diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2021-03-12 17:50:10 +0100 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2021-03-15 19:36:27 +0100 |
commit | 95f8fa1f7c1b5e0c313535915b8d62e633ef1cb5 (patch) | |
tree | f7ee117c94fb46bdad666f381a9931db3cc1f4a3 /tests/ulc/PdchUlcTest.cpp | |
parent | 582a15e413dd116a17afe4aed5b8811345f5667d (diff) |
tests: ulc: Show current bug with FN wrap around
Issue will be fixed in next commit. Leaving ASSERTs disabled so that
test passes in jenkins.
Related: OS#5020
Change-Id: I657db6b300363f8f3a9e4cfaf7a7f49e361a0512
Diffstat (limited to 'tests/ulc/PdchUlcTest.cpp')
-rw-r--r-- | tests/ulc/PdchUlcTest.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/ulc/PdchUlcTest.cpp b/tests/ulc/PdchUlcTest.cpp index 7e2bbdd6..320a7bff 100644 --- a/tests/ulc/PdchUlcTest.cpp +++ b/tests/ulc/PdchUlcTest.cpp @@ -20,6 +20,9 @@ #include <string.h> #include <stdio.h> +#include <stdint.h> +#include <unistd.h> +#include <inttypes.h> extern "C" { #include <osmocom/core/application.h> @@ -28,6 +31,7 @@ extern "C" { #include <osmocom/core/utils.h> } +#include "gprs_ms.h" #include "bts.h" #include "sba.h" #include "pdch_ul_controller.h" @@ -35,6 +39,16 @@ extern "C" { /* globals used by the code */ void *tall_pcu_ctx; +static void print_ulc_nodes(struct pdch_ulc *ulc) +{ + struct rb_node *node; + for (node = rb_first(&ulc->tree_root); node; node = rb_next(node)) { + struct pdch_ulc_node *it = container_of(node, struct pdch_ulc_node, node); + printf("FN=%" PRIu32 " type=%s\n", + it->fn, get_value_string(pdch_ul_node_names, it->type)); + } +} + static void test_reserve_multiple() { printf("=== start: %s ===\n", __FUNCTION__); @@ -143,6 +157,61 @@ static void test_reserve_multiple() printf("=== end: %s ===\n", __FUNCTION__); } +int _alloc_algorithm_dummy(struct gprs_rlcmac_bts *bts, struct gprs_rlcmac_tbf *tbf, + bool single, int8_t use_tbf) +{ + return 0; +} + + +static void test_fn_wrap_around() +{ + printf("=== start: %s ===\n", __FUNCTION__); + const uint32_t start_fn = GSM_MAX_FN - 40; + + the_pcu->alloc_algorithm = _alloc_algorithm_dummy; + + struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); + struct GprsMs *ms = ms_alloc(bts, 0x12345678); + struct gprs_rlcmac_tbf *tbf1 = tbf_alloc_dl_tbf(bts, ms, 0, true); + tbf1->trx = &bts->trx[0]; + struct gprs_rlcmac_pdch *pdch = &tbf1->trx->pdch[0]; + int rc; + uint32_t fn, last_fn; + + fn = start_fn; + while (fn < 40 || fn >= start_fn) { + printf("*** RESERVE FN=%" PRIu32 ":\n", fn); + rc = pdch_ulc_reserve_tbf_poll(pdch->ulc, fn, tbf1); + OSMO_ASSERT(rc == 0); + print_ulc_nodes(pdch->ulc); + fn = fn_next_block(fn); + } + last_fn = fn; + + /* Expiring fn_next_block(start_fn) should only expire first 2 entries here: */ + fn = fn_next_block(start_fn); + printf("*** EXPIRE FN=%" PRIu32 ":\n", fn); + pdch_ulc_expire_fn(pdch->ulc, fn); + print_ulc_nodes(pdch->ulc); + + /* We should still be able to release FN=0 here, since it came later: */ + printf("*** RELEASE fn=%" PRIu32 ":\n", 0); + rc = pdch_ulc_release_fn(pdch->ulc, 0); + print_ulc_nodes(pdch->ulc); + //OSMO_ASSERT(rc == 0); FIXME: DISABLED DUE TO BUG! + + /* Expiring last FN should expire all entries */ + printf("*** EXPIRE FN=%" PRIu32 ":\n", last_fn); + pdch_ulc_expire_fn(pdch->ulc, last_fn); + print_ulc_nodes(pdch->ulc); + /* Make sure the store is empty now: */ + //OSMO_ASSERT(!rb_first(&pdch->ulc->tree_root)); FIXME: DISABLED DUE TO BUG! + + talloc_free(bts); + printf("=== end: %s ===\n", __FUNCTION__); +} + int main(int argc, char **argv) { tall_pcu_ctx = talloc_named_const(NULL, 1, "pdch_ulc test context"); @@ -161,6 +230,7 @@ int main(int argc, char **argv) the_pcu = gprs_pcu_alloc(tall_pcu_ctx); test_reserve_multiple(); + test_fn_wrap_around(); talloc_free(the_pcu); return EXIT_SUCCESS; |