Harald Welte has submitted this change and it was merged.

Change subject: test_gsm0808_enc_dec_cell_id_list_lac(): validate encoded bytes
......................................................................


test_gsm0808_enc_dec_cell_id_list_lac(): validate encoded bytes

Change-Id: I81b1ffbe6a5ec566c112492c2cbaf99c018c45bb
---
M tests/gsm0808/gsm0808_test.c
M tests/gsm0808/gsm0808_test.ok
2 files changed, 9 insertions(+), 8 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/tests/gsm0808/gsm0808_test.c b/tests/gsm0808/gsm0808_test.c
index 8c184dd..41d85a8 100644
--- a/tests/gsm0808/gsm0808_test.c
+++ b/tests/gsm0808/gsm0808_test.c
@@ -750,6 +750,13 @@
        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 @@
 
        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);
@@ -1255,13 +1262,6 @@
 
        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()
 {
diff --git a/tests/gsm0808/gsm0808_test.ok b/tests/gsm0808/gsm0808_test.ok
index 27170f2..0ec6d23 100644
--- a/tests/gsm0808/gsm0808_test.ok
+++ b/tests/gsm0808/gsm0808_test.ok
@@ -19,6 +19,7 @@
 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] = {
      }

-- 
To view, visit https://gerrit.osmocom.org/7790
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I81b1ffbe6a5ec566c112492c2cbaf99c018c45bb
Gerrit-PatchSet: 3
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofm...@sysmocom.de>
Gerrit-Reviewer: Harald Welte <lafo...@gnumonks.org>
Gerrit-Reviewer: Jenkins Builder

Reply via email to