From 884c1b04d26d09c0654fd93edf358c881e50113e Mon Sep 17 00:00:00 2001 From: Francisco Date: Mon, 15 Mar 2021 18:00:50 +0000 Subject: [PATCH] sched,test - add test to verify cch allocator ability to undo last allocation --- .../mac/sched_phy_ch/sf_cch_allocator.cc | 6 ++- srsenb/test/mac/sched_grid_test.cc | 41 +++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/srsenb/src/stack/mac/sched_phy_ch/sf_cch_allocator.cc b/srsenb/src/stack/mac/sched_phy_ch/sf_cch_allocator.cc index ece42ed12..5c0859c75 100644 --- a/srsenb/src/stack/mac/sched_phy_ch/sf_cch_allocator.cc +++ b/srsenb/src/stack/mac/sched_phy_ch/sf_cch_allocator.cc @@ -108,9 +108,11 @@ void sf_cch_allocator::rem_last_dci() tree.prev_start = tree.dci_alloc_tree[tree.prev_start].parent_idx; // Discover other tree nodes with same level while (tree.prev_start > 0) { - uint32_t count = 0; - while (tree.dci_alloc_tree[tree.prev_start - 1].parent_idx >= 0) { + uint32_t count = 1; + int parent_idx = tree.dci_alloc_tree[tree.prev_start - 1].parent_idx; + while (parent_idx >= 0) { count++; + parent_idx = tree.dci_alloc_tree[parent_idx].parent_idx; } if (count == dci_record_list.size()) { tree.prev_start--; diff --git a/srsenb/test/mac/sched_grid_test.cc b/srsenb/test/mac/sched_grid_test.cc index 412a344ac..1e3be7269 100644 --- a/srsenb/test/mac/sched_grid_test.cc +++ b/srsenb/test/mac/sched_grid_test.cc @@ -131,6 +131,46 @@ int test_pdcch_one_ue() return SRSLTE_SUCCESS; } +int test_pdcch_ue_and_sibs() +{ + const uint32_t ENB_CC_IDX = 0; + // Params + uint32_t nof_prb = 100; + + std::vector cell_params(1); + sched_interface::ue_cfg_t ue_cfg = generate_default_ue_cfg(); + sched_interface::cell_cfg_t cell_cfg = generate_default_cell_cfg(nof_prb); + sched_interface::sched_args_t sched_args{}; + TESTASSERT(cell_params[0].set_cfg(0, cell_cfg, sched_args)); + + sf_cch_allocator pdcch; + sched_ue sched_ue{0x46, cell_params, ue_cfg}; + + pdcch.init(cell_params[PCell_IDX]); + TESTASSERT(pdcch.nof_alloc_combinations() == 0); + TESTASSERT(pdcch.nof_allocs() == 0); + + tti_point tti_rx{0}; + + pdcch.new_tti(tti_rx); + TESTASSERT(pdcch.nof_cces() == cell_params[0].nof_cce_table[0]); + TESTASSERT(pdcch.get_cfi() == 1); // Start at CFI=1 + TESTASSERT(pdcch.nof_alloc_combinations() == 0); + + TESTASSERT(pdcch.alloc_dci(alloc_type_t::DL_BC, 2)); + TESTASSERT(pdcch.nof_alloc_combinations() == 4); + TESTASSERT(pdcch.alloc_dci(alloc_type_t::DL_RAR, 2)); + TESTASSERT(pdcch.nof_allocs() == 2 and pdcch.nof_alloc_combinations() == 6); + TESTASSERT(pdcch.alloc_dci(alloc_type_t::DL_DATA, 2, &sched_ue, false)); + TESTASSERT(pdcch.nof_allocs() == 3 and pdcch.nof_alloc_combinations() == 4); + + // TEST: Ability to revert last allocation + pdcch.rem_last_dci(); + TESTASSERT(pdcch.nof_allocs() == 2 and pdcch.nof_alloc_combinations() == 6); + + return SRSLTE_SUCCESS; +} + int main() { srsenb::set_randseed(seed); @@ -143,6 +183,7 @@ int main() srslog::init(); TESTASSERT(test_pdcch_one_ue() == SRSLTE_SUCCESS); + TESTASSERT(test_pdcch_ue_and_sibs() == SRSLTE_SUCCESS); srslog::flush();