Skip to content

Commit

Permalink
mac: split pucch_alloc_harq_sr_csi_test.cpp into multiple files
Browse files Browse the repository at this point in the history
  • Loading branch information
JonPichel authored and codebot committed Dec 18, 2024
1 parent 5ee9b5f commit 87a1ef1
Show file tree
Hide file tree
Showing 5 changed files with 1,957 additions and 1,898 deletions.
2 changes: 2 additions & 0 deletions tests/unittests/scheduler/uci_and_pucch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

add_executable(uci_pucch_sched_test
pucch_alloc_common_harq_test.cpp
pucch_alloc_ded_resources_test.cpp
pucch_alloc_format_0_test.cpp
pucch_alloc_harq_sr_csi_test.cpp
pucch_guardbands_sched_test.cpp
pucch_res_manager_test.cpp
Expand Down
124 changes: 124 additions & 0 deletions tests/unittests/scheduler/uci_and_pucch/pucch_alloc_base_tester.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/*
*
* Copyright 2021-2024 Software Radio Systems Limited
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the distribution.
*
*/

#pragma once

#include "uci_test_utils.h"

using namespace srsran;

class pucch_allocator_base_tester
{
public:
pucch_allocator_base_tester(test_bench_params params_ = test_bench_params{.pucch_res_common = 11, .n_cces = 1},
unsigned max_pucchs_per_slot_ = 32U,
unsigned max_ul_grants_per_slot_ = 32U) :
t_bench(params_, max_pucchs_per_slot_, max_ul_grants_per_slot_){};

protected:
// Parameters that are passed by the routine to run the tests.
test_bench t_bench;
const unsigned pucch_res_idx{0};

// Add a SR grant to the main UE.
void add_sr_grant()
{
t_bench.pucch_alloc.pucch_allocate_sr_opportunity(t_bench.res_grid[t_bench.k0 + t_bench.k1],
t_bench.get_main_ue().crnti,
t_bench.get_main_ue().get_pcell().cfg());
}

// Add a HARQ grant of PUCCH Formats 0/1 (1 bit) to the main UE.
void add_harq_grant()
{
t_bench.pucch_alloc.alloc_ded_pucch_harq_ack_ue(
t_bench.res_grid, t_bench.get_main_ue().crnti, t_bench.get_main_ue().get_pcell().cfg(), t_bench.k0, t_bench.k1);
}

// Add a HARQ grant of PUCCH Formats 2/3/4 (> 2 bits) to the main UE.
std::optional<unsigned> add_format2_3_4_harq_grant()
{
t_bench.pucch_alloc.alloc_ded_pucch_harq_ack_ue(
t_bench.res_grid, t_bench.get_main_ue().crnti, t_bench.get_main_ue().get_pcell().cfg(), t_bench.k0, t_bench.k1);
t_bench.pucch_alloc.alloc_ded_pucch_harq_ack_ue(
t_bench.res_grid, t_bench.get_main_ue().crnti, t_bench.get_main_ue().get_pcell().cfg(), t_bench.k0, t_bench.k1);
return t_bench.pucch_alloc.alloc_ded_pucch_harq_ack_ue(
t_bench.res_grid, t_bench.get_main_ue().crnti, t_bench.get_main_ue().get_pcell().cfg(), t_bench.k0, t_bench.k1);
}

// Add a CSI grant to the main UE.
void add_csi_grant(unsigned csi_part1_bits = 4)
{
t_bench.pucch_alloc.pucch_allocate_csi_opportunity(t_bench.res_grid[t_bench.k0 + t_bench.k1],
t_bench.get_main_ue().crnti,
t_bench.get_main_ue().get_pcell().cfg(),
csi_part1_bits);
}

// Add an extra UE and allocate a HARQ grant to it.
void add_ue_with_harq_grant()
{
t_bench.add_ue();
t_bench.pucch_alloc.alloc_ded_pucch_harq_ack_ue(t_bench.res_grid,
t_bench.last_allocated_rnti,
t_bench.get_ue(t_bench.last_allocated_ue_idx).get_pcell().cfg(),
t_bench.k0,
t_bench.k1);
}

// Add a HARQ grant of PUCCH Formats 2/3/4 (> 2 bits) to the last allocated UE.
void add_harq_f2_3_4_to_last_allocated_ue()
{
t_bench.pucch_alloc.alloc_ded_pucch_harq_ack_ue(t_bench.res_grid,
t_bench.last_allocated_rnti,
t_bench.get_ue(t_bench.last_allocated_ue_idx).get_pcell().cfg(),
t_bench.k0,
t_bench.k1);
t_bench.pucch_alloc.alloc_ded_pucch_harq_ack_ue(t_bench.res_grid,
t_bench.last_allocated_rnti,
t_bench.get_ue(t_bench.last_allocated_ue_idx).get_pcell().cfg(),
t_bench.k0,
t_bench.k1);
t_bench.pucch_alloc.alloc_ded_pucch_harq_ack_ue(t_bench.res_grid,
t_bench.last_allocated_rnti,
t_bench.get_ue(t_bench.last_allocated_ue_idx).get_pcell().cfg(),
t_bench.k0,
t_bench.k1);
}

// Add an extra UE and allocate a HARQ grant of PUCCH Formats 2/3/4 (> 2 bits) to it.
void add_ue_with_format2_harq_grant()
{
t_bench.add_ue();
add_harq_f2_3_4_to_last_allocated_ue();
}

// Add an extra UE and allocate a SR HARQ grant of PUCCH Formats 2/3/4 (> 2 bits) to it.
void add_ue_with_sr_and_harq_f2_3_4()
{
t_bench.add_ue();
t_bench.pucch_alloc.pucch_allocate_sr_opportunity(t_bench.res_grid[t_bench.k0 + t_bench.k1],
t_bench.last_allocated_rnti,
t_bench.get_ue(t_bench.last_allocated_ue_idx).get_pcell().cfg());
add_harq_f2_3_4_to_last_allocated_ue();
}

// Add an extra UE and allocate a CSI HARQ grant of PUCCH Formats 2/3/4 (> 2 bits) to it.
void add_ue_with_csi_and_harq_f2()
{
unsigned csi_part1_bits = 4;
t_bench.add_ue();
t_bench.pucch_alloc.pucch_allocate_csi_opportunity(t_bench.res_grid[t_bench.k0 + t_bench.k1],
t_bench.last_allocated_rnti,
t_bench.get_ue(t_bench.last_allocated_ue_idx).get_pcell().cfg(),
csi_part1_bits);
add_harq_f2_3_4_to_last_allocated_ue();
}
};
Loading

0 comments on commit 87a1ef1

Please sign in to comment.