From 421068e643ba295c849ec86d6579d1853447b12d Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Fri, 20 Jul 2018 19:12:18 +0200 Subject: tests: codec: ecu_fr: Add buffer with unequal XMAXC values This buffer verifies that all XMAXC fields must be zero before the entire buffer is considered as silent by osmo_ecu_fr_conceal(). Change-Id: I14a192d001b5e167437cedbe76a1a3dd84dde35c --- tests/codec/codec_ecu_fr_test.c | 43 +++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 17 deletions(-) (limited to 'tests/codec/codec_ecu_fr_test.c') diff --git a/tests/codec/codec_ecu_fr_test.c b/tests/codec/codec_ecu_fr_test.c index 3a99fc72..3561c442 100644 --- a/tests/codec/codec_ecu_fr_test.c +++ b/tests/codec/codec_ecu_fr_test.c @@ -73,8 +73,11 @@ static const char *fr_frames_hex[] = { }; /* Example of a good frame */ -static const char *sample_frame_hex = \ - "d9ec9be212901f802335598c501f805bad3d4ba01f809b69df5a501f809cd1b4da"; +static const char *sample_frame_hex[] = { + "d9ec9be212901f802335598c501f805bad3d4ba01f809b69df5a501f809cd1b4da", + "d9ec9be212901d802335598c5013805bad3d4ba01f809b69df5a5019809cd1b4da", + NULL +}; #define GSM610_XMAXC_LEN 6 static void parse_xmaxc_frame(uint8_t *frame, uint64_t xmaxc_res[4]) @@ -108,26 +111,32 @@ void test_fr_concealment(void) uint8_t frame[GSM_FR_BYTES]; uint64_t xmaxc[4]; int i, rc; + int j = 0; - /* Parse frame from string to hex */ - osmo_hexparse(sample_frame_hex, frame, GSM_FR_BYTES); - parse_xmaxc_frame(frame, xmaxc); - printf("Start with: %s, XMAXC: [%"PRIx64", %"PRIx64", %"PRIx64", %"PRIx64"]\n", - sample_frame_hex, xmaxc[0], xmaxc[1], xmaxc[2], xmaxc[3]); + while (sample_frame_hex[j] != NULL) { + /* Parse frame from string to hex */ + osmo_hexparse(sample_frame_hex[j], frame, GSM_FR_BYTES); + parse_xmaxc_frame(frame, xmaxc); + printf("Start with: %s, XMAXC: [%"PRIx64", %"PRIx64", %"PRIx64", %"PRIx64"]\n", + sample_frame_hex[j], xmaxc[0], xmaxc[1], xmaxc[2], xmaxc[3]); - /* Reset the ECU with the proposed known good frame */ - osmo_ecu_fr_reset(&state, frame); + /* Reset the ECU with the proposed known good frame */ + osmo_ecu_fr_reset(&state, frame); - /* Now pretend that we do not receive any good frames anymore */ - for (i = 0; i < 20; i++) { + /* Now pretend that we do not receive any good frames anymore */ + for (i = 0; i < 20; i++) { - rc = osmo_ecu_fr_conceal(&state, frame); - OSMO_ASSERT(rc == 0); - parse_xmaxc_frame(frame, xmaxc); + rc = osmo_ecu_fr_conceal(&state, frame); + OSMO_ASSERT(rc == 0); + parse_xmaxc_frame(frame, xmaxc); + + printf("conceal: %02i, result: %s XMAXC: [%"PRIx64", %"PRIx64", %"PRIx64", %"PRIx64"]\n", + i, osmo_hexdump_nospc(frame, GSM_FR_BYTES), + xmaxc[0], xmaxc[1], xmaxc[2], xmaxc[3]); + } - printf("conceal: %02i, result: %s XMAXC: [%"PRIx64", %"PRIx64", %"PRIx64", %"PRIx64"]\n", - i, osmo_hexdump_nospc(frame, GSM_FR_BYTES), - xmaxc[0], xmaxc[1], xmaxc[2], xmaxc[3]); + /* Go to the next frame */ + j++; } } -- cgit v1.2.3