path: root/tests/gsm23003
diff options
authorNeels Hofmeyr <neels@hofmeyr.de>2018-03-01 19:32:11 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2018-03-01 19:34:37 +0100
commit5b8b8c62b4958276983e942702020ae6d42f5327 (patch)
tree21d4e163d8668ac2fd3250d62f341ed6aa736f2f /tests/gsm23003
parentccfc387fb906f24e163e1a3a141a37a9e27acee2 (diff)
gsm23003_test: fix: compare members instead of bcmp
In certain builds (for me a build with no -O2 flag) the recently added gsm23003_test test_mnc_from_str() fails, because bcmp() compares all bytes of sizeof(struct test_mnc_from_str_result), which has valid data for 7 bytes plus one padding byte that may contain arbitrary values. Instead of bcmp(), rather compare the actual members one by one. Change-Id: I28b28457c7b0462c950612fd9b87b5c7181d8bad
Diffstat (limited to 'tests/gsm23003')
1 files changed, 3 insertions, 1 deletions
diff --git a/tests/gsm23003/gsm23003_test.c b/tests/gsm23003/gsm23003_test.c
index 4411e298..ea08d0d9 100644
--- a/tests/gsm23003/gsm23003_test.c
+++ b/tests/gsm23003/gsm23003_test.c
@@ -159,7 +159,9 @@ static bool test_mnc_from_str()
result.rc = osmo_mnc_from_str(t->mnc_str, &result.mnc,
- ok = !bcmp(&result, &t->expect, sizeof(result));
+ ok = (result.rc == t->expect.rc)
+ && (result.mnc == t->expect.mnc)
+ && (result.mnc_3_digits == t->expect.mnc_3_digits);
printf("%2d: \"%s\" rc=%d mnc=%u mnc_3_digits=%u %s\n",
i, osmo_escape_str(t->mnc_str, -1), result.rc, result.mnc, result.mnc_3_digits,
ok ? "pass" : "FAIL");