Cleanup of logs and asserts used in packing/unpacking procedures.

Change FAPI packing/unpacking to make use of existing nFAPI structs.
Change unitary tests to use existing nFAPI structs when testing for FAPI support.
Update PARAM.response tlv comparison.
parent a8ce9cfc
...@@ -44,10 +44,11 @@ ...@@ -44,10 +44,11 @@
#include "nfapi_interface.h" #include "nfapi_interface.h"
#include "nfapi_nr_interface_scf.h" #include "nfapi_nr_interface_scf.h"
#include "nfapi.h" #include "nfapi.h"
#include "assertions.h"
#include "common/utils/LOG/log.h"
#include "debug.h" #include "debug.h"
#define DEBUG_FAPI_NFAPI_MSGS 0
typedef struct { typedef struct {
uint8_t num_msg; uint8_t num_msg;
uint8_t opaque_handle; uint8_t opaque_handle;
......
This diff is collapsed.
...@@ -3,28 +3,22 @@ ...@@ -3,28 +3,22 @@
int main(int n, char *v[]) int main(int n, char *v[])
{ {
srand(time(NULL)); srand(time(NULL));
#ifndef _STANDALONE_TESTING_
logInit(); logInit();
set_glog(OAILOG_DISABLE); set_glog(OAILOG_DISABLE);
#endif
fapi_nr_param_request_scf_t req; nfapi_nr_param_request_scf_t req;
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
req.header.message_id = NFAPI_NR_PHY_MSG_TYPE_PARAM_REQUEST; req.header.message_id = NFAPI_NR_PHY_MSG_TYPE_PARAM_REQUEST;
req.header.num_msg = rand16(); // FAPI doesn't have these 2 following parameters, dont use
req.header.opaque_handle = rand16(); req.header.phy_id = 0;
req.header.spare = 0;
uint8_t msg_buf[8192]; uint8_t msg_buf[8192];
uint16_t msg_len = sizeof(req); uint16_t msg_len = sizeof(req);
// first test the packing procedure // first test the packing procedure
printf("Test the packing procedure by checking the return value\n");
int pack_result = fapi_nr_p5_message_pack(&req, msg_len, msg_buf, sizeof(msg_buf), NULL); int pack_result = fapi_nr_p5_message_pack(&req, msg_len, msg_buf, sizeof(msg_buf), NULL);
// PARAM.request message body length is 0 // PARAM.request message body length is 0
AssertFatal(pack_result == 0 + NFAPI_HEADER_LENGTH, DevAssert(pack_result == 0 + NFAPI_HEADER_LENGTH);
"fapi_p5_message_pack packed_length not equal to NFAPI_HEADER_LENGTH + body length (8+0)! Reported value was %d\n",
pack_result);
printf("fapi_p5_message_pack packed_length 0x%02x\n", pack_result);
for (int i = 0; i < pack_result; i++) { for (int i = 0; i < pack_result; i++) {
printf("0x%02x ", msg_buf[i]); printf("0x%02x ", msg_buf[i]);
} }
...@@ -43,54 +37,16 @@ int main(int n, char *v[]) ...@@ -43,54 +37,16 @@ int main(int n, char *v[])
printf("Test the header unpacking and compare with initial message\n"); printf("Test the header unpacking and compare with initial message\n");
int unpack_header_result = fapi_nr_p5_message_header_unpack(&pReadPackedMessage, NFAPI_HEADER_LENGTH, &header, sizeof(header), 0); int unpack_header_result = fapi_nr_p5_message_header_unpack(&pReadPackedMessage, NFAPI_HEADER_LENGTH, &header, sizeof(header), 0);
AssertFatal(unpack_header_result >= 0, "nfapi_p5_message_header_unpack failed with return %d\n", unpack_header_result); AssertFatal(unpack_header_result >= 0, "nfapi_p5_message_header_unpack failed with return %d\n", unpack_header_result);
printf("num_msg: 0x%02x\n", header.num_msg); DevAssert(header.message_id == req.header.message_id);
AssertFatal(header.num_msg == req.header.num_msg, DevAssert(header.message_length == req.header.message_length);
"num_msg was not the same as the packed value! Unpacked value was 0x%02x , and Packed value was 0x%02x\n",
header.num_msg,
req.header.num_msg);
printf("opaque_handle: 0x%02x\n", header.opaque_handle);
AssertFatal(header.opaque_handle == req.header.opaque_handle,
"Spare was not the same as the packed value! Unpacked value was 0x%02x , and Packed value was 0x%02x\n",
header.opaque_handle,
req.header.opaque_handle);
printf("Message ID : 0x%02x\n", header.message_id);
AssertFatal(header.message_id == req.header.message_id,
"Message ID was not the same as the packed value! Unpacked value was 0x%02x , and Packed value was 0x%02x\n",
header.message_id,
req.header.message_id);
printf("Message length : 0x%02x\n", header.message_length);
AssertFatal(header.message_length == req.header.message_length,
"Message length was not the same as the packed value! Unpacked value was 0x%02x , and Packed value was 0x%02x\n",
header.message_length,
req.header.message_length);
printf("Test the unpacking and compare with initial message\n");
// test the unpacking and compare with initial message // test the unpacking and compare with initial message
fapi_nr_param_request_scf_t unpacked_req; nfapi_nr_param_request_scf_t unpacked_req;
memset(&unpacked_req, 0, sizeof(unpacked_req)); memset(&unpacked_req, 0, sizeof(unpacked_req));
int unpack_result = int unpack_result =
fapi_nr_p5_message_unpack(msg_buf, header.message_length + NFAPI_HEADER_LENGTH, &unpacked_req, sizeof(unpacked_req), NULL); fapi_nr_p5_message_unpack(msg_buf, header.message_length + NFAPI_HEADER_LENGTH, &unpacked_req, sizeof(unpacked_req), NULL);
AssertFatal(unpack_result >= 0, "fapi_nr_p5_message_unpack failed with return %d\n", unpack_result); DevAssert(unpack_result >= 0);
printf("num_msg: 0x%02x\n", unpacked_req.header.num_msg); DevAssert(unpacked_req.header.message_id == req.header.message_id);
AssertFatal(unpacked_req.header.num_msg == req.header.num_msg, DevAssert(unpacked_req.header.message_length == req.header.message_length);
"num_msg was not the same as the packed value! Unpacked value was 0x%02x , and Packed value was 0x%02x\n",
unpacked_req.header.num_msg,
req.header.num_msg);
printf("opaque_handle: 0x%02x\n", unpacked_req.header.opaque_handle);
AssertFatal(unpacked_req.header.opaque_handle == req.header.opaque_handle,
"opaque_handle was not the same as the packed value! Unpacked value was 0x%02x , and Packed value was 0x%02x\n",
unpacked_req.header.opaque_handle,
req.header.opaque_handle);
printf("Message id : 0x%02x\n", unpacked_req.header.message_id);
AssertFatal(unpacked_req.header.message_id == req.header.message_id,
"Message id was not 0x%02x, was 0x%02x\n",
req.header.message_id,
unpacked_req.header.message_id);
printf("Message length : 0x%02x\n", unpacked_req.header.message_length);
AssertFatal(unpacked_req.header.message_length == req.header.message_length,
"Message length was not the same as the value previously packed, was 0x%02x\n",
unpacked_req.header.message_length);
// All tests successful! // All tests successful!
return 0; 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