Use msgb_eq_data_print() in tests
This allows to see exact byte which differs with expected output in case of test failure. Change-Id: If1285649b27843d68dfaa6f6dd3b80deee9aa148
This commit is contained in:
parent
01f9bc7bf1
commit
d3a0d91a38
|
@ -61,7 +61,6 @@ static void dequeue_and_check(gprs_llc_queue *queue, const uint8_t *exp_data,
|
|||
size_t len, const gprs_llc_queue::MetaInfo *exp_info = 0)
|
||||
{
|
||||
struct msgb *llc_msg;
|
||||
uint8_t *msg_data;
|
||||
const gprs_llc_queue::MetaInfo *info_res;
|
||||
|
||||
llc_msg = queue->dequeue(&info_res);
|
||||
|
@ -70,10 +69,8 @@ static void dequeue_and_check(gprs_llc_queue *queue, const uint8_t *exp_data,
|
|||
fprintf(stderr, "dequeued msg, length %u (expected %zu), data %s\n",
|
||||
msgb_length(llc_msg), len, msgb_hexdump(llc_msg));
|
||||
|
||||
OSMO_ASSERT(msgb_length(llc_msg) == len);
|
||||
msg_data = msgb_data(llc_msg);
|
||||
|
||||
OSMO_ASSERT(memcmp(msg_data, exp_data, len) == 0);
|
||||
if (!msgb_eq_data_print(llc_msg, exp_data, len))
|
||||
fprintf(stderr, "check failed!\n");
|
||||
|
||||
if (exp_info)
|
||||
OSMO_ASSERT(memcmp(exp_info, info_res, sizeof(*exp_info)) == 0);
|
||||
|
@ -229,7 +226,7 @@ int main(int argc, char **argv)
|
|||
log_set_use_color(osmo_stderr_target, 0);
|
||||
log_set_print_filename(osmo_stderr_target, 0);
|
||||
log_set_log_level(osmo_stderr_target, LOGL_INFO);
|
||||
log_parse_category_mask(osmo_stderr_target, "DPCU,3");
|
||||
log_parse_category_mask(osmo_stderr_target, "DPCU,3:DLGLOBAL,1:");
|
||||
|
||||
vty_init(&pcu_vty_info);
|
||||
pcu_vty_init(&gprs_log_info);
|
||||
|
|
|
@ -33,6 +33,7 @@ extern const struct log_info gprs_log_info;
|
|||
#include <osmocom/vty/telnet_interface.h>
|
||||
#include <osmocom/vty/logging.h>
|
||||
#include <osmocom/core/utils.h>
|
||||
#include <osmocom/core/msgb.h>
|
||||
#include <osmocom/core/application.h>
|
||||
}
|
||||
using namespace std;
|
||||
|
@ -216,6 +217,8 @@ void testRlcMacUplink(void *test_ctx)
|
|||
|
||||
void testCsnLeftAlignedVarBmpBounds(void *test_ctx)
|
||||
{
|
||||
struct msgb *m = msgb_alloc(80, "test");
|
||||
static uint8_t exp[] = { 0x7f, 0xff, 0xff, 0xee, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
bitvec *vector = bitvec_alloc(23, test_ctx);
|
||||
|
||||
bitvec_unhex(vector, "40200bffd161003e0e519ffffffb800000000000000000");
|
||||
|
@ -225,14 +228,17 @@ void testCsnLeftAlignedVarBmpBounds(void *test_ctx)
|
|||
&data.u.Egprs_Packet_Downlink_Ack_Nack.EGPRS_AckNack.Desc;
|
||||
decode_gsm_rlcmac_uplink(vector, &data);
|
||||
|
||||
OSMO_ASSERT(!strcmp(osmo_hexdump(urbb->URBB, 13),
|
||||
"7f ff ff ee 00 00 00 00 00 00 00 00 00 "));
|
||||
memcpy(msgb_put(m, 13), urbb->URBB, 13);
|
||||
if (!msgb_eq_data_print(m, exp, 13))
|
||||
printf("%s failed!\n", __func__);
|
||||
msgb_free(m);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
void *ctx = talloc_named_const(NULL, 1, "RLCMACTest");
|
||||
osmo_init_logging2(ctx, &gprs_log_info);
|
||||
log_parse_category_mask(osmo_stderr_target, "DPCU,3:DLGLOBAL,1:");
|
||||
|
||||
//printSizeofRLCMAC();
|
||||
testRlcMacDownlink(ctx);
|
||||
|
|
|
@ -527,12 +527,21 @@ static void test_tbf_dl_llc_loss()
|
|||
struct msgb *msg;
|
||||
int fn = 0;
|
||||
uint8_t expected_data = 1;
|
||||
static uint8_t exp[][GSM_MACBLOCK_LEN] = {
|
||||
{ 0x07, 0x00, 0x00, 0x4d, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 },
|
||||
{ 0x07, 0x00, 0x02, 0x4d, 0x02, 0x02, 0x02,
|
||||
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 },
|
||||
{ 0x07, 0x01, 0x04, 0x4d, 0x03, 0x03, 0x03,
|
||||
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 },
|
||||
};
|
||||
|
||||
while (ms->dl_tbf()->have_data()) {
|
||||
msg = ms->dl_tbf()->create_dl_acked_block(fn += 4, 7);
|
||||
fprintf(stderr, "MSG = %s\n", msgb_hexdump(msg));
|
||||
OSMO_ASSERT(msgb_length(msg) == 23);
|
||||
OSMO_ASSERT(msgb_data(msg)[10] == expected_data);
|
||||
if (!msgb_eq_data_print(msg, exp[expected_data - 1], GSM_MACBLOCK_LEN))
|
||||
printf("%s failed at %u\n", __func__, expected_data);
|
||||
|
||||
expected_data += 1;
|
||||
}
|
||||
OSMO_ASSERT(expected_data-1 == 3);
|
||||
|
@ -732,9 +741,14 @@ static gprs_rlcmac_ul_tbf *puan_urbb_len_issue(BTS *the_bts,
|
|||
|
||||
struct msgb *msg1 = ul_tbf->create_ul_ack(*fn, ts_no);
|
||||
|
||||
OSMO_ASSERT(!strcmp(osmo_hexdump(msg1->data, msg1->data_len),
|
||||
"40 24 01 3f 3e 24 46 68 90 87 b0 06 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b "
|
||||
));
|
||||
static uint8_t exp1[] = { 0x40, 0x24, 0x01, 0x3f, 0x3e, 0x24, 0x46, 0x68, 0x90, 0x87, 0xb0, 0x06,
|
||||
0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b
|
||||
};
|
||||
|
||||
if (!msgb_eq_data_print(msg1, exp1, GSM_MACBLOCK_LEN)) {
|
||||
printf("%s test failed on 1st segment!\n", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
egprs3->si = 0;
|
||||
egprs3->r = 1;
|
||||
|
@ -754,10 +768,14 @@ static gprs_rlcmac_ul_tbf *puan_urbb_len_issue(BTS *the_bts,
|
|||
|
||||
msg1 = ul_tbf->create_ul_ack(*fn, ts_no);
|
||||
|
||||
OSMO_ASSERT(!strcmp(osmo_hexdump(msg1->data, msg1->data_len),
|
||||
"40 24 01 3f 3e 24 46 68 90 88 b0 06 8b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b "
|
||||
));
|
||||
static uint8_t exp2[] = { 0x40, 0x24, 0x01, 0x3f, 0x3e, 0x24, 0x46, 0x68, 0x90, 0x88, 0xb0, 0x06, 0x8b,
|
||||
0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b
|
||||
};
|
||||
|
||||
if (!msgb_eq_data_print(msg1, exp2, GSM_MACBLOCK_LEN)) {
|
||||
printf("%s test failed on 2nd segment!\n", __func__);
|
||||
return NULL;
|
||||
}
|
||||
return ul_tbf;
|
||||
}
|
||||
|
||||
|
@ -3205,6 +3223,10 @@ void test_packet_access_rej_epdan()
|
|||
{
|
||||
BTS the_bts;
|
||||
uint32_t tlli = 0xffeeddcc;
|
||||
static uint8_t exp[] = { 0x40, 0x84, 0x7f, 0xf7, 0x6e, 0xe6, 0x41, 0x4b,
|
||||
0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b,
|
||||
0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b
|
||||
};
|
||||
|
||||
printf("=== start %s ===\n", __func__);
|
||||
setup_bts(&the_bts, 4);
|
||||
|
@ -3217,8 +3239,9 @@ void test_packet_access_rej_epdan()
|
|||
printf("packet reject: %s\n",
|
||||
osmo_hexdump(msg->data, 23));
|
||||
|
||||
OSMO_ASSERT(!strcmp(osmo_hexdump(msg->data, 23),
|
||||
"40 84 7f f7 6e e6 41 4b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b "));
|
||||
if (!msgb_eq_data_print(msg, exp, GSM_MACBLOCK_LEN))
|
||||
printf("%s test failed!\n", __func__);
|
||||
|
||||
printf("=== end %s ===\n", __func__);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue