Skip to content

Commit 78aa129

Browse files
frankistcodebot
authored andcommitted
sched: fix uninitialized values in unit tests
1 parent 06c2005 commit 78aa129

File tree

11 files changed

+93
-15
lines changed

11 files changed

+93
-15
lines changed

include/srsran/du/du_cell_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "srsran/ran/nr_cgi.h"
1515
#include "srsran/ran/pci.h"
1616
#include "srsran/ran/ssb_configuration.h"
17-
#include "srsran/ran/tdd_ul_dl_config.h"
17+
#include "srsran/ran/tdd/tdd_ul_dl_config.h"
1818
#include "srsran/scheduler/config/bwp_configuration.h"
1919
#include "srsran/scheduler/config/serving_cell_config.h"
2020

include/srsran/du/du_cell_config_helpers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "srsran/ran/five_qi.h"
1717
#include "srsran/ran/nr_cgi_helpers.h"
1818
#include "srsran/ran/pdcch/pdcch_type0_css_coreset_config.h"
19-
#include "srsran/ran/tdd_ul_dl_config.h"
19+
#include "srsran/ran/tdd/tdd_ul_dl_config.h"
2020
#include "srsran/scheduler/config/cell_config_builder_params.h"
2121
#include "srsran/scheduler/config/scheduler_expert_config.h"
2222
#include "srsran/scheduler/config/serving_cell_config_factory.h"
File renamed without changes.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
*
3+
* Copyright 2021-2023 Software Radio Systems Limited
4+
*
5+
* By using this file, you agree to the terms and conditions set
6+
* forth in the LICENSE file which can be found at the top level of
7+
* the distribution.
8+
*
9+
*/
10+
11+
#pragma once
12+
13+
#include "srsran/ran/tdd/tdd_ul_dl_config.h"
14+
#include "srsran/support/format_utils.h"
15+
16+
namespace fmt {
17+
18+
template <>
19+
struct formatter<srsran::tdd_ul_dl_pattern> : public basic_fmt_parser {
20+
template <typename FormatContext>
21+
auto format(const srsran::tdd_ul_dl_pattern& cfg, FormatContext& ctx)
22+
{
23+
return format_to(ctx.out(),
24+
"period={} dl_slots={} dl_symbols={} ul_slots={} ul_symbols={}",
25+
cfg.dl_ul_tx_period_nof_slots,
26+
cfg.nof_dl_slots,
27+
cfg.nof_dl_symbols,
28+
cfg.nof_ul_slots,
29+
cfg.nof_ul_symbols);
30+
}
31+
};
32+
33+
template <>
34+
struct formatter<srsran::tdd_ul_dl_config_common> : public basic_fmt_parser {
35+
template <typename FormatContext>
36+
auto format(const srsran::tdd_ul_dl_config_common& cfg, FormatContext& ctx)
37+
{
38+
return format_to(ctx.out(), "scs={} pattern1={{{}}} pattern2={{{}}}", cfg.ref_scs, cfg.pattern1, cfg.pattern2);
39+
}
40+
};
41+
42+
} // namespace fmt

include/srsran/scheduler/config/serving_cell_config_factory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "serving_cell_config.h"
1515
#include "srsran/ran/csi_rs/csi_meas_config.h"
1616
#include "srsran/ran/pdcch/aggregation_level.h"
17-
#include "srsran/ran/tdd_ul_dl_config.h"
17+
#include "srsran/ran/tdd/tdd_ul_dl_config.h"
1818

