aboutsummaryrefslogtreecommitdiffstats
path: root/tests/alloc
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-12-25 19:16:55 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-01-15 10:39:07 +0100
commit4af30533f0e01a7156ff92f7689ccf35900740c3 (patch)
tree16a4ef2e9560fdbef16801fc5bf8b339bcd8a9bc /tests/alloc
parentf37e514a9607254d1cbdd20cb9b2468de2c143be (diff)
alloc/tests: Create an allocation test for various scenarious
The allocation in the TBF/BTS code is quite complex. In parts this is due the assignment and requests occuring under differen circumstances. Attempt to re-create the commono scenarios. Remove the bogus msclass check in gprs_rlcmac_tbf::update as the allocation code will check the ms class anyway.
Diffstat (limited to 'tests/alloc')
-rw-r--r--tests/alloc/AllocTest.cpp141
-rw-r--r--tests/alloc/AllocTest.ok32
2 files changed, 173 insertions, 0 deletions
diff --git a/tests/alloc/AllocTest.cpp b/tests/alloc/AllocTest.cpp
index 5790ade1..5c903210 100644
--- a/tests/alloc/AllocTest.cpp
+++ b/tests/alloc/AllocTest.cpp
@@ -97,6 +97,146 @@ static void test_alloc_a()
test_alloc_a(GPRS_RLCMAC_UL_TBF, 7);
}
+static void dump_assignment(struct gprs_rlcmac_tbf *tbf, const char *dir)
+{
+ for (int i = 0; i < ARRAY_SIZE(tbf->pdch); ++i)
+ if (tbf->pdch[i])
+ printf("PDCH[%d] is used for %s\n", i, dir);
+ printf("PDCH[%d] is control_ts for %s\n", tbf->control_ts, dir);
+ printf("PDCH[%d] is first common for %s\n", tbf->first_common_ts, dir);
+}
+
+static void test_alloc_b()
+{
+ printf("Going to test multislot assignment.\n");
+ /*
+ * PDCH is on TS 6,7,8 and we start with a UL allocation and
+ * then follow two DL allocations (once single, once normal).
+ *
+ * Uplink assigned and still available..
+ */
+ {
+ BTS the_bts;
+ struct gprs_rlcmac_bts *bts;
+ struct gprs_rlcmac_trx *trx;
+ int tfi;
+ uint8_t ts_no, trx_no;
+
+ gprs_rlcmac_tbf *ul_tbf, *dl_tbf;
+
+ printf("Testing UL then DL assignment.\n");
+
+ bts = the_bts.bts_data();
+ bts->alloc_algorithm = alloc_algorithm_b;
+
+ trx = &bts->trx[0];
+ trx->pdch[5].enable();
+ trx->pdch[6].enable();
+ trx->pdch[7].enable();
+
+ tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1);
+ OSMO_ASSERT(tfi >= 0);
+ ul_tbf = tbf_alloc(bts, NULL, GPRS_RLCMAC_UL_TBF, tfi, trx_no, 0, 1);
+ OSMO_ASSERT(ul_tbf);
+ dump_assignment(ul_tbf, "UL");
+
+ /* assume final ack has not been sent */
+ tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1);
+ OSMO_ASSERT(tfi >= 0);
+ dl_tbf = tbf_alloc(bts, ul_tbf, GPRS_RLCMAC_DL_TBF, tfi, trx_no, 0, 0);
+ OSMO_ASSERT(dl_tbf);
+ dump_assignment(dl_tbf, "DL");
+
+ tbf_free(dl_tbf);
+ tbf_free(ul_tbf);
+ }
+
+ /**
+ * Test with the other order.. first DL and then UL
+ */
+ {
+ BTS the_bts;
+ struct gprs_rlcmac_bts *bts;
+ struct gprs_rlcmac_trx *trx;
+ int tfi;
+ uint8_t ts_no, trx_no;
+
+ gprs_rlcmac_tbf *ul_tbf, *dl_tbf;
+
+ printf("Testing DL then UL assignment followed by update\n");
+
+ bts = the_bts.bts_data();
+ bts->alloc_algorithm = alloc_algorithm_b;
+
+ trx = &bts->trx[0];
+ trx->pdch[5].enable();
+ trx->pdch[6].enable();
+ trx->pdch[7].enable();
+
+ tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1);
+ OSMO_ASSERT(tfi >= 0);
+ dl_tbf = tbf_alloc(bts, NULL, GPRS_RLCMAC_DL_TBF, tfi, trx_no, 0, 1);
+ dl_tbf->m_tlli = 0x23;
+ dl_tbf->m_tlli_valid = true;
+ OSMO_ASSERT(dl_tbf);
+ dump_assignment(dl_tbf, "DL");
+
+ tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1);
+ OSMO_ASSERT(tfi >= 0);
+ ul_tbf = tbf_alloc(bts, dl_tbf, GPRS_RLCMAC_UL_TBF, tfi, trx_no, 0, 0);
+ ul_tbf->m_tlli = 0x23;
+ ul_tbf->m_tlli_valid = true;
+ ul_tbf->dir.ul.contention_resolution_done = 1;
+ OSMO_ASSERT(ul_tbf);
+ dump_assignment(ul_tbf, "UL");
+
+ /* now update the dl_tbf */
+ dl_tbf->update();
+ dump_assignment(dl_tbf, "DL");
+
+ tbf_free(dl_tbf);
+ tbf_free(ul_tbf);
+ }
+
+ /* Andreas osmocom-pcu example */
+ {
+ BTS the_bts;
+ struct gprs_rlcmac_bts *bts;
+ struct gprs_rlcmac_trx *trx;
+ int tfi;
+ uint8_t ts_no, trx_no;
+
+ gprs_rlcmac_tbf *ul_tbf, *dl_tbf;
+
+ printf("Testing jolly example\n");
+
+ bts = the_bts.bts_data();
+ bts->alloc_algorithm = alloc_algorithm_b;
+
+ trx = &bts->trx[0];
+ trx->pdch[1].enable();
+ trx->pdch[2].enable();
+ trx->pdch[3].enable();
+ trx->pdch[4].enable();
+
+ tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1);
+ OSMO_ASSERT(tfi >= 0);
+ ul_tbf = tbf_alloc(bts, NULL, GPRS_RLCMAC_UL_TBF, tfi, trx_no, 0, 0);
+ OSMO_ASSERT(ul_tbf);
+ dump_assignment(ul_tbf, "UL");
+
+ /* assume final ack has not been sent */
+ tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1);
+ OSMO_ASSERT(tfi >= 0);
+ dl_tbf = tbf_alloc(bts, ul_tbf, GPRS_RLCMAC_DL_TBF, tfi, trx_no, 0, 0);
+ OSMO_ASSERT(dl_tbf);
+ dump_assignment(dl_tbf, "DL");
+
+ tbf_free(dl_tbf);
+ tbf_free(ul_tbf);
+ }
+}
+
int main(int argc, char **argv)
{
tall_pcu_ctx = talloc_named_const(NULL, 1, "moiji-mobile AllocTest context");
@@ -109,6 +249,7 @@ int main(int argc, char **argv)
log_set_print_filename(osmo_stderr_target, 0);
test_alloc_a();
+ test_alloc_b();
return EXIT_SUCCESS;
}
diff --git a/tests/alloc/AllocTest.ok b/tests/alloc/AllocTest.ok
index 86a8c193..271a4200 100644
--- a/tests/alloc/AllocTest.ok
+++ b/tests/alloc/AllocTest.ok
@@ -1,2 +1,34 @@
Testing alloc_a direction(0)
Testing alloc_a direction(1)
+Going to test multislot assignment.
+Testing UL then DL assignment.
+PDCH[6] is used for UL
+PDCH[6] is control_ts for UL
+PDCH[6] is first common for UL
+PDCH[5] is used for DL
+PDCH[6] is used for DL
+PDCH[7] is used for DL
+PDCH[6] is control_ts for DL
+PDCH[6] is first common for DL
+Testing DL then UL assignment followed by update
+PDCH[6] is used for DL
+PDCH[6] is control_ts for DL
+PDCH[6] is first common for DL
+PDCH[6] is used for UL
+PDCH[6] is control_ts for UL
+PDCH[6] is first common for UL
+PDCH[5] is used for DL
+PDCH[6] is used for DL
+PDCH[7] is used for DL
+PDCH[6] is control_ts for DL
+PDCH[6] is first common for DL
+Testing jolly example
+PDCH[3] is used for UL
+PDCH[3] is control_ts for UL
+PDCH[3] is first common for UL
+PDCH[1] is used for DL
+PDCH[2] is used for DL
+PDCH[3] is used for DL
+PDCH[4] is used for DL
+PDCH[3] is control_ts for DL
+PDCH[3] is first common for DL