diff options
Diffstat (limited to 'tests/tlv/tlv_test.c')
-rw-r--r-- | tests/tlv/tlv_test.c | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/tests/tlv/tlv_test.c b/tests/tlv/tlv_test.c index fdd15ab0..8e8bd603 100644 --- a/tests/tlv/tlv_test.c +++ b/tests/tlv/tlv_test.c @@ -188,7 +188,7 @@ static void check_lv_shift_data_len(size_t data_len, } } -static void test_tlv_shift_functions() +static void test_tlv_shift_functions(void) { uint8_t test_data[1024]; uint8_t buf[1024]; @@ -250,7 +250,7 @@ static void test_tlv_shift_functions() /* Most GSM related protocols clearly indicate that in case of duplicate * IEs, only the first occurrence shall be used, while any further occurrences * shall be ignored. See e.g. 3GPP TS 24.008 Section 8.6.3 */ -static void test_tlv_repeated_ie() +static void test_tlv_repeated_ie(void) { uint8_t test_data[768]; int i, rc; @@ -288,7 +288,7 @@ static void test_tlv_repeated_ie() OSMO_ASSERT(dec3[2].lv[tag].val == &test_data[2 + 3 + 3]); } -static void test_tlv_encoder() +static void test_tlv_encoder(void) { const uint8_t enc_ies[] = { 0x17, 0x14, 0x06, 0x2b, 0x12, 0x2b, 0x0b, 0x40, 0x2b, 0xb7, 0x05, 0xd0, 0x63, 0x82, 0x95, 0x03, 0x05, 0x40, @@ -332,7 +332,7 @@ static void test_tlv_encoder() msgb_free(msg); } -static void test_tlv_parser_bounds() +static void test_tlv_parser_bounds(void) { struct tlv_definition tdef; struct tlv_parsed dec; @@ -423,7 +423,7 @@ static void test_tlv_parser_bounds() OSMO_ASSERT(TLVP_VAL(&dec, 0x23) == NULL); } -static void test_tlv_lens() +static void test_tlv_lens(void) { uint16_t buf_len; uint8_t buf[512]; @@ -454,6 +454,30 @@ static void test_tlv_lens() } } +static void test_tlv_type_single_tv(void) +{ + #define SAMPLE_SINGLE_TV_IE 0x08 + const struct tlv_definition att_tlvdef = { + .def = { + [SAMPLE_SINGLE_TV_IE] = { TLV_TYPE_SINGLE_TV, 0 }, + }, + }; + struct tlv_parsed tp; + int rc; + uint8_t exp_val = 0x03; + uint8_t buf[] = { (SAMPLE_SINGLE_TV_IE << 4) | (exp_val & 0x0f) }; + const uint8_t *val; + + rc = tlv_parse(&tp, &att_tlvdef, buf, sizeof(buf), 0, 0); + OSMO_ASSERT(rc == 1); + OSMO_ASSERT(TLVP_PRESENT(&tp, SAMPLE_SINGLE_TV_IE)); + val = TLVP_VAL(&tp, SAMPLE_SINGLE_TV_IE); + OSMO_ASSERT(val); + OSMO_ASSERT(val == &buf[0]); + OSMO_ASSERT(*val == buf[0]); + OSMO_ASSERT((*val & 0x0f) == exp_val); +} + int main(int argc, char **argv) { //osmo_init_logging2(ctx, &info); @@ -463,6 +487,7 @@ int main(int argc, char **argv) test_tlv_encoder(); test_tlv_parser_bounds(); test_tlv_lens(); + test_tlv_type_single_tv(); printf("Done.\n"); return EXIT_SUCCESS; |