add rrc nr test

master
Francisco Paisana 5 years ago
parent 613003ac53
commit cea2fe797d

@ -21,6 +21,7 @@
add_subdirectory(mac)
add_subdirectory(phy)
add_subdirectory(upper)
add_subdirectory(rrc)
add_executable(enb_metrics_test enb_metrics_test.cc ../src/metrics_stdout.cc ../src/metrics_csv.cc)
target_link_libraries(enb_metrics_test srslte_phy srslte_common)

@ -0,0 +1,69 @@
/*
* Copyright 2013-2020 Software Radio Systems Limited
*
* This file is part of srsLTE.
*
* srsLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#ifndef SRSLTE_DUMMY_NR_CLASSES_H
#define SRSLTE_DUMMY_NR_CLASSES_H
#include "srslte/interfaces/gnb_interfaces.h"
namespace srsenb {
class mac_dummy : public mac_interface_rrc_nr
{
public:
int cell_cfg(srsenb::sched_interface::cell_cfg_t* cell_cfg_)
{
cellcfgobj = *cell_cfg_;
return SRSLTE_SUCCESS;
}
srsenb::sched_interface::cell_cfg_t cellcfgobj;
};
class rlc_dummy : public rlc_interface_rrc_nr
{
public:
void clear_buffer(uint16_t rnti) override {}
void add_user(uint16_t rnti) override {}
void rem_user(uint16_t rnti) override {}
void add_bearer(uint16_t rnti, uint32_t lcid, srslte::rlc_config_t cnfg) override {}
void add_bearer_mrb(uint16_t rnti, uint32_t lcid) override {}
void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) override { last_sdu = std::move(sdu); }
srslte::unique_byte_buffer_t last_sdu;
};
class pdcp_dummy : public pdcp_interface_rrc_nr
{
public:
void reset(uint16_t rnti) override {}
void add_user(uint16_t rnti) override {}
void rem_user(uint16_t rnti) override {}
void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) override {}
void add_bearer(uint16_t rnti, uint32_t lcid, srslte::pdcp_config_t cnfg) override {}
void config_security(uint16_t rnti, uint32_t lcid, srslte::as_security_config_t sec_cfg) override {}
void enable_integrity(uint16_t rnti, uint32_t lcid) override {}
void enable_encryption(uint16_t rnti, uint32_t lcid) override {}
};
} // namespace srsenb
#endif // SRSLTE_DUMMY_NR_CLASSES_H

@ -0,0 +1,25 @@
#
# Copyright 2013-2020 Software Radio Systems Limited
#
# This file is part of srsLTE
#
# srsLTE is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# srsLTE is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# A copy of the GNU Affero General Public License can be found in
# the LICENSE file in the top-level directory of this distribution
# and at http://www.gnu.org/licenses/.
#
if (ENABLE_5GNR)
add_executable(rrc_nr_test rrc_nr_test.cc)
target_link_libraries(rrc_nr_test srsgnb_rrc srslte_common rrc_nr_asn1)
add_test(rrc_nr_test rrc_nr_test)
endif ()

@ -0,0 +1,115 @@
/*
* Copyright 2013-2019 Software Radio Systems Limited
*
* This file is part of srsLTE.
*
* srsLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#include "srsenb/hdr/stack/rrc/rrc_nr.h"
#include "srsenb/test/common/dummy_nr_classes.h"
#include "srslte/common/log_filter.h"
#include <iostream>
#define TESTASSERT(cond) \
{ \
if (!(cond)) { \
std::cout << "[" << __FUNCTION__ << "][Line " << __LINE__ << "]: FAIL at " << (#cond) << std::endl; \
return -1; \
} \
}
using namespace asn1::rrc_nr;
namespace srsenb {
int test_cell_cfg(const srsenb::sched_interface::cell_cfg_t& cellcfg)
{
// SIB1 must exist and have period 16rf
TESTASSERT(cellcfg.sibs[0].len > 0);
TESTASSERT(cellcfg.sibs[0].period_rf == 16);
TESTASSERT(cellcfg.si_window_ms > 0);
return SRSLTE_SUCCESS;
}
/*
* Test 1 - Test default SIB generation
* Description: Check whether the SIBs were set correctly
*/
int test_sib_generation()
{
srslte::logger_stdout logger;
srslte::timer_handler timers_db(128);
mac_dummy mac_obj;
rlc_dummy rlc_obj;
pdcp_dummy pdcp_obj;
rrc_nr rrc_obj(&timers_db);
// set cfg
rrc_nr_cfg_t default_cfg = {};
rrc_nr_cfg_t rrc_cfg = rrc_obj.update_default_cfg(default_cfg);
auto& sched_elem = rrc_cfg.sib1.si_sched_info.sched_info_list[0];
rrc_obj.init(rrc_cfg, nullptr, &mac_obj, &rlc_obj, &pdcp_obj, nullptr, nullptr);
TESTASSERT(test_cell_cfg(mac_obj.cellcfgobj) == SRSLTE_SUCCESS)
// TEMP tests
TESTASSERT(mac_obj.cellcfgobj.sibs[1].len > 0)
TESTASSERT(mac_obj.cellcfgobj.sibs[1].period_rf == sched_elem.si_periodicity.to_number())
for (int i = 2; i < 16; ++i) {
TESTASSERT(mac_obj.cellcfgobj.sibs[i].len == 0)
}
TESTASSERT(mac_obj.cellcfgobj.cell.nof_prb == 25)
return SRSLTE_SUCCESS;
}
int test_rrc_setup()
{
srslte::logger_stdout logger;
srslte::timer_handler timers_db(128);
mac_dummy mac_obj;
rlc_dummy rlc_obj;
pdcp_dummy pdcp_obj;
rrc_nr rrc_obj(&timers_db);
// set cfg
rrc_nr_cfg_t default_cfg = {};
rrc_nr_cfg_t rrc_cfg = rrc_obj.update_default_cfg(default_cfg);
rrc_obj.init(rrc_cfg, nullptr, &mac_obj, &rlc_obj, &pdcp_obj, nullptr, nullptr);
for (uint32_t n = 0; n < 2; ++n) {
uint32_t timeout = 5500;
for (uint32_t i = 0; i < timeout and rlc_obj.last_sdu == nullptr; ++i) {
timers_db.step_all();
}
TESTASSERT(rlc_obj.last_sdu != nullptr);
}
return SRSLTE_SUCCESS;
}
} // namespace srsenb
int main()
{
TESTASSERT(srsenb::test_sib_generation() == SRSLTE_SUCCESS);
TESTASSERT(srsenb::test_rrc_setup() == SRSLTE_SUCCESS);
return 0;
}
Loading…
Cancel
Save