aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bitcomp/BitcompTest.cpp
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-03-26 23:21:16 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-03-27 00:24:28 +0200
commitdd1700a397379e9383b9577fca09738b3251fc7c (patch)
tree9f2ea78e9bbc63d456576604f87573422f1defc3 /tests/bitcomp/BitcompTest.cpp
parent7783964bb92af9ef6a1d1d12a6b804aab48945b0 (diff)
bitcomp test: fix: only one hexdump per log; use printf
The test wants to write multiline results, so it should use printf instead of the logging system. Split logs to only one hexdump per printf(). One cannot use osmo_hexdump twice in one printf(); before this, one of the two hexdumps won, both dumps would show as the same. Very bad for a regression test! This uncovers a discrepancy between expected and produced results, proving that the expected stderr output was not capable of uncovering test failures. The test's check_result() function *has* always verified the decoded data, but only up to the last decoded bit. Our expected data contains seemingly random bits after the end of the decoded bits, but check_result() never compares those, hence we don't catch that error. The extra bits should definitely be zero, because the destination buffer is pre-initialized to zero -- fixed in a subsequent patch. This should cosmetically fix the build failure 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 The real fix will follow. Change-Id: I24fc32eb55baaf22f9c6fdda917bfb8395d02b1c
Diffstat (limited to 'tests/bitcomp/BitcompTest.cpp')
-rw-r--r--tests/bitcomp/BitcompTest.cpp30
1 files changed, 14 insertions, 16 deletions
diff --git a/tests/bitcomp/BitcompTest.cpp b/tests/bitcomp/BitcompTest.cpp
index 31aebd48..f35d6bec 100644
--- a/tests/bitcomp/BitcompTest.cpp
+++ b/tests/bitcomp/BitcompTest.cpp
@@ -18,6 +18,8 @@ extern "C" {
#define MAX_CRBB_LEN 23
#define MAX_URBB_LEN 40
#define CEIL_DIV_8(x) (((x) + 7)/8)
+#define _LOG(fmt, args...) \
+ fprintf(stderr, fmt, ## args)
void *tall_pcu_ctx;
@@ -157,8 +159,7 @@ static void test_EPDAN_decode_tree(void)
dest.data = bits_data;
dest.data_len = sizeof(bits_data);
dest.cur_bit = 0;
- LOGP(DRLCMACDL, LOGL_DEBUG,
- "\nTest:%d\n"
+ _LOG("\nTest:%d\n"
"Tree based decoding:\n"
"uncompressed data = %s\n"
"len = %d\n",
@@ -169,8 +170,7 @@ static void test_EPDAN_decode_tree(void)
rc = egprs_compress::decompress_crbb(test[itr].crbb_len,
test[itr].cc, test[itr].crbb_data, &dest);
if (rc < 0) {
- LOGP(DRLCMACUL, LOGL_NOTICE,
- "\nFailed to decode CRBB: length %d, data %s",
+ _LOG("\nFailed to decode CRBB: length %d, data %s",
test[itr].crbb_len,
osmo_hexdump(test[itr].crbb_data,
CEIL_DIV_8(test[itr].crbb_len)));
@@ -178,29 +178,27 @@ static void test_EPDAN_decode_tree(void)
if (test[itr].verify) {
if (!result_matches(dest, test[itr].ucmp_data,
test[itr].ucmp_len)) {
- LOGP(DRLCMACDL, LOGL_DEBUG,
- "\nTree based decoding: Error\n"
+ _LOG("\nTree based decoding: Error\n"
"expected data = %s\n"
- "expected len = %d\n"
- "decoded data = %s\n"
- "decoded len = %d\n",
+ "expected len = %d\n",
osmo_hexdump(test[itr].ucmp_data,
CEIL_DIV_8(test[itr].ucmp_len)),
- 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);
}
}
- LOGP(DRLCMACDL, LOGL_DEBUG,
- "\nexpected data = %s\n"
- "expected len = %d\n"
- "decoded data = %s\n"
- "decoded len = %d\n",
+ _LOG("\nexpected data = %s\n"
+ "expected len = %d\n",
osmo_hexdump(test[itr].ucmp_data,
CEIL_DIV_8(test[itr].ucmp_len)),
- 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);
}