Skip to content

Commit 0d3b162

Browse files
committed
du_manager: fix failing unit test regarding allocation of SR resources
1 parent 3203e6a commit 0d3b162

File tree

1 file changed

+32
-15
lines changed

1 file changed

+32
-15
lines changed

tests/unittests/du_manager/du_ran_resource_manager_test.cpp

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,27 @@ class du_ran_resource_manager_tester : public ::testing::TestWithParam<params>
5252
return sr_periodicity_to_slot(default_ue_cell_cfg.ul_config->init_ul_bwp.pucch_cfg->sr_res_list[0].period);
5353
}
5454

55+
unsigned get_nof_sr_slot_offsets() const
56+
{
57+
const unsigned slots_per_frame = NOF_SUBFRAMES_PER_FRAME * get_nof_slots_per_subframe(cell_cfg_list[0].scs_common);
58+
const auto& sr_res_list = default_ue_cell_cfg.ul_config->init_ul_bwp.pucch_cfg->sr_res_list;
59+
unsigned nof_offsets = 0;
60+
for (unsigned i = 0; i != sr_res_list.size(); ++i) {
61+
unsigned sr_period_slots = sr_periodicity_to_slot(sr_res_list[i].period);
62+
if (cell_cfg_list[0].tdd_ul_dl_cfg_common.has_value()) {
63+
for (unsigned j = 0; j != sr_period_slots; ++j) {
64+
if (has_active_tdd_ul_symbols(*cell_cfg_list[0].tdd_ul_dl_cfg_common, j % slots_per_frame)) {
65+
nof_offsets++;
66+
}
67+
}
68+
} else {
69+
nof_offsets += sr_period_slots;
70+
}
71+
}
72+
// Note: right now we are using two PUCCH resources for SR.
73+
return nof_offsets * 2;
74+
}
75+
5576
std::vector<du_cell_config> cell_cfg_list;
5677
std::map<uint8_t, du_qos_config> qos_cfg_list;
5778
const serving_cell_config default_ue_cell_cfg;
@@ -89,18 +110,10 @@ TEST_P(du_ran_resource_manager_tester, when_srb1_is_added_then_ue_resource_confi
89110

90111
TEST_P(du_ran_resource_manager_tester, when_multiple_ues_are_created_then_they_use_different_sr_offsets)
91112
{
92-
unsigned sr_period = get_config_sr_period();
93-
unsigned slots_per_frame = NOF_SUBFRAMES_PER_FRAME * get_nof_slots_per_subframe(cell_cfg_list[0].scs_common);
94-
unsigned nof_avail_sr_offsets = sr_period * 2;
95-
if (cell_cfg_list[0].tdd_ul_dl_cfg_common.has_value()) {
96-
nof_avail_sr_offsets = 0;
97-
for (unsigned i = 0; i != sr_period; ++i) {
98-
if (has_active_tdd_ul_symbols(*cell_cfg_list[0].tdd_ul_dl_cfg_common, i % slots_per_frame)) {
99-
nof_avail_sr_offsets += 2;
100-
}
101-
}
102-
}
103-
du_ue_index_t next_ue_index = to_du_ue_index(0);
113+
unsigned sr_period = get_config_sr_period();
114+
unsigned slots_per_frame = NOF_SUBFRAMES_PER_FRAME * get_nof_slots_per_subframe(cell_cfg_list[0].scs_common);
115+
unsigned nof_avail_sr_offsets = this->get_nof_sr_slot_offsets();
116+
du_ue_index_t next_ue_index = to_du_ue_index(0);
104117

105118
// > Created UEs have unique (PUCCH resource, SR offset) pairs.
106119
std::set<std::pair<unsigned, unsigned>> sr_offsets;
@@ -123,17 +136,21 @@ TEST_P(du_ran_resource_manager_tester, when_multiple_ues_are_created_then_they_u
123136
// > No more SR offsets available. UE Resource Allocation fails.
124137
ue_ran_resource_configurator& empty_ue_res = create_ue(next_ue_index);
125138
ASSERT_TRUE(empty_ue_res.empty());
126-
ues.erase(to_du_ue_index(sr_period));
139+
ues.erase(next_ue_index);
127140
}
128141

129142
// Removing one UE, should make one SR offset available.
130-
du_ue_index_t ue_idx_to_rem = to_du_ue_index(test_rgen::uniform_int<unsigned>(0, nof_avail_sr_offsets - 1));
131-
unsigned rem_sr_offset =
143+
du_ue_index_t ue_idx_to_rem = to_du_ue_index(test_rgen::uniform_int<unsigned>(0, ues.size() - 1));
144+
unsigned rem_pucch_resource =
145+
ues[ue_idx_to_rem]->cells[0].serv_cell_cfg.ul_config->init_ul_bwp.pucch_cfg->sr_res_list[0].pucch_res_id;
146+
unsigned rem_sr_offset =
132147
ues[ue_idx_to_rem]->cells[0].serv_cell_cfg.ul_config->init_ul_bwp.pucch_cfg->sr_res_list[0].offset;
133148
ues.erase(ue_idx_to_rem);
134149
next_ue_index = to_du_ue_index((unsigned)next_ue_index + 1);
135150
ue_ran_resource_configurator& ue_res = create_ue(next_ue_index);
136151
ASSERT_FALSE(ue_res.empty());
152+
ASSERT_EQ(rem_pucch_resource,
153+
ue_res->cells[0].serv_cell_cfg.ul_config->init_ul_bwp.pucch_cfg->sr_res_list[0].pucch_res_id);
137154
ASSERT_EQ(rem_sr_offset, ue_res->cells[0].serv_cell_cfg.ul_config->init_ul_bwp.pucch_cfg->sr_res_list[0].offset);
138155
}
139156

0 commit comments

Comments
 (0)