aboutsummaryrefslogtreecommitdiffstats
path: root/tests/alloc/AllocTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/alloc/AllocTest.cpp')
-rw-r--r--tests/alloc/AllocTest.cpp141
1 files changed, 141 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;
}