path: root/tests/bitvec/bitvec_test.c
diff options
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2016-01-30 16:16:28 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2016-01-30 16:19:33 +0100
commit5710804a42b72504c012b75222b663cdf46de4f5 (patch)
tree4439a38329aaef9c6b401b420c71a749038edff6 /tests/bitvec/bitvec_test.c
parenta9301a1a1f2ac0c73aff2075c2361d54a6fc8675 (diff)
bivec: Fix the output of the testcase
osmo_hexdump_nospc/osmo_hexdump is an old school C routine with a static internal array. This means that printf will most likely one of the two strings twice. For Linux/glibc this is the first string (for whatever reason?) and for FreeBSD it is the last call of the osmo_hexdump_nospc. We could have noticed by both strings being of the same length besides the different length input. The second issue is that we cast a hexstring to uint8_t and dump the string as hex. So the two strings should not match at all. Fix it by printing the hex string as plain hex and separating the two printf calls. Update the test output.
Diffstat (limited to 'tests/bitvec/bitvec_test.c')
1 files changed, 6 insertions, 2 deletions
diff --git a/tests/bitvec/bitvec_test.c b/tests/bitvec/bitvec_test.c
index 789df75a..7d131e03 100644
--- a/tests/bitvec/bitvec_test.c
+++ b/tests/bitvec/bitvec_test.c
@@ -57,13 +57,17 @@ static void test_byte_ops()
static void test_unhex(const char *hex)
+ int rc;
struct bitvec b;
uint8_t d[64] = {0};
b.data = d;
b.data_len = sizeof(d);
b.cur_bit = 0;
- printf("%d -=>\n", bitvec_unhex(&b, hex));
- printf("%s\n%s\n", osmo_hexdump_nospc(d, 64), osmo_hexdump_nospc((const unsigned char *)hex, 23));
+ rc = bitvec_unhex(&b, hex);
+ printf("%d -=> cur_bit=%u\n", rc, b.cur_bit);
+ printf("%s\n", osmo_hexdump_nospc(d, 64));
+ printf("%s\n", hex);
int main(int argc, char **argv)