From 9dcfa8fdb136e0ce3f7877ce22d76e71365508bb Mon Sep 17 00:00:00 2001 From: Francisco Date: Fri, 8 Oct 2021 18:02:10 +0100 Subject: [PATCH] nr,gnb,rrc: pass default rrc_nr_cfg_t to rrc_nr_test --- srsenb/test/rrc/CMakeLists.txt | 4 +-- srsenb/test/rrc/rrc_nr_test.cc | 8 ++--- srsenb/test/rrc/test_helpers.cc | 59 +++++++++++++++++++++------------ srsenb/test/rrc/test_helpers.h | 2 ++ 4 files changed, 45 insertions(+), 28 deletions(-) diff --git a/srsenb/test/rrc/CMakeLists.txt b/srsenb/test/rrc/CMakeLists.txt index 8b440b28c..5cf376160 100644 --- a/srsenb/test/rrc/CMakeLists.txt +++ b/srsenb/test/rrc/CMakeLists.txt @@ -10,8 +10,8 @@ add_library(test_helpers test_helpers.cc) target_link_libraries(test_helpers srsenb_rrc srsenb_common rrc_asn1 rrc_nr_asn1 s1ap_asn1 srsran_common enb_cfg_parser ${LIBCONFIGPP_LIBRARIES}) add_executable(rrc_nr_test rrc_nr_test.cc) -target_link_libraries(rrc_nr_test srsgnb_rrc srsran_common rrc_nr_asn1 ${ATOMIC_LIBS}) -add_test(rrc_nr_test rrc_nr_test) +target_link_libraries(rrc_nr_test srsgnb_rrc test_helpers rrc_nr_asn1 ${ATOMIC_LIBS}) +add_test(rrc_nr_test rrc_nr_test -i ${CMAKE_CURRENT_SOURCE_DIR}/../..) add_executable(rrc_meascfg_test rrc_meascfg_test.cc) target_link_libraries(rrc_meascfg_test test_helpers ${ATOMIC_LIBS}) diff --git a/srsenb/test/rrc/rrc_nr_test.cc b/srsenb/test/rrc/rrc_nr_test.cc index 717f2a643..84e096755 100644 --- a/srsenb/test/rrc/rrc_nr_test.cc +++ b/srsenb/test/rrc/rrc_nr_test.cc @@ -13,6 +13,7 @@ #include "srsenb/hdr/stack/rrc/rrc_nr.h" #include "srsenb/test/common/dummy_classes_common.h" #include "srsenb/test/common/dummy_classes_nr.h" +#include "srsenb/test/rrc/test_helpers.h" #include "srsran/common/test_common.h" #include "srsran/interfaces/gnb_rrc_nr_interfaces.h" #include @@ -75,11 +76,10 @@ int test_rrc_setup() rrc_nr rrc_obj(&task_sched); // set cfg - rrc_nr_cfg_t default_cfg = {}; - rrc_cell_cfg_nr_t cell_cfg = {}; - rrc_nr_cfg_t rrc_cfg_nr = rrc_obj.update_default_cfg(default_cfg); + rrc_cell_cfg_nr_t cell_cfg = {}; + rrc_nr_cfg_t rrc_cfg_nr = rrc_obj.update_default_cfg(rrc_nr_cfg_t{}); + test_helpers::parse_default_cfg(&rrc_cfg_nr); rrc_cfg_nr.cell_list.push_back(cell_cfg); - TESTASSERT(rrc_obj.init(rrc_cfg_nr, &phy_obj, &mac_obj, &rlc_obj, &pdcp_obj, nullptr, nullptr, nullptr) == SRSRAN_SUCCESS); diff --git a/srsenb/test/rrc/test_helpers.cc b/srsenb/test/rrc/test_helpers.cc index a3c890a50..7b1c9e882 100644 --- a/srsenb/test/rrc/test_helpers.cc +++ b/srsenb/test/rrc/test_helpers.cc @@ -46,30 +46,45 @@ int parse_default_cfg_phy(rrc_cfg_t* rrc_cfg, phy_cfg_t* phy_cfg, srsenb::all_ar int parse_default_cfg(rrc_cfg_t* rrc_cfg, srsenb::all_args_t& args) { - args = {}; - *rrc_cfg = {}; - args.enb_files.sib_config = argparse::repository_dir + "/sib.conf.example"; - args.enb_files.rr_config = argparse::repository_dir + "/rr.conf.example"; - args.enb_files.rb_config = argparse::repository_dir + "/rb.conf.example"; - srslog::fetch_basic_logger("TEST").debug("sib file path=%s", args.enb_files.sib_config.c_str()); - - args.enb.enb_id = 0x19B; - args.enb.dl_earfcn = 3400; - args.enb.n_prb = 50; - TESTASSERT(srsran::string_to_mcc("001", &args.stack.s1ap.mcc)); - TESTASSERT(srsran::string_to_mnc("01", &args.stack.s1ap.mnc)); - args.enb.transmission_mode = 1; - args.enb.nof_ports = 1; - args.general.eia_pref_list = "EIA2, EIA1, EIA0"; - args.general.eea_pref_list = "EEA0, EEA2, EEA1"; - args.stack.mac.nof_prealloc_ues = 2; - - args.general.rrc_inactivity_timer = 60000; - - phy_cfg_t phy_cfg; + phy_cfg_t phy_cfg; rrc_nr_cfg_t rrc_cfg_nr; + return parse_default_cfg(&args, rrc_cfg, &phy_cfg, &rrc_cfg_nr); +} - return enb_conf_sections::parse_cfg_files(&args, rrc_cfg, &rrc_cfg_nr, &phy_cfg); +int parse_default_cfg(rrc_nr_cfg_t* rrc_nr_cfg) +{ + srsenb::all_args_t args; + phy_cfg_t phy_cfg; + rrc_cfg_t rrc_cfg; + return parse_default_cfg(&args, &rrc_cfg, &phy_cfg, rrc_nr_cfg); +} + +int parse_default_cfg(srsenb::all_args_t* args, rrc_cfg_t* rrc_cfg, phy_cfg_t* phy_cfg, rrc_nr_cfg_t* rrc_nr_cfg) +{ + *args = {}; + *rrc_cfg = {}; + *phy_cfg = {}; + *rrc_nr_cfg = {}; + + args->enb_files.sib_config = argparse::repository_dir + "/sib.conf.example"; + args->enb_files.rr_config = argparse::repository_dir + "/rr.conf.example"; + args->enb_files.rb_config = argparse::repository_dir + "/rb.conf.example"; + srslog::fetch_basic_logger("TEST").debug("sib file path=%s", args->enb_files.sib_config.c_str()); + + args->enb.enb_id = 0x19B; + args->enb.dl_earfcn = 3400; + args->enb.n_prb = 50; + TESTASSERT(srsran::string_to_mcc("001", &args->stack.s1ap.mcc)); + TESTASSERT(srsran::string_to_mnc("01", &args->stack.s1ap.mnc)); + args->enb.transmission_mode = 1; + args->enb.nof_ports = 1; + args->general.eia_pref_list = "EIA2, EIA1, EIA0"; + args->general.eea_pref_list = "EEA0, EEA2, EEA1"; + args->stack.mac.nof_prealloc_ues = 2; + + args->general.rrc_inactivity_timer = 60000; + + return enb_conf_sections::parse_cfg_files(args, rrc_cfg, rrc_nr_cfg, phy_cfg); } int bring_rrc_to_reconf_state(srsenb::rrc& rrc, srsran::timer_handler& timers, uint16_t rnti) diff --git a/srsenb/test/rrc/test_helpers.h b/srsenb/test/rrc/test_helpers.h index 44d652a96..172194b90 100644 --- a/srsenb/test/rrc/test_helpers.h +++ b/srsenb/test/rrc/test_helpers.h @@ -205,7 +205,9 @@ public: namespace test_helpers { +int parse_default_cfg(srsenb::all_args_t* args, rrc_cfg_t* rrc_cfg, phy_cfg_t* phy_cfg, rrc_nr_cfg_t* rrc_nr_cfg); int parse_default_cfg(rrc_cfg_t* rrc_cfg, srsenb::all_args_t& args); +int parse_default_cfg(rrc_nr_cfg_t* rrc_nr_cfg); int parse_default_cfg_phy(rrc_cfg_t* rrc_cfg, phy_cfg_t* phy_cfg, srsenb::all_args_t& args); template