laforge submitted this change.
tests/smscb_cbsp: add more decode test cases
Some test cases are currently failing/passing unexpectedly.
This will be addressed in follow-up patches.
Change-Id: I70e40ac8cd8b6443fa4ef9246e45332c438a95b5
Related: OS#7097, OS#7098
---
M tests/smscb/cbsp_test.c
M tests/smscb/cbsp_test.ok
2 files changed, 88 insertions(+), 8 deletions(-)
diff --git a/tests/smscb/cbsp_test.c b/tests/smscb/cbsp_test.c
index 2dbdded..43b921c 100644
--- a/tests/smscb/cbsp_test.c
+++ b/tests/smscb/cbsp_test.c
@@ -26,6 +26,14 @@
#include <osmocom/gsm/protocol/gsm_48_049.h>
#include <osmocom/gsm/cbsp.h>
+struct test_case {
+ const char *name;
+ const char *hex_pdu;
+ bool exp_failure;
+};
+
+static const struct test_case test_case_list[] = {
+ {
/*
CBSP WRITE-REPLACE FAILURE
Message Type: WRITE-REPLACE FAILURE (3)
@@ -69,8 +77,45 @@
Information Element Identifier: Channel Indicator (18)
Channel Indicator: basic channel (0x00)
*/
-static const char write_repl_fail_with_failure_list[] =
- "0300002c0e003103417009000f0009f1070018003003012711c3510f04000f0009f1070017002a09f1070018002a1200";
+ .name = "CBSP WRITE-REPLACE FAILURE",
+ .hex_pdu = "0300002c0e003103417009000f0009f1070018003003012711c3510f04000f0009f1070017002a09f1070018002a1200",
+ },
+ {
+ /* XXX: CELL_IDENT_BSS => empty cell list (fails) */
+ .name = "CBSP RESET: Cell List (BSS)",
+ .hex_pdu = "1000000404000106",
+ },
+ {
+ /* XXX: CELL_IDENT_NO_CELL is not listed in 3GPP TS 48.049, 8.2.6 (fails) */
+ .name = "CBSP RESET: Cell List (NO_CELL)",
+ .hex_pdu = "1000000404000103",
+ },
+ {
+ /* same as the previos one, but with trailing bytes (ignored) */
+ .name = "CBSP RESET: Cell List (NO_CELL) with trailing bytes",
+ .hex_pdu = "1000000404000303ffff",
+ },
+ {
+ /* CELL_IDENT_LAC with short LAC => failure */
+ .name = "CBSP RESET: Cell List (LAC, short)",
+ .hex_pdu = "1000000404000205ff",
+ },
+ {
+ /* XXX: CELL_IDENT_LAC with missing LAC => expected failure (passes) */
+ .name = "CBSP RESET: Cell List (LAC, missing)",
+ .hex_pdu = "1000000404000105",
+ },
+ {
+ /* CELL_IDENT_LAC with malformed length => failure */
+ .name = "CBSP RESET: Cell List (malformed TLV)",
+ .hex_pdu = "100000040400ff05",
+ },
+ {
+ /* unknown cell identification discriminator => failure */
+ .name = "CBSP RESET: Cell List (unknown discriminator)",
+ .hex_pdu = "100000040400010f",
+ },
+};
static struct msgb *msgb_from_hex(unsigned int size, const char *hex)
{
@@ -88,14 +133,25 @@
printf("=== %s start ===\n", __func__);
- msg = msgb_from_hex(sizeof(write_repl_fail_with_failure_list),
- write_repl_fail_with_failure_list);
+ for (unsigned int i = 0; i < ARRAY_SIZE(test_case_list); i++) {
+ const struct test_case *tc = &test_case_list[i];
+ const char *verdict;
- cbsp_dec = osmo_cbsp_decode(NULL, msg);
- OSMO_ASSERT(cbsp_dec);
+ printf("TC[%u] '%s'\n", i, tc->name);
+ printf("TC[%u] PDU: %s\n", i, tc->hex_pdu);
- talloc_free(cbsp_dec);
- msgb_free(msg);
+ msg = msgb_from_hex(strlen(tc->hex_pdu), tc->hex_pdu);
+
+ cbsp_dec = osmo_cbsp_decode(NULL, msg);
+ if (cbsp_dec != NULL)
+ verdict = "pass";
+ else /* osmo_cbsp_errstr may be unset (NULL) */
+ verdict = osmo_cbsp_errstr ? : "error";
+ printf("TC[%u] osmo_cbsp_decode() result: %s\n", i, verdict);
+
+ talloc_free(cbsp_dec);
+ msgb_free(msg);
+ }
printf("=== %s end ===\n", __func__);
}
diff --git a/tests/smscb/cbsp_test.ok b/tests/smscb/cbsp_test.ok
index a837de5..f869d71 100644
--- a/tests/smscb/cbsp_test.ok
+++ b/tests/smscb/cbsp_test.ok
@@ -1,2 +1,26 @@
=== test_decode start ===
+TC[0] 'CBSP WRITE-REPLACE FAILURE'
+TC[0] PDU: 0300002c0e003103417009000f0009f1070018003003012711c3510f04000f0009f1070017002a09f1070018002a1200
+TC[0] osmo_cbsp_decode() result: pass
+TC[1] 'CBSP RESET: Cell List (BSS)'
+TC[1] PDU: 1000000404000106
+TC[1] osmo_cbsp_decode() result: cell list: unexpected cell_id_size
+TC[2] 'CBSP RESET: Cell List (NO_CELL)'
+TC[2] PDU: 1000000404000103
+TC[2] osmo_cbsp_decode() result: cell list: unexpected cell_id_size
+TC[3] 'CBSP RESET: Cell List (NO_CELL) with trailing bytes'
+TC[3] PDU: 1000000404000303ffff
+TC[3] osmo_cbsp_decode() result: cell list: unexpected cell_id_size
+TC[4] 'CBSP RESET: Cell List (LAC, short)'
+TC[4] PDU: 1000000404000205ff
+TC[4] osmo_cbsp_decode() result: cell list: error decoding cell_id_union
+TC[5] 'CBSP RESET: Cell List (LAC, missing)'
+TC[5] PDU: 1000000404000105
+TC[5] osmo_cbsp_decode() result: pass
+TC[6] 'CBSP RESET: Cell List (malformed TLV)'
+TC[6] PDU: 100000040400ff05
+TC[6] osmo_cbsp_decode() result: error
+TC[7] 'CBSP RESET: Cell List (unknown discriminator)'
+TC[7] PDU: 100000040400010f
+TC[7] osmo_cbsp_decode() result: cell list: unexpected cell_id_size
=== test_decode end ===
To view, visit change 44176. To unsubscribe, or for help writing mail filters, visit settings.