[PATCH] osmo-pcu[master]: bitcomp test: fix: also verify bits after decoded data

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/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Sun Mar 26 22:25:08 UTC 2017


Review at  https://gerrit.osmocom.org/2169

bitcomp test: fix: also verify bits after decoded data

Before this, the expected data had seemingly random bits set after the end of
the expected decoding result. Make the test expect these extra bits as zero,
matching with the buffer initialization to zero.

In result_matches(), compare the full length of bytes instead of masking the
bits after the end of the decoded data (which caused us to not catch the wrong
expectation until now).

This fixes the underlying issues found in
http://lists.osmocom.org/pipermail/osmocom-net-gprs/2017-March/000876.html
  [osmo-pcu 0.2.896-0a8f] testsuite: 4 failed
  from: Arnaud ZANETTI
  on: Fri Mar 24 09:53:53 UTC 2017

Change-Id: I2501208e2f8b4f709efbcadbd1057c086472c9e6
---
M tests/bitcomp/BitcompTest.cpp
M tests/bitcomp/BitcompTest.err
2 files changed, 5 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/69/2169/1

diff --git a/tests/bitcomp/BitcompTest.cpp b/tests/bitcomp/BitcompTest.cpp
index f35d6be..c5fde2e 100644
--- a/tests/bitcomp/BitcompTest.cpp
+++ b/tests/bitcomp/BitcompTest.cpp
@@ -38,7 +38,7 @@
 			.ucmp_data = {
 			0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x01, 0xff, 0xff,
 			0xff, 0xf8, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xfe,
-			0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xdb
+			0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xc0
 			},
 			.ucmp_len = 194, .verify = 1
 		},
@@ -49,7 +49,7 @@
 			.ucmp_data = {
 			0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00,
 			0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8,
-			0x00, 0x00, 0x00, 0x00, 0x03
+			0x00, 0x00, 0x00, 0x00, 0x00
 			},
 			.ucmp_len = 182, .verify = 1
 		},
@@ -127,18 +127,7 @@
 {
 	if (bits.cur_bit != exp_len)
 		return false;
-	size_t n = (exp_len / 8);
-	int rem = (exp_len % 8);
-
-	if (memcmp(exp_data, bits.data, n) == 0) {
-		if (rem == 0)
-			return true;
-		if ((bits.data[n] & MASK(rem)) == ((*(exp_data + n)) & MASK(rem)))
-			return true;
-		else
-			return false;
-	} else
-		return false;
+	return (memcmp(exp_data, bits.data, CEIL_DIV_8(exp_len)) == 0);
 }
 
 /*  To test decoding of compressed bitmap by Tree based method
diff --git a/tests/bitcomp/BitcompTest.err b/tests/bitcomp/BitcompTest.err
index f769daa..1d6fb00 100644
--- a/tests/bitcomp/BitcompTest.err
+++ b/tests/bitcomp/BitcompTest.err
@@ -11,7 +11,7 @@
 Run_length = 19
 Run_length = 32
 
-expected data = ff ff ff f8 00 00 01 ff ff ff f8 00 00 00 ff ff ff fe 00 00 3f ff ff ff db 
+expected data = ff ff ff f8 00 00 01 ff ff ff f8 00 00 00 ff ff ff fe 00 00 3f ff ff ff c0 
 expected len = 194
 decoded data = ff ff ff f8 00 00 01 ff ff ff f8 00 00 00 ff ff ff fe 00 00 3f ff ff ff c0 
 decoded len = 194
@@ -25,7 +25,7 @@
 Run_length = 51
 Run_length = 41
 
-expected data = ff ff ff ff ff ff c0 00 00 00 00 3f ff ff ff ff ff f8 00 00 00 00 03 
+expected data = ff ff ff ff ff ff c0 00 00 00 00 3f ff ff ff ff ff f8 00 00 00 00 00 
 expected len = 182
 decoded data = ff ff ff ff ff ff c0 00 00 00 00 3f ff ff ff ff ff f8 00 00 00 00 00 
 decoded len = 182

-- 
To view, visit https://gerrit.osmocom.org/2169
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2501208e2f8b4f709efbcadbd1057c086472c9e6
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list