Add test for MS mode and (M)CS settings

Right now set_mode() on GprsMs behaves in pretty counter-intuitive way:
* it's possible to set current DL MCS higher than max value
* EGPRS and EGPRS_GMSK have the same max DL MCS
* setting EGPRS* mode drops current/max MCS values to unknown

Let's capture this in a unit-test before attempting any further
modifications.

Change-Id: Ibf917f4b49d927a21cbd467775806fa6ea06a6a6
This commit is contained in:
Max 2019-03-06 15:59:09 +01:00 committed by Harald Welte
parent 0e6e45a65f
commit 41d6b35670
3 changed files with 86 additions and 0 deletions

View File

@ -531,6 +531,75 @@ static void test_ms_cs_selection()
printf("=== end %s ===\n", __func__);
}
static void dump_ms(const GprsMs *ms, const char *pref)
{
printf("%s MS DL %s/%s, UL %s/%s, mode %s, <%s>\n", pref,
mcs_name(ms->current_cs_dl()), mcs_name(ms->max_cs_dl()),
mcs_name(ms->current_cs_ul()), mcs_name(ms->max_cs_ul()),
mode_name(ms->mode()),
ms->is_idle() ? "IDLE" : "ACTIVE");
}
static void test_ms_mcs_mode()
{
BTS the_bts;
gprs_rlcmac_bts *bts = the_bts.bts_data();
uint32_t tlli = 0xdeadbeef;
gprs_rlcmac_dl_tbf *dl_tbf;
GprsMs *ms1, *ms2;
printf("=== start %s ===\n", __func__);
ms1 = new GprsMs(&the_bts, tlli);
dump_ms(ms1, "1: no BTS defaults ");
bts->initial_cs_dl = 4;
bts->initial_cs_ul = 1;
bts->cs_downgrade_threshold = 0;
ms2 = new GprsMs(&the_bts, tlli + 1);
dump_ms(ms2, "2: with BTS defaults");
dl_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_dl_tbf);
new (dl_tbf) gprs_rlcmac_dl_tbf(NULL);
dl_tbf->set_ms(ms2);
dump_ms(ms2, "2: after TBF attach ");
ms1->set_mode(EGPRS);
dump_ms(ms1, "1: after mode set ");
ms2->set_mode(EGPRS);
dump_ms(ms2, "2: after mode set ");
ms1->set_current_cs_dl(MCS7);
dump_ms(ms1, "1: after MCS set ");
ms2->set_current_cs_dl(MCS8);
dump_ms(ms2, "2: after MCS set ");
ms1->set_mode(EGPRS_GMSK);
dump_ms(ms1, "1: after mode set ");
ms2->set_mode(EGPRS_GMSK);
dump_ms(ms2, "2: after mode set ");
// FIXME: following code triggers ASAN failure:
// ms2->detach_tbf(dl_tbf);
// dump_ms(ms2, "2: after TBF detach ");
ms1->set_mode(GPRS);
dump_ms(ms1, "1: after mode set ");
ms2->set_mode(GPRS);
dump_ms(ms2, "2: after mode set ");
talloc_free(dl_tbf);
printf("=== end %s ===\n", __func__);
}
int main(int argc, char **argv)
{
struct vty_app_info pcu_vty_info = {0};
@ -556,6 +625,7 @@ int main(int argc, char **argv)
test_ms_storage();
test_ms_timeout();
test_ms_cs_selection();
test_ms_mcs_mode();
if (getenv("TALLOC_REPORT_FULL"))
talloc_report_full(tall_pcu_ctx, stderr);

View File

@ -56,3 +56,6 @@ Timeout for MS object, TLLI = 0xffeeddbb
Destroying MS object, TLLI = 0xffeeddbb
Creating MS object, TLLI = 0xffeeddbb
Attaching TBF to MS object, TLLI = 0xffeeddbb, TBF = TBF(TFI=0 TLLI=0xffeeddbb DIR=DL STATE=NULL)
Creating MS object, TLLI = 0xdeadbeef
Creating MS object, TLLI = 0xdeadbef0
Attaching TBF to MS object, TLLI = 0xdeadbef0, TBF = TBF(TFI=0 TLLI=0xdeadbef0 DIR=DL STATE=NULL)

View File

@ -18,3 +18,16 @@
=== end test_ms_timeout ===
=== start test_ms_cs_selection ===
=== end test_ms_cs_selection ===
=== start test_ms_mcs_mode ===
1: no BTS defaults MS DL UNKNOWN/UNKNOWN, UL UNKNOWN/UNKNOWN, mode GPRS, <IDLE>
2: with BTS defaults MS DL CS-4/CS-4, UL CS-1/CS-4, mode GPRS, <IDLE>
2: after TBF attach MS DL CS-4/CS-4, UL CS-1/CS-4, mode GPRS, <ACTIVE>
1: after mode set MS DL UNKNOWN/UNKNOWN, UL UNKNOWN/UNKNOWN, mode EGPRS, <IDLE>
2: after mode set MS DL UNKNOWN/UNKNOWN, UL UNKNOWN/UNKNOWN, mode EGPRS, <ACTIVE>
1: after MCS set MS DL MCS-7/MCS-4, UL UNKNOWN/UNKNOWN, mode EGPRS, <IDLE>
2: after MCS set MS DL MCS-8/MCS-4, UL UNKNOWN/UNKNOWN, mode EGPRS, <ACTIVE>
1: after mode set MS DL MCS-7/MCS-4, UL UNKNOWN/UNKNOWN, mode EGPRS_GMSK-only, <IDLE>
2: after mode set MS DL MCS-8/MCS-4, UL UNKNOWN/UNKNOWN, mode EGPRS_GMSK-only, <ACTIVE>
1: after mode set MS DL CS-4/CS-4, UL CS-1/CS-4, mode GPRS, <IDLE>
2: after mode set MS DL CS-4/CS-4, UL CS-1/CS-4, mode GPRS, <ACTIVE>
=== end test_ms_mcs_mode ===