Change in libosmocore[master]: coding: check gsm0503_rach_*() results

Max gerrit-no-reply at lists.osmocom.org
Tue Mar 5 10:32:39 UTC 2019


Max has uploaded this change for review. ( https://gerrit.osmocom.org/13129


Change subject: coding: check gsm0503_rach_*() results
......................................................................

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
---
M tests/coding/coding_test.c
1 file changed, 10 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/29/13129/1

diff --git a/tests/coding/coding_test.c b/tests/coding/coding_test.c
index 7b4f2a5..2b0830f 100644
--- a/tests/coding/coding_test.c
+++ b/tests/coding/coding_test.c
@@ -104,13 +104,14 @@
 
 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 @@
 	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_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 @@
 	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);

-- 
To view, visit https://gerrit.osmocom.org/13129
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I41bfa808e3c064a11152e7ce8ee77a01d38a0744
Gerrit-Change-Number: 13129
Gerrit-PatchSet: 1
Gerrit-Owner: Max <msuraev at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190305/2a2d3a16/attachment.html>


More information about the gerrit-log mailing list