diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2023-05-02 12:11:22 +0200 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2023-05-02 12:11:26 +0200 |
commit | e2217ee098426f6ea67bb3f60ccea5bd39628c01 (patch) | |
tree | 99022d1c36e79f0c6649459992bff11d109714f8 /tests/tlv/tlv_test.c | |
parent | f6ef9ba1e9d535c016b306fbace85d373e3cf489 (diff) |
tlv: Show bug in decoded tlv_parsed for type TLV_TYPE_SINGLE_TV
A commit was merged recently attempting to fix decoding of
TLV_TYPE_SINGLE_TV. It did mostly a good job, but missed updating the
o_tag pointer used to fill in the structures.
This new unit test showcases the mentioned problem.
A follow-up patch will fix the bug.
Change-Id: Ia17c84059a413f80c2bcf194034ebac586ecf7e1
Diffstat (limited to 'tests/tlv/tlv_test.c')
-rw-r--r-- | tests/tlv/tlv_test.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/tlv/tlv_test.c b/tests/tlv/tlv_test.c index f9137ad3..aaa86a3a 100644 --- a/tests/tlv/tlv_test.c +++ b/tests/tlv/tlv_test.c @@ -454,6 +454,32 @@ static void test_tlv_lens(void) } } +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)); //FIXME! + val = TLVP_VAL(&tp, SAMPLE_SINGLE_TV_IE); + OSMO_ASSERT(!val); //FIXME! +#if 0 + OSMO_ASSERT(val == &buf[0]); + OSMO_ASSERT(*val == buf[0]); + OSMO_ASSERT((*val & 0x0f) == exp_val); +#endif +} + int main(int argc, char **argv) { //osmo_init_logging2(ctx, &info); @@ -463,6 +489,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; |