aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-04-13 04:10:58 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2018-04-13 05:38:48 +0200
commit066473fe3635ad98ebc17d0bc2a320712e0b6cdd (patch)
tree5b55c5b07ef26c25e11a0335f9a61a93566ff7fb
parent250e7f7d30c5d90e39293f67bf7553d2d3d094f6 (diff)
test_gsm0808_enc_dec_cell_id_list_lac(): validate encoded bytes
-rw-r--r--tests/gsm0808/gsm0808_test.c16
-rw-r--r--tests/gsm0808/gsm0808_test.ok1
2 files changed, 9 insertions, 8 deletions
diff --git a/tests/gsm0808/gsm0808_test.c b/tests/gsm0808/gsm0808_test.c
index 8c184dda..41d85a86 100644
--- a/tests/gsm0808/gsm0808_test.c
+++ b/tests/gsm0808/gsm0808_test.c
@@ -750,6 +750,13 @@ static void test_gsm0808_enc_dec_encrypt_info()
msgb_free(msg);
}
+#define EXPECT_ENCODED(hexstr) do { \
+ const char *enc_str = msgb_hexdump(msg); \
+ printf("%s: encoded: %s(rc = %u)\n", __func__, enc_str, rc_enc); \
+ OSMO_ASSERT(strcmp(enc_str, hexstr " ") == 0); \
+ OSMO_ASSERT(rc_enc == msg->len); \
+ } while(0)
+
static void test_gsm0808_enc_dec_cell_id_list_lac()
{
struct gsm0808_cell_id_list2 enc_cil;
@@ -767,7 +774,7 @@ static void test_gsm0808_enc_dec_cell_id_list_lac()
msg = msgb_alloc(1024, "output buffer");
rc_enc = gsm0808_enc_cell_id_list2(msg, &enc_cil);
- OSMO_ASSERT(rc_enc == 9);
+ EXPECT_ENCODED("1a 07 05 56 78 00 00 00 00");
rc_dec = gsm0808_dec_cell_id_list2(&dec_cil, msg->data + 2, msg->len - 2);
OSMO_ASSERT(rc_dec == 7);
@@ -1256,13 +1263,6 @@ void test_cell_id_list_add() {
printf("------- %s done\n", __func__);
}
-#define EXPECT_ENCODED(hexstr) do { \
- const char *enc_str = msgb_hexdump(msg); \
- printf("%s: encoded: %s(rc = %u)\n", __func__, enc_str, rc_enc); \
- OSMO_ASSERT(strcmp(enc_str, hexstr " ") == 0); \
- OSMO_ASSERT(rc_enc == msg->len); \
- } while(0)
-
static void test_gsm0808_enc_dec_cell_id_lac()
{
struct gsm0808_cell_id enc_ci = {
diff --git a/tests/gsm0808/gsm0808_test.ok b/tests/gsm0808/gsm0808_test.ok
index 27170f27..0ec6d23f 100644
--- a/tests/gsm0808/gsm0808_test.ok
+++ b/tests/gsm0808/gsm0808_test.ok
@@ -19,6 +19,7 @@ Testing creating Clear Request
Testing creating Paging Request
Testing creating DTAP
Testing prepend DTAP
+test_gsm0808_enc_dec_cell_id_list_lac: encoded: 1a 07 05 56 78 00 00 00 00 (rc = 9)
------- test_cell_id_list_add
cell_id_list cgi[0] = {
}