J release: Release container Image
[ric-plt/e2mgr.git] / E2Manager / 3rdparty / asn1codec / src / tests / x2reset_request_wrapper_test.c
1 /*
2  * Copyright 2019 AT&T Intellectual Property
3  * Copyright 2019 Nokia
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 /*
19  * This source code is part of the near-RT RIC (RAN Intelligent Controller)
20  * platform project (RICP).
21  */
22
23
24
25 #include <stdbool.h>
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <x2reset_request_wrapper.h>
29
30 void test_build_pack_x2reset_request();
31 void test_unpack(void);
32
33 int
34 main(int argc, char* argv[])
35 {
36     test_build_pack_x2reset_request();
37     exit(0);
38 }
39
40 void test_build_pack_x2reset_request(){
41     size_t error_buf_size = 8192;
42     size_t packed_buf_size = 4096;
43     unsigned char responseDataBuf[packed_buf_size];
44     char responseErrorBuf[error_buf_size];
45     bool result;
46     E2AP_PDU_t *pdu;
47     /**********************************************************************************/
48
49     packed_buf_size = 4096;
50     result = build_pack_x2reset_request(Cause_PR_radioNetwork,CauseRadioNetwork_time_critical_handover,
51                     &packed_buf_size, responseDataBuf, error_buf_size, responseErrorBuf);
52     if (!result) {
53         printf("#%s failed. Packing error %s\n", __func__, responseErrorBuf);
54         return;
55     }
56     printf("#%s packed size:%lu\nPayload:\n", __func__, packed_buf_size);
57     for (size_t i = 0; i < packed_buf_size; ++i)
58         printf("%02x",responseDataBuf[i]);
59     printf("\n");
60
61     pdu =calloc(1, sizeof(E2AP_PDU_t));
62     if (!unpack_pdu_aux(pdu, packed_buf_size, responseDataBuf,error_buf_size, responseErrorBuf,ATS_ALIGNED_BASIC_PER)){
63         printf("#%s failed. Packing error %s\n", __func__, responseErrorBuf);
64     }
65     responseErrorBuf[0] = 0;
66     asn1_pdu_printer(pdu, sizeof(responseErrorBuf), responseErrorBuf);
67     printf("#%s: %s\n", __func__, responseErrorBuf);
68
69 }
70