aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2019-03-06 15:59:09 +0100
committerHarald Welte <laforge@gnumonks.org>2019-04-11 07:29:53 +0000
commit41d6b35670efe87d91d509d5b1df8b06292fe73e (patch)
treee2f4c456597454f0f7b8acc53dc9ec21d600aa48
parent0e6e45a65f984d346444f47411244b255cb39301 (diff)
Add test for MS mode and (M)CS settingsHEADmaster
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
-rw-r--r--tests/ms/MsTest.cpp70
-rw-r--r--tests/ms/MsTest.err3
-rw-r--r--tests/ms/MsTest.ok13
3 files changed, 86 insertions, 0 deletions
diff --git a/tests/ms/MsTest.cpp b/tests/ms/MsTest.cpp
index aa600e5..4f8f3a0 100644
--- a/tests/ms/MsTest.cpp
+++ b/tests/ms/MsTest.cpp
@@ -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);
diff --git a/tests/ms/MsTest.err b/tests/ms/MsTest.err
index a2e4a0c..735c4fe 100644
--- a/tests/ms/MsTest.err
+++ b/tests/ms/MsTest.err
@@ -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)
diff --git a/tests/ms/MsTest.ok b/tests/ms/MsTest.ok
index f14cceb..9952d59 100644
--- a/tests/ms/MsTest.ok
+++ b/tests/ms/MsTest.ok
@@ -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 ===