diff options
author | Max <msuraev@sysmocom.de> | 2019-03-05 11:30:39 +0100 |
---|---|---|
committer | Max <msuraev@sysmocom.de> | 2019-03-05 11:30:39 +0100 |
commit | a47859025010de21faf9b48d929aec1f080f844d (patch) | |
tree | 4b7056783bbbdebc440cf2fd6c00133b13bff965 /tests/coding | |
parent | 6d57c5727699888f96a49f0a989a4563cede3cae (diff) |
coding: check gsm0503_rach_*() results
Check return value of RACH encode/decode functions and fail test on
unexpected results.
Change-Id: I41bfa808e3c064a11152e7ce8ee77a01d38a0744
Related: OS#1854
Diffstat (limited to 'tests/coding')
-rw-r--r-- | tests/coding/coding_test.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/tests/coding/coding_test.c b/tests/coding/coding_test.c index 7b4f2a56..2b0830f2 100644 --- a/tests/coding/coding_test.c +++ b/tests/coding/coding_test.c @@ -104,13 +104,14 @@ static void test_xcch(uint8_t *l2) static void test_rach(uint8_t bsic, uint8_t ra) { + int rc; uint8_t result; ubit_t bursts_u[36]; sbit_t bursts_s[36]; /* Encode L2 message */ - printf("Encoding: %02x\n", ra); - gsm0503_rach_ext_encode(bursts_u, ra, bsic, false); + rc = gsm0503_rach_ext_encode(bursts_u, ra, bsic, false); + printf("Encoding: %02x%s\n", ra, (rc != 0) ? " FAIL" : ""); /* Prepare soft-bits */ osmo_ubit2sbit(bursts_s, bursts_u, 36); @@ -123,8 +124,8 @@ static void test_rach(uint8_t bsic, uint8_t ra) memset(bursts_s + 6, 0, 8); /* Decode, correcting errors */ - gsm0503_rach_decode_ber(&result, bursts_s, bsic, NULL, NULL); - printf("Decoded: %02x\n", result); + rc = gsm0503_rach_decode_ber(&result, bursts_s, bsic, NULL, NULL); + printf("Decoded: %02x%s\n", result, (rc != 0) ? " FAIL" : ""); if (ra != result) printf("FAIL [RACH]: encoded %u != %u decoded\n", ra, result); @@ -134,13 +135,14 @@ static void test_rach(uint8_t bsic, uint8_t ra) static void test_rach_ext(uint8_t bsic, uint16_t ra) { + int rc; uint16_t result = 3000; /* Max ext. RA is 2^11 = 2048 */ ubit_t bursts_u[36]; sbit_t bursts_s[36]; /* Encode L2 message */ - printf("Encoding: %02x\n", ra); - gsm0503_rach_ext_encode(bursts_u, ra, bsic, true); + rc = gsm0503_rach_ext_encode(bursts_u, ra, bsic, true); + printf("Encoding: %02x%s\n", ra, (rc != 0) ? " FAIL" : ""); /* Prepare soft-bits */ osmo_ubit2sbit(bursts_s, bursts_u, 36); @@ -153,8 +155,8 @@ static void test_rach_ext(uint8_t bsic, uint16_t ra) memset(bursts_s + 9, 0, 8); /* Decode, correcting errors */ - gsm0503_rach_ext_decode_ber(&result, bursts_s, bsic, NULL, NULL); - printf("Decoded: %02x\n", result); + rc = gsm0503_rach_ext_decode_ber(&result, bursts_s, bsic, NULL, NULL); + printf("Decoded: %02x%s\n", result, (rc != 0) ? " FAIL" : ""); if (ra != result) printf("FAIL [RACH ext]: encoded %u != %u decoded\n", ra, result); |