From 8d9ed738a7c94f07df348a9687b88a1fe03cd440 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Mon, 20 Feb 2023 13:01:29 +0100 Subject: [PATCH] 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 --- tests/gsm0808/gsm0808_test.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/gsm0808/gsm0808_test.c b/tests/gsm0808/gsm0808_test.c index a03f27670..9a6de1e7d 100644 --- a/tests/gsm0808/gsm0808_test.c +++ b/tests/gsm0808/gsm0808_test.c @@ -1199,6 +1199,33 @@ static void test_gsm0808_enc_dec_channel_type_speech(void) 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 @@ int main(int argc, char **argv) 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();