push code back with legal issues fix
[ric-plt/e2mgr.git] / E2Manager / asn1codec / src / tests / configuration_update_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 // Copyright 2019 AT&T Intellectual Property
22 // Copyright 2019 Nokia
23 //
24 // Licensed under the Apache License, Version 2.0 (the "License");
25 // you may not use this file except in compliance with the License.
26 // You may obtain a copy of the License at
27 //
28 //      http://www.apache.org/licenses/LICENSE-2.0
29 //
30 // Unless required by applicable law or agreed to in writing, software
31 // distributed under the License is distributed on an "AS IS" BASIS,
32 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33 // See the License for the specific language governing permissions and
34 // limitations under the License.
35 //
36 #include <stdbool.h>
37 #include <stdio.h>
38 #include <stdlib.h>
39 #include <configuration_update_wrapper.h>
40
41 void test_build_pack_x2enb_configuration_update_ack();
42 void test_build_pack_x2enb_configuration_update_failure();
43 void test_build_pack_endc_configuration_update_ack();
44 void test_build_pack_endc_configuration_update_failure();
45 int
46 main(int argc, char* argv[])
47 {
48     test_build_pack_x2enb_configuration_update_ack();
49     test_build_pack_x2enb_configuration_update_failure();
50     test_build_pack_endc_configuration_update_ack();
51     test_build_pack_endc_configuration_update_failure();
52     exit(0);
53 }
54
55 void test_build_pack_x2enb_configuration_update_ack(){
56     size_t error_buf_size = 8192;
57     size_t packed_buf_size = 4096;
58     unsigned char responseDataBuf[packed_buf_size];
59     char responseErrorBuf[error_buf_size];
60     bool result = build_pack_x2enb_configuration_update_ack(&packed_buf_size, responseDataBuf, error_buf_size, responseErrorBuf);
61     if (!result) {
62         printf("#test_build_pack_x2enb_configuration_update_ack failed. Packing error %s\n", responseErrorBuf);
63         return;
64     }
65     printf("x2enb configuration update acknowledge packed size:%lu\nPayload:\n", packed_buf_size);
66     for (size_t i = 0; i < packed_buf_size; ++i)
67         printf("%02x",responseDataBuf[i]);
68     printf("\n");
69 }
70
71 void test_build_pack_x2enb_configuration_update_failure(){
72         size_t error_buf_size = 8192;
73         size_t packed_buf_size = 4096;
74         unsigned char responseDataBuf[packed_buf_size];
75         char responseErrorBuf[error_buf_size];
76         bool result = build_pack_x2enb_configuration_update_failure(&packed_buf_size, responseDataBuf, error_buf_size, responseErrorBuf);
77     if (!result) {
78         printf("#test_build_pack_x2enb_configuration_update_failure. Packing error %s\n", responseErrorBuf);
79         return;
80     }
81     printf("x2enb configuration update failure packed size:%lu\nPayload:\n", packed_buf_size);
82     for (size_t i = 0; i < packed_buf_size; ++i)
83         printf("%02x",responseDataBuf[i]);
84     printf("\n");
85 }
86
87 void test_build_pack_endc_configuration_update_ack(){
88     size_t error_buf_size = 8192;
89     size_t packed_buf_size = 4096;
90     unsigned char responseDataBuf[packed_buf_size];
91     char responseErrorBuf[error_buf_size];
92     bool result = build_pack_endc_configuration_update_ack(&packed_buf_size, responseDataBuf, error_buf_size, responseErrorBuf);
93     if (!result) {
94         printf("#test_build_pack_endc_configuration_update_ack. Packing error %s\n", responseErrorBuf);
95        return;
96     }
97     printf("endc configuration update acknowledge packed size:%lu\nPayload:\n", packed_buf_size);
98     for (size_t i = 0; i < packed_buf_size; ++i)
99         printf("%02x",responseDataBuf[i]);
100     printf("\n");
101
102     E2AP_PDU_t *pdu = calloc(1, sizeof(E2AP_PDU_t));
103     if (!unpack_pdu_aux(pdu, packed_buf_size, responseDataBuf,error_buf_size, responseErrorBuf,ATS_ALIGNED_BASIC_PER)){
104         printf("#%s failed. Packing error %s\n", __func__, responseErrorBuf);
105     }
106     responseErrorBuf[0] = 0;
107     asn1_pdu_printer(pdu, sizeof(responseErrorBuf), responseErrorBuf);
108     printf("#%s: %s\n", __func__, responseErrorBuf);
109
110 }
111
112 void test_build_pack_endc_configuration_update_failure(){
113         size_t error_buf_size = 8192;
114         size_t packed_buf_size = 4096;
115         unsigned char responseDataBuf[packed_buf_size];
116         char responseErrorBuf[error_buf_size];
117         bool result = build_pack_endc_configuration_update_failure(&packed_buf_size, responseDataBuf, error_buf_size, responseErrorBuf);
118     if (!result) {
119         printf("#test_build_pack_endc_configuration_update_failure. Packing error %s\n", responseErrorBuf);
120         return;
121     }
122     printf("endc configuration update failure packed size:%lu\nPayload:\n", packed_buf_size);
123     for (size_t i = 0; i < packed_buf_size; ++i)
124         printf("%02x",responseDataBuf[i]);
125     printf("\n");
126 }