X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Ftest_e2ap.h;fp=test%2Ftest_e2ap.h;h=427d8400e34706df6be1b2e491424cb4418ec6b8;hb=4edb52e022fe23b8951488c959458ad68b644d47;hp=0000000000000000000000000000000000000000;hpb=ea129fa14c89d8f5cedacd9afc1e4dd7a30f1ae4;p=ric-app%2Fhw.git diff --git a/test/test_e2ap.h b/test/test_e2ap.h new file mode 100644 index 0000000..427d840 --- /dev/null +++ b/test/test_e2ap.h @@ -0,0 +1,168 @@ +/* +================================================================================== + + Copyright (c) 2019-2020 AT&T Intellectual Property. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +================================================================================== +*/ +/* + * test_e2ap.h + * + * Created on: Oct 23, 2020 + * Author: Shraboni Jana + */ + +#ifndef TEST_TEST_E2AP_H_ +#define TEST_TEST_E2AP_H_ +#include +#include + +#include "e2ap_control_failure.hpp" +#include "xapp.hpp" +#include "e2ap_control_ack.hpp" +TEST(E2AP, ControlAcknowledgementEncode) +{ + + unsigned char buff[1024]; + size_t buf_len = 1024; + + E2APControlAcknowledge::ControlAcknowledgeIEs infoObj; + infoObj.set_ranFunctionID(1); + infoObj.set_ricRequestorID(1); + infoObj.set_ricInstanceID(1); + infoObj.set_ricControlStatus(1); + infoObj.set_ricCallProcessID("CallProcessID"); + infoObj.set_ricControlOutcome("ControlOutcome"); + + + E2APControlAcknowledge cntrlObj(infoObj); + + bool res = cntrlObj.encode(buff, &buf_len); + if(!res) + { + std::cout << cntrlObj.get_error() << std::endl; + } + ASSERT_TRUE(res); + FILE * pFile; + pFile = fopen ("controlack1.per","w"); + if (pFile!=NULL) + { + fwrite (buff , sizeof(char), buf_len, pFile); + sleep(2); + fclose (pFile); + } + +} +TEST(E2SM, ControlAcknowledgementDecode) +{ + unsigned char e2ap_buff[4096]; + char filename[100] = "controlack1.per"; + FILE *fp; + fp = fopen(filename,"rb"); + if(!fp) { + perror(filename); + exit(1); } + + size_t e2ap_buff_size = fread(e2ap_buff, 1, 4096, fp); + fclose(fp); + if(!e2ap_buff_size){ + fprintf(stderr, "%s: Empty or broken\n", filename); + exit(1); + } else { + fprintf(stderr, "e2ap buffer size: %ld \n", e2ap_buff_size); + } + + bool decode_status = true; + try{ + E2APControlAcknowledge e2obj(&e2ap_buff[0],&e2ap_buff_size); + + + } catch(const char* e){ + decode_status = false; + std::cout << "Error Message: " << e << std::endl; + } + + + ASSERT_TRUE(decode_status); + +} +TEST(E2AP, ControlFailureEncode) +{ + + unsigned char buff[1024]; + size_t buf_len = 1024; + + E2APControlFailure::ControlFailureIEs infoObj; + infoObj.set_ranFunctionID(1); + infoObj.set_ricRequestorID(1); + infoObj.set_ricInstanceID(1); + infoObj.set_ricCause(1); + infoObj.set_ricSubCause(1); + infoObj.set_ricCallProcessID("CallProcessID"); + infoObj.set_ricControlOutcome("ControlOutcome"); + + + E2APControlFailure cntrlObj(infoObj); + + bool res = cntrlObj.encode(buff, &buf_len); + if(!res) + { + std::cout << cntrlObj.get_error() << std::endl; + } + ASSERT_TRUE(res); + FILE * pFile; + pFile = fopen ("controlfail1.per","w"); + if (pFile!=NULL) + { + fwrite (buff , sizeof(char), buf_len, pFile); + sleep(2); + fclose (pFile); + } + +} +TEST(E2SM, ControlFailureDecode) +{ + unsigned char e2ap_buff[1024]; + char filename[100] = "controlfail1.per"; + FILE *fp; + fp = fopen(filename,"rb"); + if(!fp) { + perror(filename); + exit(1); } + + size_t e2ap_buff_size = fread(e2ap_buff, 1, 1024, fp); + fclose(fp); + if(!e2ap_buff_size){ + fprintf(stderr, "%s: Empty or broken\n", filename); + exit(1); + } else { + fprintf(stderr, "e2ap buffer size: %ld \n", e2ap_buff_size); + } + + bool decode_status = true; + try{ + E2APControlFailure e2obj(&e2ap_buff[0],&e2ap_buff_size); + + + } catch(const char* e){ + decode_status = false; + std::cout << "Error Message: " << e << std::endl; + } + + + ASSERT_TRUE(decode_status); + +} + +#endif /* TEST_TEST_E2AP_H_ */