I release step 2 of 2
[ric-plt/e2mgr.git] / E2Manager / 3rdparty / asn1codec / src / tests / configuration_update_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 #include <stdbool.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <configuration_update_wrapper.h>
28
29 void test_build_pack_x2enb_configuration_update_ack();
30 void test_build_pack_x2enb_configuration_update_failure();
31 void test_build_pack_endc_configuration_update_ack();
32 void test_build_pack_endc_configuration_update_failure();
33 int
34 main(int argc, char* argv[])
35 {
36     test_build_pack_x2enb_configuration_update_ack();
37     test_build_pack_x2enb_configuration_update_failure();
38     test_build_pack_endc_configuration_update_ack();
39     test_build_pack_endc_configuration_update_failure();
40     exit(0);
41 }
42
43 void test_build_pack_x2enb_configuration_update_ack(){
44     size_t error_buf_size = 8192;
45     size_t packed_buf_size = 4096;
46     unsigned char responseDataBuf[packed_buf_size];
47     char responseErrorBuf[error_buf_size];
48     bool result = build_pack_x2enb_configuration_update_ack(&packed_buf_size, responseDataBuf, error_buf_size, responseErrorBuf);
49     if (!result) {
50         printf("#test_build_pack_x2enb_configuration_update_ack failed. Packing error %s\n", responseErrorBuf);
51         return;
52     }
53     printf("x2enb configuration update acknowledge packed size:%lu\nPayload:\n", packed_buf_size);
54     for (size_t i = 0; i < packed_buf_size; ++i)
55         printf("%02x",responseDataBuf[i]);
56     printf("\n");
57 }
58
59 void test_build_pack_x2enb_configuration_update_failure(){
60         size_t error_buf_size = 8192;
61         size_t packed_buf_size = 4096;
62         unsigned char responseDataBuf[packed_buf_size];
63         char responseErrorBuf[error_buf_size];
64         bool result = build_pack_x2enb_configuration_update_failure(&packed_buf_size, responseDataBuf, error_buf_size, responseErrorBuf);
65     if (!result) {
66         printf("#test_build_pack_x2enb_configuration_update_failure. Packing error %s\n", responseErrorBuf);
67         return;
68     }
69     printf("x2enb configuration update failure packed size:%lu\nPayload:\n", packed_buf_size);
70     for (size_t i = 0; i < packed_buf_size; ++i)
71         printf("%02x",responseDataBuf[i]);
72     printf("\n");
73 }
74
75 void test_build_pack_endc_configuration_update_ack(){
76     size_t error_buf_size = 8192;
77     size_t packed_buf_size = 4096;
78     unsigned char responseDataBuf[packed_buf_size];
79     char responseErrorBuf[error_buf_size];
80     bool result = build_pack_endc_configuration_update_ack(&packed_buf_size, responseDataBuf, error_buf_size, responseErrorBuf);
81     if (!result) {
82         printf("#test_build_pack_endc_configuration_update_ack. Packing error %s\n", responseErrorBuf);
83        return;
84     }
85     printf("endc configuration update acknowledge packed size:%lu\nPayload:\n", packed_buf_size);
86     for (size_t i = 0; i < packed_buf_size; ++i)
87         printf("%02x",responseDataBuf[i]);
88     printf("\n");
89
90     E2AP_PDU_t *pdu = calloc(1, sizeof(E2AP_PDU_t));
91     if (!unpack_pdu_aux(pdu, packed_buf_size, responseDataBuf,error_buf_size, responseErrorBuf,ATS_ALIGNED_BASIC_PER)){
92         printf("#%s failed. Packing error %s\n", __func__, responseErrorBuf);
93     }
94     responseErrorBuf[0] = 0;
95     asn1_pdu_printer(pdu, sizeof(responseErrorBuf), responseErrorBuf);
96     printf("#%s: %s\n", __func__, responseErrorBuf);
97
98 }
99
100 void test_build_pack_endc_configuration_update_failure(){
101         size_t error_buf_size = 8192;
102         size_t packed_buf_size = 4096;
103         unsigned char responseDataBuf[packed_buf_size];
104         char responseErrorBuf[error_buf_size];
105         bool result = build_pack_endc_configuration_update_failure(&packed_buf_size, responseDataBuf, error_buf_size, responseErrorBuf);
106     if (!result) {
107         printf("#test_build_pack_endc_configuration_update_failure. Packing error %s\n", responseErrorBuf);
108         return;
109     }
110     printf("endc configuration update failure packed size:%lu\nPayload:\n", packed_buf_size);
111     for (size_t i = 0; i < packed_buf_size; ++i)
112         printf("%02x",responseDataBuf[i]);
113     printf("\n");
114 }