2 ==================================================================================
4 Copyright (c) 2019-2020 AT&T Intellectual Property.
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 ==================================================================================
22 * Created on: Oct 23, 2020
23 * Author: Shraboni Jana
26 #ifndef TEST_TEST_E2AP_H_
27 #define TEST_TEST_E2AP_H_
29 #include<gtest/gtest.h>
31 #include "e2ap_control_failure.hpp"
33 #include "e2ap_control_ack.hpp"
34 TEST(E2AP, ControlAcknowledgementEncode)
37 unsigned char buff[1024];
38 size_t buf_len = 1024;
40 E2APControlAcknowledge::ControlAcknowledgeIEs infoObj;
41 infoObj.set_ranFunctionID(1);
42 infoObj.set_ricRequestorID(1);
43 infoObj.set_ricInstanceID(1);
44 infoObj.set_ricControlStatus(1);
45 infoObj.set_ricCallProcessID("CallProcessID");
46 infoObj.set_ricControlOutcome("ControlOutcome");
49 E2APControlAcknowledge cntrlObj(infoObj);
51 bool res = cntrlObj.encode(buff, &buf_len);
54 std::cout << cntrlObj.get_error() << std::endl;
58 pFile = fopen ("controlack1.per","w");
61 fwrite (buff , sizeof(char), buf_len, pFile);
67 TEST(E2SM, ControlAcknowledgementDecode)
69 unsigned char e2ap_buff[4096];
70 char filename[100] = "controlack1.per";
72 fp = fopen(filename,"rb");
77 size_t e2ap_buff_size = fread(e2ap_buff, 1, 4096, fp);
80 fprintf(stderr, "%s: Empty or broken\n", filename);
83 fprintf(stderr, "e2ap buffer size: %ld \n", e2ap_buff_size);
86 bool decode_status = true;
88 E2APControlAcknowledge e2obj(&e2ap_buff[0],&e2ap_buff_size);
91 } catch(const char* e){
92 decode_status = false;
93 std::cout << "Error Message: " << e << std::endl;
97 ASSERT_TRUE(decode_status);
100 TEST(E2AP, ControlFailureEncode)
103 unsigned char buff[1024];
104 size_t buf_len = 1024;
106 E2APControlFailure::ControlFailureIEs infoObj;
107 infoObj.set_ranFunctionID(1);
108 infoObj.set_ricRequestorID(1);
109 infoObj.set_ricInstanceID(1);
110 infoObj.set_ricCause(1);
111 infoObj.set_ricSubCause(1);
112 infoObj.set_ricCallProcessID("CallProcessID");
113 infoObj.set_ricControlOutcome("ControlOutcome");
116 E2APControlFailure cntrlObj(infoObj);
118 bool res = cntrlObj.encode(buff, &buf_len);
121 std::cout << cntrlObj.get_error() << std::endl;
125 pFile = fopen ("controlfail1.per","w");
128 fwrite (buff , sizeof(char), buf_len, pFile);
134 TEST(E2SM, ControlFailureDecode)
136 unsigned char e2ap_buff[1024];
137 char filename[100] = "controlfail1.per";
139 fp = fopen(filename,"rb");
144 size_t e2ap_buff_size = fread(e2ap_buff, 1, 1024, fp);
147 fprintf(stderr, "%s: Empty or broken\n", filename);
150 fprintf(stderr, "e2ap buffer size: %ld \n", e2ap_buff_size);
153 bool decode_status = true;
155 E2APControlFailure e2obj(&e2ap_buff[0],&e2ap_buff_size);
158 } catch(const char* e){
159 decode_status = false;
160 std::cout << "Error Message: " << e << std::endl;
164 ASSERT_TRUE(decode_status);
168 #endif /* TEST_TEST_E2AP_H_ */