bitcomp test: use expected rc instead of 'verify' flag

The 'verify' flag is useless, we always want to verify everything.  Replace
'verify' with 'expect_rc', expecting a specific decoding result per test set.

When an error code was returned, cut short the loop and skip printing expected
vs. decoded bits.

This uncovers the fact that the first test marked as "invalid inputs" does not
seem to be invalid after all, or at least does not produce an error to be
returned. For now, only uncover this fact, the fix shall be submitted later.

Change-Id: Icf815a8f1acb0e275463408450171df046879847
This commit is contained in:
Neels Hofmeyr 2017-03-27 00:13:14 +02:00
parent 5382e0fc1f
commit e6d26ec09c
2 changed files with 51 additions and 41 deletions

View File

@ -29,7 +29,7 @@ struct test_data {
uint8_t crbb_data[MAX_CRBB_LEN]; /* compressed data */
uint8_t ucmp_data[MAX_URBB_LEN]; /* uncompressed data */
int ucmp_len;
int verify;
int expect_rc;
} test[] = {
{ .crbb_len = 67, .cc = 1,
.crbb_data = {
@ -40,7 +40,8 @@ struct test_data {
0xff, 0xf8, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xfe,
0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xc0
},
.ucmp_len = 194, .verify = 1
.ucmp_len = 194,
.expect_rc = 0,
},
{ .crbb_len = 40, .cc = 1,
.crbb_data = {
@ -51,12 +52,14 @@ struct test_data {
0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8,
0x00, 0x00, 0x00, 0x00, 0x00
},
.ucmp_len = 182, .verify = 1
.ucmp_len = 182,
.expect_rc = 0,
},
{ .crbb_len = 8, .cc = 1,
.crbb_data = {0x02},
.ucmp_data = {0xff, 0xff, 0xff, 0xf8},
.ucmp_len = 29, .verify = 1
.ucmp_len = 29,
.expect_rc = 0,
},
{ .crbb_len = 103, .cc = 1,
.crbb_data = {
@ -69,13 +72,15 @@ struct test_data {
0x0f, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x7f, 0xff,
0xff, 0xff, 0x80, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff
},
.ucmp_len = 288, .verify = 1
.ucmp_len = 288,
.expect_rc = 0,
},
/* Test vector from libosmocore test */
{ .crbb_len = 35, .cc = 0,
.crbb_data = {0xde, 0x88, 0x75, 0x65, 0x80},
.ucmp_data = {0x37, 0x47, 0x81, 0xf0},
.ucmp_len = 28, .verify = 1
.ucmp_len = 28,
.expect_rc = 0,
},
{ .crbb_len = 18, .cc = 1,
.crbb_data = {0xdd, 0x41, 0x00},
@ -83,23 +88,28 @@ struct test_data {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0x00, 0x00
},
.ucmp_len = 90, .verify = 1
.ucmp_len = 90,
.expect_rc = 0,
},
/*Invalid inputs*/
/* TODO: previously marked as "Invalid inputs" but succeeds */
{ .crbb_len = 18, .cc = 1,
.crbb_data = {0x1E, 0x70, 0xc0},
.ucmp_data = {0x0},
.ucmp_len = 0, .verify = 0
.ucmp_data = {0xb0, 0x00, 0x00},
.ucmp_len = 19,
.expect_rc = 0,
},
/* Invalid inputs */
{ .crbb_len = 14, .cc = 1,
.crbb_data = {0x00, 0x1E, 0x7c},
.ucmp_data = {0x0},
.ucmp_len = 0, .verify = 0
.ucmp_len = 0,
.expect_rc = -1,
},
{ .crbb_len = 24, .cc = 0,
.crbb_data = {0x00, 0x00, 0x00},
.ucmp_data = {0x0},
.ucmp_len = 0, .verify = 0
.ucmp_len = 0,
.expect_rc = -1,
}
};
@ -158,28 +168,29 @@ static void test_EPDAN_decode_tree(void)
test[itr].crbb_len);
rc = egprs_compress::decompress_crbb(test[itr].crbb_len,
test[itr].cc, test[itr].crbb_data, &dest);
_LOG("rc = %d\n", rc);
OSMO_ASSERT(test[itr].expect_rc == rc);
if (rc < 0) {
_LOG("\nFailed to decode CRBB: length %d, data %s",
_LOG("Failed to decode CRBB: length %d, data %s\n",
test[itr].crbb_len,
osmo_hexdump(test[itr].crbb_data,
CEIL_DIV_8(test[itr].crbb_len)));
continue;
}
if (test[itr].verify) {
if (!result_matches(dest, test[itr].ucmp_data,
test[itr].ucmp_len)) {
_LOG("\nTree based decoding: Error\n"
"expected data = %s\n"
"expected len = %d\n",
osmo_hexdump(test[itr].ucmp_data,
CEIL_DIV_8(test[itr].ucmp_len)),
test[itr].ucmp_len);
_LOG("decoded data = %s\n"
"decoded len = %d\n",
osmo_hexdump(dest.data,
CEIL_DIV_8(dest.cur_bit)),
dest.cur_bit);
OSMO_ASSERT(0);
}
if (!result_matches(dest, test[itr].ucmp_data,
test[itr].ucmp_len)) {
_LOG("\nTree based decoding: Error\n"
"expected data = %s\n"
"expected len = %d\n",
osmo_hexdump(test[itr].ucmp_data,
CEIL_DIV_8(test[itr].ucmp_len)),
test[itr].ucmp_len);
_LOG("decoded data = %s\n"
"decoded len = %d\n",
osmo_hexdump(dest.data,
CEIL_DIV_8(dest.cur_bit)),
dest.cur_bit);
OSMO_ASSERT(0);
}
_LOG("\nexpected data = %s\n"
"expected len = %d\n",

View File

@ -10,6 +10,7 @@ Run_length = 27
Run_length = 31
Run_length = 19
Run_length = 32
rc = 0
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
@ -24,6 +25,7 @@ Run_length = 50
Run_length = 40
Run_length = 51
Run_length = 41
rc = 0
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
@ -35,6 +37,7 @@ Tree based decoding:
uncompressed data = 02
len = 8
Run_length = 29
rc = 0
expected data = ff ff ff f8
expected len = 29
@ -56,6 +59,7 @@ Run_length = 22
Run_length = 32
Run_length = 22
Run_length = 33
rc = 0
expected data = ff ff ff f8 00 00 ff ff ff f8 00 00 7f ff ff fe 00 00 0f ff ff ff e0 00 00 7f ff ff ff 80 00 01 ff ff ff ff
expected len = 288
@ -76,6 +80,7 @@ Run_length = 3
Run_length = 4
Run_length = 6
Run_length = 5
rc = 0
expected data = 37 47 81 f0
expected len = 28
@ -89,6 +94,7 @@ len = 18
Run_length = 64
Run_length = 16
Run_length = 10
rc = 0
expected data = ff ff ff ff ff ff ff ff ff ff 00 00
expected len = 90
@ -103,9 +109,10 @@ Run_length = 1
Run_length = 1
Run_length = 2
Run_length = 15
rc = 0
expected data =
expected len = 0
expected data = b0 00 00
expected len = 19
decoded data = b0 00 00
decoded len = 19
@ -113,20 +120,12 @@ Test:8
Tree based decoding:
uncompressed data = 00 1e
len = 14
rc = -1
Failed to decode CRBB: length 14, data 00 1e
expected data =
expected len = 0
decoded data =
decoded len = 0
Test:9
Tree based decoding:
uncompressed data = 00 00 00
len = 24
rc = -1
Failed to decode CRBB: length 24, data 00 00 00
expected data =
expected len = 0
decoded data =
decoded len = 0