Add Bearer Context Release Complete enc/dec lib and unit test

This commit is contained in:
Guido Casati
2025-05-12 21:45:58 +02:00
parent f8eba806da
commit 8f9761ac84
3 changed files with 133 additions and 0 deletions
+40
View File
@@ -306,6 +306,45 @@ static void test_bearer_context_release_command(void)
free_e1_bearer_context_release_command(&cp);
}
/** @brief Test E1AP Bearer Context Release Complete encoding/decoding */
static void test_bearer_context_release_complete(void)
{
e1ap_bearer_release_cplt_t orig = {
.gNB_cu_cp_ue_id = 0x1234,
.gNB_cu_up_ue_id = 0x5678,
};
// Encode the original message
E1AP_E1AP_PDU_t *enc = encode_e1_bearer_context_release_complete(&orig);
// E1AP decode the encoded message
E1AP_E1AP_PDU_t *dec = e1ap_encode_decode(enc);
// Free the E1AP encoded message
e1ap_msg_free(enc);
// Decode the encoded message
e1ap_bearer_release_cplt_t decoded = {0};
AssertFatal(decode_e1_bearer_context_release_complete(&decoded, dec), "decode_e1_bearer_context_release_complete failed");
// Free the E1AP decoded message
e1ap_msg_free(dec);
// Equality check original/decoded
AssertFatal(eq_bearer_context_release_complete(&orig, &decoded), "eq_bearer_context_release_complete: decoded message does not match original");
// Free the memory for the decoded message
free_e1_bearer_context_release_complete(&decoded);
// Deep copy and equality check of the original message
e1ap_bearer_release_cplt_t cp = cp_bearer_context_release_complete(&orig);
AssertFatal(eq_bearer_context_release_complete(&orig, &cp), "eq_bearer_context_release_complete(): copied message doesn't match\n");
// Cleanup
free_e1_bearer_context_release_complete(&orig);
free_e1_bearer_context_release_complete(&cp);
}
/**
* @brief Test CU-UP Setup Request encoding/decoding
*/
@@ -717,5 +756,6 @@ int main()
test_bearer_context_modification_response_fail();
// Bearer Context Release
test_bearer_context_release_command();
test_bearer_context_release_complete();
return 0;
}