diff options
author | Jacob Erlbeck <jerlbeck@sysmocom.de> | 2015-06-29 12:19:52 +0200 |
---|---|---|
committer | Jacob Erlbeck <jerlbeck@sysmocom.de> | 2015-06-29 12:19:52 +0200 |
commit | edcab1a0be452d8c977e35783ce489beb82da099 (patch) | |
tree | 9a26fba5b09028102612fabb4599cc1741ba5eb0 | |
parent | cb1b494c896243a92a1969bb4c0ee4baddad2423 (diff) |
alloc/test: Add test for successive allocation
This test allocates as many as possible UL/DL TBF pairs, shows their
PDCH usage, and checks how many of them has been created
successfully.
Sponsored-by: On-Waves ehf
-rw-r--r-- | tests/alloc/AllocTest.cpp | 82 | ||||
-rw-r--r-- | tests/alloc/AllocTest.err | 5 | ||||
-rw-r--r-- | tests/alloc/AllocTest.ok | 63 |
3 files changed, 150 insertions, 0 deletions
diff --git a/tests/alloc/AllocTest.cpp b/tests/alloc/AllocTest.cpp index ebd57c58..d0fac953 100644 --- a/tests/alloc/AllocTest.cpp +++ b/tests/alloc/AllocTest.cpp @@ -390,6 +390,83 @@ static void test_alloc_b() test_all_alloc_b(); } +typedef int (*algo_t)(struct gprs_rlcmac_bts *bts, + struct GprsMs *ms, + struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single); + +static char get_dir_char(uint8_t mask, uint8_t tx, uint8_t rx) +{ + return (mask & tx & rx) ? 'C' : + (mask & tx) ? 'U' : + (mask & rx) ? 'D' : + '.'; +} + +static void test_successive_allocation(algo_t algo, unsigned min_class, + unsigned max_class, unsigned expect_num, const char *text) +{ + BTS the_bts; + struct gprs_rlcmac_bts *bts; + struct gprs_rlcmac_trx *trx; + int tfi; + uint8_t trx_no; + unsigned counter; + unsigned ms_class = min_class; + + printf("Going to test assignment with many TBF, %s\n", text); + + bts = the_bts.bts_data(); + bts->alloc_algorithm = algo; + + trx = &bts->trx[0]; + trx->pdch[3].enable(); + trx->pdch[4].enable(); + trx->pdch[5].enable(); + trx->pdch[6].enable(); + trx->pdch[7].enable(); + + for (counter = 0; 1; counter += 1) { + gprs_rlcmac_tbf *ul_tbf, *dl_tbf; + uint8_t ul_slots; + uint8_t dl_slots; + unsigned i; + + tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1); + if (tfi < 0) + break; + ul_tbf = tbf_alloc_ul_tbf(bts, NULL, tfi, trx_no, ms_class, 0); + if (ul_tbf == NULL) + break; + OSMO_ASSERT(ul_tbf->ms()); + dl_tbf = tbf_alloc_dl_tbf(bts, ul_tbf->ms(), tfi, trx_no, ms_class, 0); + OSMO_ASSERT(dl_tbf); + + ul_slots = 1 << ul_tbf->first_common_ts; + dl_slots = 0; + for (i = 0; i < ARRAY_SIZE(dl_tbf->pdch); i += 1) + if (dl_tbf->pdch[i]) + dl_slots |= 1 << i; + + printf(" TBF[%d] class %d reserves %c%c%c%c%c%c%c%c\n", + tfi, ms_class, + get_dir_char(0x01, ul_slots, dl_slots), + get_dir_char(0x02, ul_slots, dl_slots), + get_dir_char(0x04, ul_slots, dl_slots), + get_dir_char(0x08, ul_slots, dl_slots), + get_dir_char(0x10, ul_slots, dl_slots), + get_dir_char(0x20, ul_slots, dl_slots), + get_dir_char(0x40, ul_slots, dl_slots), + get_dir_char(0x80, ul_slots, dl_slots)); + + ms_class += 1; + if (ms_class > max_class) + ms_class = min_class; + } + + printf(" Successfully allocated %d UL TBFs\n", counter); + OSMO_ASSERT(counter >= expect_num); +} + int main(int argc, char **argv) { tall_pcu_ctx = talloc_named_const(NULL, 1, "moiji-mobile AllocTest context"); @@ -403,6 +480,11 @@ int main(int argc, char **argv) test_alloc_a(); test_alloc_b(); + test_successive_allocation(alloc_algorithm_a, 1, 1, 7, "algorithm A"); + test_successive_allocation(alloc_algorithm_b, 10, 10, 7, "algorithm B class 10"); + test_successive_allocation(alloc_algorithm_b, 12, 12, 7, "algorithm B class 12"); + test_successive_allocation(alloc_algorithm_b, 1, 12, 14, "algorithm B class 1-12"); + test_successive_allocation(alloc_algorithm_b, 1, 29, 18, "algorithm B class 1-29"); return EXIT_SUCCESS; } diff --git a/tests/alloc/AllocTest.err b/tests/alloc/AllocTest.err index 3f285a46..bb18b28c 100644 --- a/tests/alloc/AllocTest.err +++ b/tests/alloc/AllocTest.err @@ -1,2 +1,7 @@ No TFI available. - Failed allocating TS=2, no USF available +- Failed allocating TS=3, no USF available +No suitable uplink slots available +No suitable uplink slots available +No suitable uplink slots available +No suitable uplink slots available diff --git a/tests/alloc/AllocTest.ok b/tests/alloc/AllocTest.ok index 19ae644a..23c9ab67 100644 --- a/tests/alloc/AllocTest.ok +++ b/tests/alloc/AllocTest.ok @@ -8615,3 +8615,66 @@ Mass test: TS0(OOOOOOOO)TS7 MS_Class=26 Mass test: TS0(OOOOOOOO)TS7 MS_Class=27 Mass test: TS0(OOOOOOOO)TS7 MS_Class=28 Mass test: TS0(OOOOOOOO)TS7 MS_Class=29 +Going to test assignment with many TBF, algorithm A + TBF[0] class 1 reserves ...C.... + TBF[1] class 1 reserves ...C.... + TBF[2] class 1 reserves ...C.... + TBF[3] class 1 reserves ...C.... + TBF[4] class 1 reserves ...C.... + TBF[5] class 1 reserves ...C.... + TBF[6] class 1 reserves ...C.... + Successfully allocated 7 UL TBFs +Going to test assignment with many TBF, algorithm B class 10 + TBF[0] class 10 reserves ...DDCD. + TBF[1] class 10 reserves ...DDCD. + TBF[2] class 10 reserves ...DDCD. + TBF[3] class 10 reserves ...DDCD. + TBF[4] class 10 reserves ...DDCD. + TBF[5] class 10 reserves ...DDCD. + TBF[6] class 10 reserves ...DDCD. + Successfully allocated 7 UL TBFs +Going to test assignment with many TBF, algorithm B class 12 + TBF[0] class 12 reserves ...DDCD. + TBF[1] class 12 reserves ...DDCD. + TBF[2] class 12 reserves ...DDCD. + TBF[3] class 12 reserves ...DDCD. + TBF[4] class 12 reserves ...DDCD. + TBF[5] class 12 reserves ...DDCD. + TBF[6] class 12 reserves ...DDCD. + Successfully allocated 7 UL TBFs +Going to test assignment with many TBF, algorithm B class 1-12 + TBF[0] class 1 reserves ...C.... + TBF[1] class 2 reserves ...DC... + TBF[2] class 3 reserves ...DC... + TBF[3] class 4 reserves ...DCD.. + TBF[4] class 5 reserves ...CD... + TBF[5] class 6 reserves ...DCD.. + TBF[6] class 7 reserves ...DCD.. + TBF[7] class 8 reserves ...DDCD. + TBF[8] class 9 reserves ...DCD.. + TBF[9] class 10 reserves ...DDCD. + TBF[10] class 11 reserves ...DDCD. + TBF[11] class 12 reserves ...DDCD. + TBF[12] class 1 reserves ...C.... + TBF[13] class 2 reserves ...DC... + Successfully allocated 14 UL TBFs +Going to test assignment with many TBF, algorithm B class 1-29 + TBF[0] class 1 reserves ...C.... + TBF[1] class 2 reserves ...DC... + TBF[2] class 3 reserves ...DC... + TBF[3] class 4 reserves ...DCD.. + TBF[4] class 5 reserves ...CD... + TBF[5] class 6 reserves ...DCD.. + TBF[6] class 7 reserves ...DCD.. + TBF[7] class 8 reserves ...DDCD. + TBF[8] class 9 reserves ...DCD.. + TBF[9] class 10 reserves ...DDCD. + TBF[10] class 11 reserves ...DDCD. + TBF[11] class 12 reserves ...DDCD. + TBF[12] class 13 reserves ...CDD.. + TBF[13] class 14 reserves ...CDDD. + TBF[14] class 15 reserves ...CDDDD + TBF[15] class 16 reserves ...CDDDD + TBF[16] class 17 reserves ...CDDDD + TBF[17] class 18 reserves ...DDDCD + Successfully allocated 18 UL TBFs |