1919
namespace srsran {
2020
namespace config_helpers {

include/srsran/scheduler/scheduler_configurator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "srsran/ran/sr_configuration.h"
2525
#include "srsran/ran/ssb_configuration.h"
2626
#include "srsran/ran/subcarrier_spacing.h"
27-
#include "srsran/ran/tdd_ul_dl_config.h"
27+
#include "srsran/ran/tdd/tdd_ul_dl_config.h"
2828
#include "srsran/scheduler/config/bwp_configuration.h"
2929
#include "srsran/scheduler/config/dmrs.h"
3030
#include "srsran/scheduler/config/logical_channel_config.h"

lib/ran/prach/prach_helper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "srsran/ran/prach/prach_helper.h"
1212
#include "srsran/ran/prach/prach_configuration.h"
1313
#include "srsran/ran/prach/prach_preamble_information.h"
14-
#include "srsran/ran/tdd_ul_dl_config.h"
14+
#include "srsran/ran/tdd/tdd_ul_dl_config.h"
1515

1616
using namespace srsran;
1717

lib/ran/tdd_ul_dl_config.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*/
1010

11-
#include "srsran/ran/tdd_ul_dl_config.h"
11+
#include "srsran/ran/tdd/tdd_ul_dl_config.h"
1212
#include "srsran/ran/frame_types.h"
1313

1414
using namespace srsran;

lib/scheduler/ue_scheduling/harq_process.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ void detail::harq_process<IsDownlink>::slot_indication(slot_point slot_tx)
8080
logger.warning(id,
8181
"Discarding HARQ. Cause: HARQ-ACK wait timeout ({} slots) was reached without a HARQ-ACK report "
8282
"being received and the maximum number of reTxs {} was exceeded",
83-
max_nof_harq_retxs(0),
84-
ack_wait_in_slots);
83+
ack_wait_in_slots,
84+
max_nof_harq_retxs(0));
8585
} else {
8686
logger.debug(id,
8787
"Discarding HARQ. Cause: HARQ-ACK wait timeout ({} slots) was reached but only invalid HARQ-ACKs "
8888
"were received and the maximum number of reTxs {} was exceeded",
89-
max_nof_harq_retxs(0),
90-
ack_wait_in_slots);
89+
ack_wait_in_slots,
90+
max_nof_harq_retxs(0));
9191
}
9292
}
9393
// Reset the ACK wait time.
@@ -265,6 +265,7 @@ void ul_harq_process::new_tx(slot_point pusch_slot, unsigned max_harq_retxs)
265265
harq_process::tx_common(pusch_slot, pusch_slot);
266266
// Note: For UL, DAI is not used, so we set it to zero.
267267
base_type::new_tx_tb_common(0, max_harq_retxs, 0);
268+
prev_tx_params = {};
268269
}
269270

270271
void ul_harq_process::new_retx(slot_point pusch_slot)

tests/unittests/scheduler/scheduler_retx_test.cpp

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ struct test_params {
8383
unsigned nof_retxs = 0;
8484
};
8585

86+
/// Formatter for test params.
87+
void PrintTo(const test_params& value, ::std::ostream* os)
88+
{
89+
*os << fmt::format("nof_retx={}", value.nof_retxs);
90+
}
91+
8692
class scheduler_retx_tester : public base_scheduler_retx_tester, public ::testing::TestWithParam<test_params>
8793
{};
8894

@@ -135,11 +141,14 @@ TEST_P(scheduler_retx_tester, msg3_gets_retx_if_nacked)
135141
}
136142

137143
class scheduler_missing_ack_tester : public base_scheduler_retx_tester, public ::testing::Test
138-
{};
144+
{
145+
protected:
146+
static const unsigned MAX_HARQ_TIMEOUT = 256;
147+
};
139148

