Change in libosmocore[master]: tests/coding_test: Fix test_pdtch() results

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Thu Apr 9 14:24:17 UTC 2020


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/17763 )


Change subject: tests/coding_test: Fix test_pdtch() results
......................................................................

tests/coding_test: Fix test_pdtch() results

When switching the l2 structures passes to test_pdtch() to be constant,
it was noted that output of the test changes. This happens because same
array is tested several times with different length, incrementing each
time. Since the test was modifying the input array directly, it means
each new run of test_pdtch() the array was further modified.
Upon constifying the structures, we copy the array and hence only modify
the required bits each time.

Change-Id: Iffd0ca3669eb8d0d2e80d754fc8acbf72f1bebe8
---
M tests/coding/coding_test.c
M tests/coding/coding_test.ok
2 files changed, 30 insertions(+), 29 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/63/17763/1

diff --git a/tests/coding/coding_test.c b/tests/coding/coding_test.c
index 417c594..bdfe300 100644
--- a/tests/coding/coding_test.c
+++ b/tests/coding/coding_test.c
@@ -323,7 +323,7 @@
 	uint8_t l2[54];
 };
 
-static struct test_macblock test_macblock[] = {
+static const struct test_macblock test_macblock[] = {
 	/* Random frame */
 	{	false,
 		GSM0503_GPRS_BURSTS_NBITS,
@@ -385,33 +385,34 @@
 	},
 };
 
-static void test_pdtch(struct test_macblock *tmb, int len)
+static void test_pdtch(const struct test_macblock *tmb, int len)
 {
-	uint8_t result[len];
+	uint8_t l2[len], result[len];
 	ubit_t bursts_u[116 * 4];
 	sbit_t bursts_s[116 * 4];
 	int n_errors, n_bits_total;
 	int rc;
 
 	/* Zero the not coded tail bits */
+	memcpy(l2, tmb->l2, len);
 	switch (len) {
 	case 34:
 	case 54:
-		tmb->l2[len - 1] &= 0x7f;
+		l2[len - 1] &= 0x7f;
 		result[len - 1] &= 0x7f;
 		break;
 	case 40:
-		tmb->l2[len - 1] &= 0x07;
+		l2[len - 1] &= 0x07;
 		result[len - 1] &= 0x07;
 		break;
 	}
 
 	/* Encode L2 message */
-	printf("Encoding: %s\n", osmo_hexdump(tmb->l2, len));
+	printf("Encoding: %s\n", osmo_hexdump(l2, len));
 	if (tmb->is_egprs)
-		rc = gsm0503_pdtch_egprs_encode(bursts_u, tmb->l2, len);
+		rc = gsm0503_pdtch_egprs_encode(bursts_u, l2, len);
 	else
-		rc = gsm0503_pdtch_encode(bursts_u, tmb->l2, len);
+		rc = gsm0503_pdtch_encode(bursts_u, l2, len);
 	CHECK_RC_OR_RET(rc == (int)tmb->exp_burst_bits, "encoding");
 
 	/* Prepare soft-bits */
@@ -435,7 +436,7 @@
 	printf("pdtch_decode: n_errors=%d n_bits_total=%d ber=%.2f\n",
 		n_errors, n_bits_total, (float)n_errors/n_bits_total);
 
-	OSMO_ASSERT(!memcmp(tmb->l2, result, len));
+	OSMO_ASSERT(!memcmp(l2, result, len));
 
 	printf("\n");
 }
diff --git a/tests/coding/coding_test.ok b/tests/coding/coding_test.ok
index 91083e4..cb562e9 100644
--- a/tests/coding/coding_test.ok
+++ b/tests/coding/coding_test.ok
@@ -272,32 +272,32 @@
 Decoded: a3 af 5f c6 36 43 44 ab d9 6d 7d 62 24 c9 d2 92 fa 27 5d 71 7a 59 a8 42 a3 af 5f c6 36 43 44 ab a3 2f 
 pdtch_decode: n_errors=132 n_bits_total=588 ber=0.22
 
-Encoding: a3 af 5f c6 36 43 44 ab d9 6d 7d 62 24 c9 d2 92 fa 27 5d 71 7a 59 a8 42 a3 af 5f c6 36 43 44 ab a3 2f 5f c6 36 43 44 03 
+Encoding: a3 af 5f c6 36 43 44 ab d9 6d 7d 62 24 c9 d2 92 fa 27 5d 71 7a 59 a8 42 a3 af 5f c6 36 43 44 ab a3 af 5f c6 36 43 44 03 
 U-Bits:
-100010111000001100000000001101001000000000101100111011001 00  00  101110010011001000110010000011100101000011110001101100001
-001011110100100101010101111111110011111011111110001101001 01  00  011010010110101000111110001100110011101101111000100101110
-110001101010001000010101011111101011000111010110110011110 00  00  101001101100011001101100110110000101000001000001011000110
-011100001010000100100101001000110110100111000000101110000 00  01  111100110000011001001100110100111101011010011110100010011
+100010111000001100000000001101001000000000101100111011001 00  00  101110011011001000110000000011100101000011110001101100001
+001011110100100101010101111111110011111011111110011101001 01  00  011010110110101000110110001100110011101101111000100101100
+110001100000001000010101011111101011000111010111110011110 00  00  100001101100011001101100110110000101000001000001011001110
+011100001010000100100101001000100110100111010000101110000 00  01  111100110000011001001101110100111101001010011110100110011
 S-Bits:
-81 7f 7f 7f 81 7f 81 81 81 7f 7f 7f 7f 7f 81 81 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 81 81 7f 81 7f 7f 81 7f 7f 7f 7f 7f 7f 7f 7f 7f 81 7f 81 81 7f 7f 81 81 81 7f 81 81 7f 7f 81  7f  7f  81 7f 81 81 81 7f 7f 81 7f 7f 81 81 7f 7f 81 7f 7f 7f 81 81 7f 7f 81 7f 7f 7f 7f 7f 81 81 81 7f 7f 81 7f 81 7f 7f 7f 7f 81 81 81 81 7f 7f 7f 81 81 7f 81 81 7f 7f 7f 7f 81 
-7f 7f 81 7f 81 81 81 81 7f 81 7f 7f 81 7f 7f 81 7f 81 7f 81 7f 81 7f 81 81 81 81 81 81 81 81 81 7f 7f 81 81 81 81 81 7f 81 81 81 81 81 81 81 7f 7f 7f 81 81 7f 81 7f 7f 81  81  7f  7f 81 81 7f 81 7f 7f 81 7f 81 81 7f 81 7f 81 7f 7f 7f 81 81 81 81 81 7f 7f 7f 81 81 7f 7f 81 81 7f 7f 81 81 81 7f 81 81 7f 81 81 81 81 7f 7f 7f 81 7f 7f 81 7f 81 81 81 7f 
-81 81 7f 7f 7f 81 81 7f 81 7f 81 7f 7f 7f 81 7f 7f 7f 7f 81 7f 81 7f 81 7f 81 81 81 81 81 81 7f 81 7f 81 81 7f 7f 7f 81 81 81 7f 81 7f 81 81 7f 81 81 7f 7f 81 81 81 81 7f  7f  7f  81 7f 81 7f 7f 81 81 7f 81 81 7f 7f 7f 81 81 7f 7f 81 81 7f 81 81 7f 7f 81 81 7f 81 81 7f 7f 7f 7f 81 7f 81 7f 7f 7f 7f 7f 81 7f 7f 7f 7f 7f 81 7f 81 81 7f 7f 7f 81 81 7f 
-7f 81 81 81 7f 7f 7f 7f 81 7f 81 7f 7f 7f 7f 81 7f 7f 81 7f 7f 81 7f 81 7f 7f 81 7f 7f 7f 81 81 7f 81 81 7f 81 7f 7f 81 81 81 7f 7f 7f 7f 7f 7f 81 7f 81 81 81 7f 7f 7f 7f  7f  81  81 81 81 81 7f 7f 81 81 7f 7f 7f 7f 7f 81 81 7f 7f 81 7f 7f 81 81 7f 7f 81 81 7f 81 7f 7f 81 81 81 81 7f 81 7f 81 81 7f 81 7f 7f 81 81 81 81 7f 81 7f 7f 7f 81 7f 7f 81 81 
-Decoded: a3 af 5f c6 36 43 44 ab d9 6d 7d 62 24 c9 d2 92 fa 27 5d 71 7a 59 a8 42 a3 af 5f c6 36 43 44 ab a3 2f 5f c6 36 43 44 03 
+81 7f 7f 7f 81 7f 81 81 81 7f 7f 7f 7f 7f 81 81 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 81 81 7f 81 7f 7f 81 7f 7f 7f 7f 7f 7f 7f 7f 7f 81 7f 81 81 7f 7f 81 81 81 7f 81 81 7f 7f 81  7f  7f  81 7f 81 81 81 7f 7f 81 81 7f 81 81 7f 7f 81 7f 7f 7f 81 81 7f 7f 7f 7f 7f 7f 7f 7f 81 81 81 7f 7f 81 7f 81 7f 7f 7f 7f 81 81 81 81 7f 7f 7f 81 81 7f 81 81 7f 7f 7f 7f 81 
+7f 7f 81 7f 81 81 81 81 7f 81 7f 7f 81 7f 7f 81 7f 81 7f 81 7f 81 7f 81 81 81 81 81 81 81 81 81 7f 7f 81 81 81 81 81 7f 81 81 81 81 81 81 81 7f 7f 81 81 81 7f 81 7f 7f 81  81  7f  7f 81 81 7f 81 7f 81 81 7f 81 81 7f 81 7f 81 7f 7f 7f 81 81 7f 81 81 7f 7f 7f 81 81 7f 7f 81 81 7f 7f 81 81 81 7f 81 81 7f 81 81 81 81 7f 7f 7f 81 7f 7f 81 7f 81 81 7f 7f 
+81 81 7f 7f 7f 81 81 7f 7f 7f 7f 7f 7f 7f 81 7f 7f 7f 7f 81 7f 81 7f 81 7f 81 81 81 81 81 81 7f 81 7f 81 81 7f 7f 7f 81 81 81 7f 81 7f 81 81 81 81 81 7f 7f 81 81 81 81 7f  7f  7f  81 7f 7f 7f 7f 81 81 7f 81 81 7f 7f 7f 81 81 7f 7f 81 81 7f 81 81 7f 7f 81 81 7f 81 81 7f 7f 7f 7f 81 7f 81 7f 7f 7f 7f 7f 81 7f 7f 7f 7f 7f 81 7f 81 81 7f 7f 81 81 81 7f 
+7f 81 81 81 7f 7f 7f 7f 81 7f 81 7f 7f 7f 7f 81 7f 7f 81 7f 7f 81 7f 81 7f 7f 81 7f 7f 7f 81 7f 7f 81 81 7f 81 7f 7f 81 81 81 7f 81 7f 7f 7f 7f 81 7f 81 81 81 7f 7f 7f 7f  7f  81  81 81 81 81 7f 7f 81 81 7f 7f 7f 7f 7f 81 81 7f 7f 81 7f 7f 81 81 7f 81 81 81 7f 81 7f 7f 81 81 81 81 7f 81 7f 7f 81 7f 81 7f 7f 81 81 81 81 7f 81 7f 7f 81 81 7f 7f 81 81 
+Decoded: a3 af 5f c6 36 43 44 ab d9 6d 7d 62 24 c9 d2 92 fa 27 5d 71 7a 59 a8 42 a3 af 5f c6 36 43 44 ab a3 af 5f c6 36 43 44 03 
 pdtch_decode: n_errors=220 n_bits_total=676 ber=0.33
 
-Encoding: a3 af 5f c6 36 43 44 ab d9 6d 7d 62 24 c9 d2 92 fa 27 5d 71 7a 59 a8 42 a3 af 5f c6 36 43 44 ab a3 2f 5f c6 36 43 44 03 d9 6d 7d 62 24 c9 d2 92 fa 27 5d 71 7a 28 
+Encoding: a3 af 5f c6 36 43 44 ab d9 6d 7d 62 24 c9 d2 92 fa 27 5d 71 7a 59 a8 42 a3 af 5f c6 36 43 44 ab a3 af 5f c6 36 43 44 ab d9 6d 7d 62 24 c9 d2 92 fa 27 5d 71 7a 28 
 U-Bits:
-100010100101111101110101011001010100000101001001011011000 00  00  001000000000001100000110001011010111110101110101001100010
-010101000000101010101011110000010101000100000011010001101 00  01  010111110101110101010111011111100111010011010000111110111
-010111100101110011111100101110001010100110000010100000100 00  01  010111101110101111110011110101111101110100011000101111111
-011110100110000011110100111111101111111111111010101110000 01  00  001010101010101010101010111010110110000000100000101001011
+100010100101111101110101011001010100000101001001011011000 00  00  001010001000001100000111001011010111110101110101001101010
+010101000000001010101011110000010101000100000011010001101 00  01  010111010101110101010111011111100111010011010000111110111
+010111100101110011111100101111001010100110000011100000100 00  01  010111101110101111110011110101111101110100011000101111111
+011110100110000010110100111111111111111111111010101110000 01  00  001010101010101010101011111010110110010000100000101001011
 S-Bits:
-81 7f 7f 7f 81 7f 81 7f 7f 81 7f 81 81 81 81 81 7f 81 81 81 7f 81 7f 81 7f 81 81 7f 7f 81 7f 81 7f 81 7f 7f 7f 7f 7f 81 7f 81 7f 7f 81 7f 7f 81 7f 81 81 7f 81 81 7f 7f 7f  7f  7f  7f 7f 81 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 81 81 7f 7f 7f 7f 7f 81 81 7f 7f 7f 81 7f 81 81 7f 81 7f 81 81 81 81 81 7f 81 7f 81 81 81 7f 81 7f 81 7f 7f 81 81 7f 7f 7f 81 7f 
-7f 81 7f 81 7f 81 7f 7f 7f 7f 7f 7f 81 7f 81 7f 81 7f 81 7f 81 7f 81 81 81 81 7f 7f 7f 7f 7f 81 7f 81 7f 81 7f 7f 7f 81 7f 7f 7f 7f 7f 7f 81 81 7f 81 7f 7f 7f 81 81 7f 81  7f  81  7f 81 7f 81 81 81 81 81 7f 81 7f 81 81 81 7f 81 7f 81 7f 81 7f 81 81 81 7f 81 81 81 81 81 81 7f 7f 81 81 81 7f 81 7f 7f 81 81 7f 81 7f 7f 7f 7f 81 81 81 81 81 7f 81 81 81 
-7f 81 7f 81 81 81 81 7f 7f 81 7f 81 81 81 7f 7f 81 81 81 81 81 81 7f 7f 81 7f 81 81 81 7f 7f 7f 81 7f 81 7f 81 7f 7f 81 81 7f 7f 7f 7f 7f 81 7f 81 7f 7f 7f 7f 7f 81 7f 7f  7f  81  7f 81 7f 81 81 81 81 7f 81 81 81 7f 81 7f 81 81 81 81 81 81 7f 7f 81 81 81 81 7f 81 7f 81 81 81 81 81 7f 81 81 81 7f 81 7f 7f 7f 81 81 7f 7f 7f 81 7f 81 81 81 81 81 81 81 
-7f 81 81 81 81 7f 81 7f 7f 81 81 7f 7f 7f 7f 7f 81 81 81 81 7f 81 7f 7f 81 81 81 81 81 81 81 7f 81 81 81 81 81 81 81 81 81 81 81 81 81 7f 81 7f 81 7f 81 81 81 7f 7f 7f 7f  81  7f  7f 7f 81 7f 81 7f 81 7f 81 7f 81 7f 81 7f 81 7f 81 7f 81 7f 81 7f 81 7f 81 81 81 7f 81 7f 81 81 7f 81 81 7f 7f 7f 7f 7f 7f 7f 81 7f 7f 7f 7f 7f 81 7f 81 7f 7f 81 7f 81 81 
-Decoded: a3 af 5f c6 36 43 44 ab d9 6d 7d 62 24 c9 d2 92 fa 27 5d 71 7a 59 a8 42 a3 af 5f c6 36 43 44 ab a3 2f 5f c6 36 43 44 03 d9 6d 7d 62 24 c9 d2 92 fa 27 5d 71 7a 28 
+81 7f 7f 7f 81 7f 81 7f 7f 81 7f 81 81 81 81 81 7f 81 81 81 7f 81 7f 81 7f 81 81 7f 7f 81 7f 81 7f 81 7f 7f 7f 7f 7f 81 7f 81 7f 7f 81 7f 7f 81 7f 81 81 7f 81 81 7f 7f 7f  7f  7f  7f 7f 81 7f 81 7f 7f 7f 81 7f 7f 7f 7f 7f 81 81 7f 7f 7f 7f 7f 81 81 81 7f 7f 81 7f 81 81 7f 81 7f 81 81 81 81 81 7f 81 7f 81 81 81 7f 81 7f 81 7f 7f 81 81 7f 81 7f 81 7f 
+7f 81 7f 81 7f 81 7f 7f 7f 7f 7f 7f 7f 7f 81 7f 81 7f 81 7f 81 7f 81 81 81 81 7f 7f 7f 7f 7f 81 7f 81 7f 81 7f 7f 7f 81 7f 7f 7f 7f 7f 7f 81 81 7f 81 7f 7f 7f 81 81 7f 81  7f  81  7f 81 7f 81 81 81 7f 81 7f 81 7f 81 81 81 7f 81 7f 81 7f 81 7f 81 81 81 7f 81 81 81 81 81 81 7f 7f 81 81 81 7f 81 7f 7f 81 81 7f 81 7f 7f 7f 7f 81 81 81 81 81 7f 81 81 81 
+7f 81 7f 81 81 81 81 7f 7f 81 7f 81 81 81 7f 7f 81 81 81 81 81 81 7f 7f 81 7f 81 81 81 81 7f 7f 81 7f 81 7f 81 7f 7f 81 81 7f 7f 7f 7f 7f 81 81 81 7f 7f 7f 7f 7f 81 7f 7f  7f  81  7f 81 7f 81 81 81 81 7f 81 81 81 7f 81 7f 81 81 81 81 81 81 7f 7f 81 81 81 81 7f 81 7f 81 81 81 81 81 7f 81 81 81 7f 81 7f 7f 7f 81 81 7f 7f 7f 81 7f 81 81 81 81 81 81 81 
+7f 81 81 81 81 7f 81 7f 7f 81 81 7f 7f 7f 7f 7f 81 7f 81 81 7f 81 7f 7f 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 7f 81 7f 81 7f 81 81 81 7f 7f 7f 7f  81  7f  7f 7f 81 7f 81 7f 81 7f 81 7f 81 7f 81 7f 81 7f 81 7f 81 7f 81 7f 81 81 81 81 81 7f 81 7f 81 81 7f 81 81 7f 7f 81 7f 7f 7f 7f 81 7f 7f 7f 7f 7f 81 7f 81 7f 7f 81 7f 81 81 
+Decoded: a3 af 5f c6 36 43 44 ab d9 6d 7d 62 24 c9 d2 92 fa 27 5d 71 7a 59 a8 42 a3 af 5f c6 36 43 44 ab a3 af 5f c6 36 43 44 ab d9 6d 7d 62 24 c9 d2 92 fa 27 5d 71 7a 28 
 pdtch_decode: n_errors=0 n_bits_total=444 ber=0.00
 
 Encoding: 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Iffd0ca3669eb8d0d2e80d754fc8acbf72f1bebe8
Gerrit-Change-Number: 17763
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200409/9e08c88f/attachment.htm>


More information about the gerrit-log mailing list