osmith has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/31409 )
Change subject: tests: add test_gsm0808_enc_dec_channel_type_sign ......................................................................
tests: add test_gsm0808_enc_dec_channel_type_sign
Verify that we have the spare byte when encoding the signalling type.
Related: OS#5911 Change-Id: Ied6e451d2e884412104cd9d530d0cd1b39f17f27 --- M tests/gsm0808/gsm0808_test.c 1 file changed, 40 insertions(+), 0 deletions(-)
Approvals: fixeria: Looks good to me, approved pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified
diff --git a/tests/gsm0808/gsm0808_test.c b/tests/gsm0808/gsm0808_test.c index a03f276..9a6de1e 100644 --- a/tests/gsm0808/gsm0808_test.c +++ b/tests/gsm0808/gsm0808_test.c @@ -1199,6 +1199,33 @@ msgb_free(msg); }
+static void test_gsm0808_enc_dec_channel_type_sign(void) +{ + struct gsm0808_channel_type enc_ct = { + .ch_indctr = GSM0808_CHAN_SIGN, + .ch_rate_type = GSM0808_SIGN_FULL_PREF_NO_CHANGE, + }; + struct gsm0808_channel_type dec_ct = {}; + struct msgb *msg; + uint8_t ct_enc_expected[] = { GSM0808_IE_CHANNEL_TYPE, + 0x03, 0x03, 0x1a, 0x00 + }; + uint8_t rc_enc; + int rc_dec; + + msg = msgb_alloc(1024, "output buffer"); + rc_enc = gsm0808_enc_channel_type(msg, &enc_ct); + OSMO_ASSERT(rc_enc == 5); + OSMO_ASSERT(memcmp(ct_enc_expected, msg->data, msg->len) == 0); + + rc_dec = gsm0808_dec_channel_type(&dec_ct, msg->data + 2, msg->len - 2); + OSMO_ASSERT(rc_dec == 2); + OSMO_ASSERT(enc_ct.ch_indctr == dec_ct.ch_indctr); + OSMO_ASSERT(enc_ct.ch_rate_type == dec_ct.ch_rate_type); + + msgb_free(msg); +} + static void test_gsm0808_dec_channel_type_err(void) { struct gsm0808_channel_type ct; @@ -2684,6 +2711,7 @@ test_gsm0808_enc_dec_channel_type_data(); test_gsm0808_enc_dec_channel_type_data_asym_pref(); test_gsm0808_enc_dec_channel_type_speech(); + test_gsm0808_enc_dec_channel_type_sign(); test_gsm0808_dec_channel_type_err(); test_gsm0808_enc_dec_encrypt_info();