tests/amr: add a unit test for amr_parse_mr_conf()
This unit test demonstrates a problem in amr_parse_mr_conf(): the threshold and hysteresis values are parsed incorrectly. They are expected to match what we have in amr_fr_bts_mode_def[]: Mode[0] = 0/13/4 Mode[1] = 2/25/4 Mode[2] = 5/37/4 This will be fixed in a follow-up patch. Change-Id: Iab7e8878e62f598959e80fcb7e729b7f496962a2 Related: SYS#5917, OS#4984
This commit is contained in:
parent
f576e673a3
commit
4765a5d195
|
@ -4,7 +4,7 @@ AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOCODEC_CFLA
|
|||
LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOCODEC_LIBS) \
|
||||
$(LIBOSMOABIS_LIBS) $(LIBOSMOTRAU_LIBS)
|
||||
noinst_PROGRAMS = amr_test
|
||||
EXTRA_DIST = amr_test.ok
|
||||
EXTRA_DIST = amr_test.ok amr_test.err
|
||||
|
||||
amr_test_SOURCES = amr_test.c
|
||||
amr_test_LDADD = $(top_builddir)/src/common/libbts.a \
|
||||
|
|
|
@ -19,7 +19,12 @@
|
|||
*/
|
||||
|
||||
#include <osmo-bts/logging.h>
|
||||
#include <osmo-bts/bts.h>
|
||||
#include <osmo-bts/amr.h>
|
||||
|
||||
#include <osmocom/core/application.h>
|
||||
#include <osmocom/core/utils.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "../../src/osmo-bts-trx/sched_utils.h"
|
||||
|
@ -143,9 +148,44 @@ static void test_amr_cmi_sched(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void test_amr_parse_mr_conf(void)
|
||||
{
|
||||
uint8_t mrc_enc[] = { 0x20, 0xa5, 0x0d, 0x46, 0x52, 0x54 };
|
||||
struct amr_multirate_conf mrc = { 0 };
|
||||
unsigned int i;
|
||||
|
||||
printf("amr_parse_mr_conf() <- %s\n", osmo_hexdump(&mrc_enc[0], sizeof(mrc_enc)));
|
||||
OSMO_ASSERT(amr_parse_mr_conf(&mrc, &mrc_enc[0], sizeof(mrc_enc)) > 0);
|
||||
printf("amr_parse_mr_conf() -> num_modes=%u\n", mrc.num_modes);
|
||||
for (i = 0; i < mrc.num_modes; i++) {
|
||||
printf(" Mode[%u] = %u/%u/%u\n",
|
||||
i, mrc.bts_mode[i].mode,
|
||||
mrc.bts_mode[i].threshold,
|
||||
mrc.bts_mode[i].hysteresis);
|
||||
}
|
||||
|
||||
mrc_enc[1] = 0xff; /* all codec modes active */
|
||||
printf("amr_parse_mr_conf() <- %s\n", osmo_hexdump(&mrc_enc[0], sizeof(mrc_enc)));
|
||||
OSMO_ASSERT(amr_parse_mr_conf(&mrc, &mrc_enc[0], sizeof(mrc_enc)) == -EINVAL);
|
||||
|
||||
mrc_enc[0] = 0xff; /* unknown version */
|
||||
printf("amr_parse_mr_conf() <- %s\n", osmo_hexdump(&mrc_enc[0], sizeof(mrc_enc)));
|
||||
OSMO_ASSERT(amr_parse_mr_conf(&mrc, &mrc_enc[0], sizeof(mrc_enc)) == -EINVAL);
|
||||
|
||||
printf("amr_parse_mr_conf() <- %s\n", osmo_hexdump(&mrc_enc[0], 1)); /* short read */
|
||||
OSMO_ASSERT(amr_parse_mr_conf(&mrc, &mrc_enc[0], 1) == -EINVAL);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
osmo_init_logging2(NULL, &bts_log_info);
|
||||
log_set_print_filename2(osmo_stderr_target, LOG_FILENAME_NONE);
|
||||
log_set_print_category_hex(osmo_stderr_target, 0);
|
||||
log_set_print_category(osmo_stderr_target, 1);
|
||||
log_set_print_level(osmo_stderr_target, 1);
|
||||
log_set_use_color(osmo_stderr_target, 0);
|
||||
|
||||
test_amr_cmi_sched();
|
||||
test_amr_parse_mr_conf();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
DRSL ERROR AMR Multirate with 8 modes len=6 not possible
|
||||
DRSL ERROR AMR Multirate Version 7 unknown
|
||||
DRSL ERROR AMR Multirate IE is too short (1)
|
|
@ -150,3 +150,12 @@ Downlink, AMR AFS: fn_begin=86, CMI=0
|
|||
Downlink, AMR AFS: fn_begin=91, CMI=1
|
||||
Downlink, AMR AFS: fn_begin=95, CMI=0
|
||||
Downlink, AMR AFS: fn_begin=99, CMI=1
|
||||
amr_parse_mr_conf() <- 20 a5 0d 46 52 54
|
||||
amr_parse_mr_conf() -> num_modes=4
|
||||
Mode[0] = 0/37/0
|
||||
Mode[1] = 2/53/1
|
||||
Mode[2] = 5/37/2
|
||||
Mode[3] = 7/0/0
|
||||
amr_parse_mr_conf() <- 20 ff 0d 46 52 54
|
||||
amr_parse_mr_conf() <- ff ff 0d 46 52 54
|
||||
amr_parse_mr_conf() <- ff
|
||||
|
|
|
@ -67,5 +67,6 @@ AT_CLEANUP
|
|||
AT_SETUP([amr])
|
||||
AT_KEYWORDS([amr])
|
||||
cat $abs_srcdir/amr/amr_test.ok > expout
|
||||
AT_CHECK([$abs_top_builddir/tests/amr/amr_test], [], [expout], [ignore])
|
||||
cat $abs_srcdir/amr/amr_test.err > experr
|
||||
AT_CHECK([$abs_top_builddir/tests/amr/amr_test], [], [expout], [experr])
|
||||
AT_CLEANUP
|
||||
|
|
Loading…
Reference in New Issue