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 ==================================================================================
21 * Created on: Apr, 2020
22 * Author: Shraboni Jana
25 #ifndef TEST_TEST_ASN_H_
26 #define TEST_TEST_ASN_H_
28 #include<gtest/gtest.h>
31 #include "e2sm_control.hpp"
32 #include "e2ap_indication.hpp"
33 #include "e2sm_indication.hpp"
34 #include "e2ap_control.hpp"
37 TEST(E2SM, IndicationMessageEncode)
39 unsigned char buff[1024];
40 size_t buf_len = 1024;
43 HWIndicationHeader headerObj;
44 headerObj.set_ricIndicationHeader(1);
45 std::cout << headerObj.get_error() << std::endl;
47 HWIndicationMessage messageObj;
48 messageObj.set_hw_message("HelloWorld-E2SM");
49 std::cout << messageObj.get_error() << std::endl;
51 E2APIndication<HWIndicationHeader,HWIndicationMessage>::IndicationIEs infoObj;
52 infoObj.set_ranFunctionID(1);
53 infoObj.set_ricActionID(1);
54 infoObj.set_ricRequestorID(1);
55 infoObj.set_ricIndicationHeader(headerObj);
56 infoObj.set_ricIndicationMessage(messageObj);
58 E2APIndication<HWIndicationHeader,HWIndicationMessage> e2obj(infoObj);
60 bool res = e2obj.encode(buff, &buf_len);
63 std::cout << e2obj.get_error() << std::endl;
69 pFile = fopen ("indication2.per","w");
72 fputs ((const char*)buff,pFile);
77 TEST(E2SM, IndicationMessageDecode)
79 unsigned char e2ap_buff[4096];
80 char filename[100] = "indication2.per";
82 fp = fopen(filename,"rb");
87 size_t e2ap_buff_size = fread(e2ap_buff, 1, 4096, fp);
90 fprintf(stderr, "%s: Empty or broken\n", filename);
93 fprintf(stderr, "e2ap buffer size: %ld \n", e2ap_buff_size);
96 bool decode_status = true;
98 E2APIndication<HWIndicationHeader,HWIndicationMessage> e2obj(&e2ap_buff[0],&e2ap_buff_size);
99 E2APIndication<HWIndicationHeader,HWIndicationMessage>::IndicationIEs indIEs = e2obj.getIndicationIEs();
100 std::cout << indIEs.get_ricRequestorID() << std::endl;
102 size_t hsize = indIEs.get_ricIndicationHeader_size();
103 unsigned char* hvalue = (unsigned char*)indIEs.get_ricIndicationHeader();
104 HWIndicationHeader headerObj(&hvalue[0], &hsize);
106 size_t msize = indIEs.get_ricIndicationMessage_size();
107 auto mvalue = (unsigned char*)indIEs.get_ricIndicationMessage();
108 HWIndicationMessage msgObj(&mvalue[0], &msize);
110 } catch(const char* e){
111 decode_status = false;
112 std::cout << "Error Message: " << e << std::endl;
116 ASSERT_TRUE(decode_status);
120 TEST(E2SM, ControlMessage)
123 unsigned char buff[1024];
124 size_t buf_len = 1024;
128 HWControlMessage msgObj;
129 msgObj.set_ricControlMessage("ControlMessage");
131 HWControlHeader headObj;
132 headObj.set_ricControlHeader(1);
134 E2APControlMessage<HWControlHeader,HWControlMessage>::ControlRequestIEs infoObj;
135 infoObj.set_ranFunctionID(1);
136 infoObj.set_ricRequestorID(1);
137 infoObj.set_ricControlHeader(headObj);
138 infoObj.set_ricControlMessage(msgObj);
141 E2APControlMessage<HWControlHeader,HWControlMessage> cntrlObj(infoObj);
143 bool res = cntrlObj.encode(buff, &buf_len);
146 std::cout << cntrlObj.get_error() << std::endl;
151 #endif /* TEST_TEST_ASN_H_ */