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
This commit is contained in:
parent
dd1700a397
commit
5382e0fc1f
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue