[RICPLT-1703] - Reset Request + rmr_service refactoring (disabled)
[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 #include <stdbool.h>
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <configuration_update_wrapper.h>
24
25 void test_build_pack_x2enb_configuration_update_ack();
26 void test_build_pack_x2enb_configuration_update_failure();
27 void test_build_pack_endc_configuration_update_ack();
28 void test_build_pack_endc_configuration_update_failure();
29 int
30 main(int argc, char* argv[])
31 {
32     test_build_pack_x2enb_configuration_update_ack();
33     test_build_pack_x2enb_configuration_update_failure();
34     test_build_pack_endc_configuration_update_ack();
35     test_build_pack_endc_configuration_update_failure();
36     exit(0);
37 }
38
39 void test_build_pack_x2enb_configuration_update_ack(){
40     size_t error_buf_size = 8192;
41     size_t packed_buf_size = 4096;
42     unsigned char responseDataBuf[packed_buf_size];
43     char responseErrorBuf[error_buf_size];
44     bool result = build_pack_x2enb_configuration_update_ack(&packed_buf_size, responseDataBuf, error_buf_size, responseErrorBuf);
45     if (!result) {
46         printf("#test_build_pack_x2enb_configuration_update_ack failed. Packing error %s\n", responseErrorBuf);
47         return;
48     }
49     printf("x2enb configuration update acknowledge packed size:%lu\nPayload:\n", packed_buf_size);
50     for (size_t i = 0; i < packed_buf_size; ++i)
51         printf("%02x",responseDataBuf[i]);
52     printf("\n");
53 }
54
55 void test_build_pack_x2enb_configuration_update_failure(){
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_failure(&packed_buf_size, responseDataBuf, error_buf_size, responseErrorBuf);
61     if (!result) {
62         printf("#test_build_pack_x2enb_configuration_update_failure. Packing error %s\n", responseErrorBuf);
63         return;
64     }
65     printf("x2enb configuration update failure 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_endc_configuration_update_ack(){
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_endc_configuration_update_ack(&packed_buf_size, responseDataBuf, error_buf_size, responseErrorBuf);
77     if (!result) {
78         printf("#test_build_pack_endc_configuration_update_ack. Packing error %s\n", responseErrorBuf);
79        return;
80     }
81     printf("endc configuration update acknowledge 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     E2AP_PDU_t *pdu = calloc(1, sizeof(E2AP_PDU_t));
87     if (!unpack_pdu_aux(pdu, packed_buf_size, responseDataBuf,error_buf_size, responseErrorBuf,ATS_ALIGNED_BASIC_PER)){
88         printf("#%s failed. Packing error %s\n", __func__, responseErrorBuf);
89     }
90     responseErrorBuf[0] = 0;
91     asn1_pdu_printer(pdu, sizeof(responseErrorBuf), responseErrorBuf);
92     printf("#%s: %s\n", __func__, responseErrorBuf);
93
94 }
95
96 void test_build_pack_endc_configuration_update_failure(){
97         size_t error_buf_size = 8192;
98         size_t packed_buf_size = 4096;
99         unsigned char responseDataBuf[packed_buf_size];
100         char responseErrorBuf[error_buf_size];
101         bool result = build_pack_endc_configuration_update_failure(&packed_buf_size, responseDataBuf, error_buf_size, responseErrorBuf);
102     if (!result) {
103         printf("#test_build_pack_endc_configuration_update_failure. Packing error %s\n", responseErrorBuf);
104         return;
105     }
106     printf("endc configuration update failure packed size:%lu\nPayload:\n", packed_buf_size);
107     for (size_t i = 0; i < packed_buf_size; ++i)
108         printf("%02x",responseDataBuf[i]);
109     printf("\n");
110 }