aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-03-26 23:39:44 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-03-27 00:24:28 +0200
commit5382e0fc1f5c30532b5b2b322601c9d4a8d4f982 (patch)
tree3028f5ceac43e70fe3cd0c4910f9df6c05656c64
parentdd1700a397379e9383b9577fca09738b3251fc7c (diff)
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
-rw-r--r--tests/bitcomp/BitcompTest.cpp17
-rw-r--r--tests/bitcomp/BitcompTest.err4
2 files changed, 5 insertions, 16 deletions
diff --git a/tests/bitcomp/BitcompTest.cpp b/tests/bitcomp/BitcompTest.cpp
index f35d6bec..c5fde2ea 100644
--- a/tests/bitcomp/BitcompTest.cpp
+++ b/tests/bitcomp/BitcompTest.cpp
@@ -38,7 +38,7 @@ struct test_data {
.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 @@ struct test_data {
.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 @@ bool result_matches(const bitvec &bits, const uint8_t *exp_data, unsigned int ex
{
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 f769daa4..1d6fb002 100644
--- a/tests/bitcomp/BitcompTest.err
+++ b/tests/bitcomp/BitcompTest.err
@@ -11,7 +11,7 @@ Run_length = 31
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 = 40
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