140149
TEST_F(scheduler_missing_ack_tester, when_no_harq_ack_arrives_then_harq_eventually_becomes_available)
141150
{
142-
static constexpr unsigned nof_harqs = 8;
151+
static constexpr unsigned nof_harqs = 16;
143152
static constexpr rnti_t rnti = to_rnti(0x4601);
144153
sched_ue_creation_request_message ue_create_req = test_helpers::create_default_sched_ue_creation_request();
145154
ue_create_req.crnti = rnti;
@@ -158,19 +167,25 @@ TEST_F(scheduler_missing_ack_tester, when_no_harq_ack_arrives_then_harq_eventual
158167
}
159168

160169
// Set buffer state to zero, so that no newtxs get allocated once the current harqs become empty.
170+
srslog::fetch_basic_logger("TEST").info("-- Setting DL BS=0, which will stop new DL grants --");
161171
bench.push_dl_buffer_state(dl_buffer_state_indication_message{ue_create_req.ue_index, LCID_SRB1, 0});
162172
bench.run_slot(to_du_cell_index(0));
163173
ASSERT_EQ(bench.find_ue_dl_pdcch(rnti), nullptr) << "No HARQs should be available at this point";
164174

165175
// After several slots without HARQ-ACK, the HARQ should auto retx.
166-
const unsigned MAX_HARQ_TIMEOUT = 10240, MAX_TEST_COUNT = 256;
176+
srslog::fetch_basic_logger("TEST").info("-- DL HARQs should be auto-retransmitted --");
177+
const unsigned MAX_TEST_COUNT = nof_harqs * 8;
178+
unsigned nof_retxs = 0;
167179
for (unsigned i = 0; i != MAX_TEST_COUNT; ++i) {
168180
const pdcch_dl_information* pdcch = this->run_until_next_dl_pdcch_alloc(MAX_HARQ_TIMEOUT);
169181
if (pdcch == nullptr) {
170182
// All HARQs should be reset at this point.
171183
break;
172184
}
185+
nof_retxs++;
173186
}
187+
ASSERT_GT(nof_retxs, 0);
188+
ASSERT_TRUE(nof_retxs % nof_harqs == 0) << "All HARQs should have expired at this point";
174189

175190
// At this point, all HARQs should be free once again. Push enough bytes and verify that all HARQs get re-allocated.
176191
bench.push_dl_buffer_state(dl_buffer_state_indication_message{ue_create_req.ue_index, LCID_SRB1, 10000000});
@@ -182,7 +197,7 @@ TEST_F(scheduler_missing_ack_tester, when_no_harq_ack_arrives_then_harq_eventual
182197

183198
TEST_F(scheduler_missing_ack_tester, when_no_crc_arrives_then_ul_harq_eventually_becomes_available)
184199
{
185-
static constexpr unsigned nof_harqs = 8;
200+
static constexpr unsigned nof_harqs = 16;
186201
static constexpr rnti_t rnti = to_rnti(0x4601);
187202
sched_ue_creation_request_message ue_create_req = test_helpers::create_default_sched_ue_creation_request();
188203
ue_create_req.crnti = rnti;
@@ -204,22 +219,29 @@ TEST_F(scheduler_missing_ack_tester, when_no_crc_arrives_then_ul_harq_eventually
204219
}
205220

206221
// Set buffer state to zero, so that no newtxs get allocated once the current harqs become empty.
222+
srslog::fetch_basic_logger("TEST").info("-- Setting BSR=0, which will stop new UL grants --");
207223
bsr.reported_lcgs[0].nof_bytes = 0;
208224
bench.push_bsr(bsr);
209225
bench.run_slot(to_du_cell_index(0));
210226
ASSERT_EQ(bench.find_ue_ul_pdcch(rnti), nullptr) << "No HARQs should be available at this point";
211227

212228
// After several slots without HARQ-ACK, the HARQ should auto retx.
213-
const unsigned MAX_HARQ_TIMEOUT = 32, MAX_TEST_COUNT = 10000;
229+
srslog::fetch_basic_logger("TEST").info("-- UL HARQs should be auto-retransmitted --");
230+
const unsigned MAX_TEST_COUNT = nof_harqs * 8;
231+
unsigned nof_retxs = 0;
214232
for (unsigned i = 0; i != MAX_TEST_COUNT; ++i) {
215233
const pdcch_ul_information* pdcch = this->run_until_next_ul_pdcch_alloc(MAX_HARQ_TIMEOUT);
216234
if (pdcch == nullptr) {
217235
// All HARQs should be reset at this point.
218236
break;
219237
}
238+
nof_retxs++;
220239
}
240+
ASSERT_GT(nof_retxs, 0);
241+
ASSERT_TRUE(nof_retxs % nof_harqs == 0) << "All HARQs should have expired at this point";
221242

222243
// At this point, all HARQs should be free once again. Push enough bytes and verify that all HARQs get re-allocated.
244+
srslog::fetch_basic_logger("TEST").info("-- Pushing BSR > 0 and ensuring HARQs get reallocated. --");
223245
bsr.reported_lcgs[0].nof_bytes = 100000000;
224246
bench.push_bsr(bsr);
225247
for (unsigned i = 0; i != nof_harqs; ++i) {

0 commit comments

Comments
 (0)