Fix licensing issues
[ric-plt/e2mgr.git] / E2Manager / 3rdparty / asn1codec / src / tests / x2reset_request_wrapper_test.c
1 /*
2  *
3  * Copyright 2019 AT&T Intellectual Property
4  * Copyright 2019 Nokia
5  *
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
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
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  *
18  */
19
20
21 #include <stdbool.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <x2reset_request_wrapper.h>
25
26 void test_build_pack_x2reset_request();
27 void test_unpack(void);
28
29 int
30 main(int argc, char* argv[])
31 {
32     test_build_pack_x2reset_request();
33     exit(0);
34 }
35
36 void test_build_pack_x2reset_request(){
37     size_t error_buf_size = 8192;
38     size_t packed_buf_size = 4096;
39     unsigned char responseDataBuf[packed_buf_size];
40     char responseErrorBuf[error_buf_size];
41     bool result;
42     E2AP_PDU_t *pdu;
43     /**********************************************************************************/
44
45     packed_buf_size = 4096;
46     result = build_pack_x2reset_request(Cause_PR_radioNetwork,CauseRadioNetwork_time_critical_handover,
47                     &packed_buf_size, responseDataBuf, error_buf_size, responseErrorBuf);
48     if (!result) {
49         printf("#%s failed. Packing error %s\n", __func__, responseErrorBuf);
50         return;
51     }
52     printf("#%s packed size:%lu\nPayload:\n", __func__, packed_buf_size);
53     for (size_t i = 0; i < packed_buf_size; ++i)
54         printf("%02x",responseDataBuf[i]);
55     printf("\n");
56
57     pdu =calloc(1, sizeof(E2AP_PDU_t));
58     if (!unpack_pdu_aux(pdu, packed_buf_size, responseDataBuf,error_buf_size, responseErrorBuf,ATS_ALIGNED_BASIC_PER)){
59         printf("#%s failed. Packing error %s\n", __func__, responseErrorBuf);
60     }
61     responseErrorBuf[0] = 0;
62     asn1_pdu_printer(pdu, sizeof(responseErrorBuf), responseErrorBuf);
63     printf("#%s: %s\n", __func__, responseErrorBuf);
64
65 }
66