Commit df2c92e6 authored by Guido Casati's avatar Guido Casati

Add test for F1AP Setup Response enc/dec lib

parent 30628b82
......@@ -3,6 +3,7 @@
#include <stdio.h>
#include "common/utils/assertions.h"
#include "common/utils/utils.h"
#include "f1ap_messages_types.h"
#include "F1AP_F1AP-PDU.h"
......@@ -271,11 +272,70 @@ static void test_f1ap_setup_request(void)
free_f1ap_setup_request(&orig);
}
/**
* @brief Test F1AP Setup Response Encoding/Decoding
*/
static void test_f1ap_setup_response(void)
{
/* allocate memory */
/* gNB_CU_name */
char *cu_name = "OAI-CU";
int len = strlen(cu_name) + 1;
uint8_t *gNB_CU_name = calloc(len, sizeof(uint8_t));
AssertFatal(gNB_CU_name != NULL, "out of memory\n");
memcpy((void *)gNB_CU_name, cu_name, len);
/* create message */
f1ap_setup_resp_t orig = {
.gNB_CU_name = (char *)gNB_CU_name,
.transaction_id = 2,
.rrc_ver[0] = 12,
.rrc_ver[1] = 34,
.rrc_ver[2] = 56,
.num_cells_to_activate = 1,
.cells_to_activate[0].nr_cellid = 123456,
.cells_to_activate[0].nrpci = 1,
.cells_to_activate[0].plmn.mcc = 12,
.cells_to_activate[0].plmn.mnc = 123,
.cells_to_activate[0].plmn.mnc_digit_length = 3,
};
/* Cells to activate */
if (orig.num_cells_to_activate) {
/* SI_container */
char *s = "test";
int SI_container_length = strlen(s) + 1;
orig.cells_to_activate[0].num_SI = 1;
f1ap_sib_msg_t *SI_msg = &orig.cells_to_activate[0].SI_msg[0];
SI_msg->SI_container = malloc_or_fail(SI_container_length);
memcpy(SI_msg->SI_container, (uint8_t *)s, SI_container_length);
SI_msg->SI_container_length = SI_container_length;
SI_msg->SI_type = 7;
}
F1AP_F1AP_PDU_t *f1enc = encode_f1ap_setup_response(&orig);
F1AP_F1AP_PDU_t *f1dec = f1ap_encode_decode(f1enc);
f1ap_msg_free(f1enc);
f1ap_setup_resp_t decoded = {0};
bool ret = decode_f1ap_setup_response(f1dec, &decoded);
AssertFatal(ret, "decode_f1ap_setup_response(): could not decode message\n");
f1ap_msg_free(f1dec);
ret = eq_f1ap_setup_response(&orig, &decoded);
AssertFatal(ret, "eq_f1ap_setup_response(): decoded message doesn't match\n");
free_f1ap_setup_response(&decoded);
f1ap_setup_resp_t cp = cp_f1ap_setup_response(&orig);
ret = eq_f1ap_setup_response(&orig, &cp);
AssertFatal(ret, "eq_f1ap_setup_response(): copied message doesn't match\n");
free_f1ap_setup_response(&cp);
free_f1ap_setup_response(&orig);
}
int main()
{
test_initial_ul_rrc_message_transfer();
test_dl_rrc_message_transfer();
test_ul_rrc_message_transfer();
test_f1ap_setup_request();
test_f1ap_setup_response();
return 0;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment