Moved cp to test common

master
David Rupprecht 3 years ago committed by Andre Puschmann
parent 5999b0d3a5
commit f90e359208

@ -17,6 +17,7 @@
#ifdef __cplusplus
#include "srsran/common/buffer_pool.h"
#include "srsran/common/crash_handler.h"
#include "srsran/common/srsran_assert.h"
#include "srsran/common/standard_streams.h"
@ -141,6 +142,13 @@ inline void test_init(int argc, char** argv)
srslog::init();
}
inline void copy_msg_to_buffer(unique_byte_buffer_t& pdu, const_byte_span msg)
{
pdu = srsran::make_byte_buffer();
memcpy(pdu->msg, msg.data(), msg.size());
pdu->N_bytes = msg.size();
}
} // namespace srsran
#define CONDERROR(cond, fmt, ...) srsran_assert(not(cond), fmt, ##__VA_ARGS__)

@ -11,7 +11,7 @@
*/
#include "sched_nr_sim_ue.h"
#include "lib/include/srsran/common/test_common.h"
#include "srsran/common/test_common.h"
namespace srsenb {

@ -183,10 +183,10 @@ int test_s1ap_mobility(srsran::log_sink_spy& spy, test_event test_params)
/* Receive MeasReport from UE (correct if PCI=2) */
if (test_params == test_event::wrong_measreport) {
uint8_t meas_report[] = {0x08, 0x10, 0x38, 0x74, 0x00, 0x0D, 0xBC, 0x80}; // PCI == 3
test_helpers::copy_msg_to_buffer(pdu, meas_report);
copy_msg_to_buffer(pdu, meas_report);
} else {
uint8_t meas_report[] = {0x08, 0x10, 0x38, 0x74, 0x00, 0x09, 0xBC, 0x80}; // PCI == 2
test_helpers::copy_msg_to_buffer(pdu, meas_report);
copy_msg_to_buffer(pdu, meas_report);
}
tester.rrc.write_pdu(tester.rnti, 1, std::move(pdu));
tester.tic();
@ -203,7 +203,7 @@ int test_s1ap_mobility(srsran::log_sink_spy& spy, test_event test_params)
if (test_params == test_event::concurrent_ho) {
s1ap.last_ho_required = {};
uint8_t meas_report[] = {0x08, 0x10, 0x38, 0x74, 0x00, 0x09, 0xBC, 0x80}; // PCI == 2
test_helpers::copy_msg_to_buffer(pdu, meas_report);
copy_msg_to_buffer(pdu, meas_report);
tester.rrc.write_pdu(tester.rnti, 1, std::move(pdu));
tester.tic();
TESTASSERT(s1ap.last_ho_required.rrc_container == nullptr);
@ -241,7 +241,7 @@ int test_s1ap_mobility(srsran::log_sink_spy& spy, test_event test_params)
0x01, 0x48, 0x04, 0xbc, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x02, 0xa0, 0x07, 0xa0,
0x10, 0x00, 0x01, 0x00, 0x05, 0x00, 0xa7, 0xd0, 0xc1, 0xf6, 0xaf, 0x3e, 0x12, 0xcc,
0x86, 0x0d, 0x30, 0x00, 0x0b, 0x5a, 0x02, 0x17, 0x86, 0x00, 0x05, 0xa0, 0x20};
test_helpers::copy_msg_to_buffer(pdu, ho_cmd_rrc_container);
copy_msg_to_buffer(pdu, ho_cmd_rrc_container);
TESTASSERT(s1ap.last_enb_status.rnti != tester.rnti);
tester.rrc.ho_preparation_complete(tester.rnti, rrc::ho_prep_result::success, asn1::s1ap::ho_cmd_s{}, std::move(pdu));
TESTASSERT(s1ap.last_enb_status.status_present);
@ -381,7 +381,7 @@ int test_s1ap_tenb_mobility(test_event test_params)
tester.rrc.upd_user(0x47, 0x46);
uint8_t recfg_complete[] = {0x10, 0x00};
test_helpers::copy_msg_to_buffer(pdu, recfg_complete);
copy_msg_to_buffer(pdu, recfg_complete);
tester.rrc.write_pdu(0x46, srb_to_lcid(lte_srb::srb1), std::move(pdu));
tester.tic();
TESTASSERT(mac_ue.ue_bearers[srb_to_lcid(lte_srb::srb1)].direction == sched_interface::ue_bearer_cfg_t::BOTH);
@ -421,10 +421,10 @@ int test_intraenb_mobility(srsran::log_sink_spy& spy, test_event test_params)
/* Receive MeasReport from UE (correct if PCI=2) */
if (test_params == test_event::wrong_measreport) {
uint8_t meas_report[] = {0x08, 0x10, 0x38, 0x74, 0x00, 0x0D, 0xBC, 0x80}; // PCI == 3
test_helpers::copy_msg_to_buffer(pdu, meas_report);
copy_msg_to_buffer(pdu, meas_report);
} else {
uint8_t meas_report[] = {0x08, 0x10, 0x38, 0x74, 0x00, 0x09, 0xBC, 0x80}; // PCI == 2
test_helpers::copy_msg_to_buffer(pdu, meas_report);
copy_msg_to_buffer(pdu, meas_report);
}
tester.rrc.write_pdu(tester.rnti, 1, std::move(pdu));
tester.tic();
@ -444,7 +444,7 @@ int test_intraenb_mobility(srsran::log_sink_spy& spy, test_event test_params)
if (test_params == test_event::concurrent_ho) {
tester.pdcp.last_sdu = {};
uint8_t meas_report[] = {0x08, 0x10, 0x38, 0x74, 0x00, 0x09, 0xBC, 0x80}; // PCI == 2
test_helpers::copy_msg_to_buffer(pdu, meas_report);
copy_msg_to_buffer(pdu, meas_report);
tester.rrc.write_pdu(tester.rnti, 1, std::move(pdu));
tester.tic();
TESTASSERT(tester.pdcp.last_sdu.sdu == nullptr);
@ -503,7 +503,7 @@ int test_intraenb_mobility(srsran::log_sink_spy& spy, test_event test_params)
/* Test Case: Terminate first Handover. No extra messages should be sent DL. SR/CQI resources match recfg message */
uint8_t recfg_complete[] = {0x10, 0x00};
test_helpers::copy_msg_to_buffer(pdu, recfg_complete);
copy_msg_to_buffer(pdu, recfg_complete);
tester.rrc.write_pdu(tester.rnti, srb_to_lcid(lte_srb::srb2), std::move(pdu));
TESTASSERT(tester.pdcp.last_sdu.sdu == nullptr);
ue_cfg = &tester.mac.ue_db[tester.rnti];
@ -516,7 +516,7 @@ int test_intraenb_mobility(srsran::log_sink_spy& spy, test_event test_params)
/* Test Case: The RRC should be able to start a new handover */
uint8_t meas_report[] = {0x08, 0x10, 0x38, 0x74, 0x00, 0x05, 0xBC, 0x80}; // PCI == 1
test_helpers::copy_msg_to_buffer(pdu, meas_report);
copy_msg_to_buffer(pdu, meas_report);
tester.rrc.write_pdu(tester.rnti, 1, std::move(pdu));
tester.tic();
TESTASSERT(tester.s1ap.last_ho_required.rrc_container == nullptr);

@ -218,13 +218,6 @@ bool unpack_asn1(ASN1Type& asn1obj, srsran::const_byte_span pdu)
return true;
}
inline void copy_msg_to_buffer(srsran::unique_byte_buffer_t& pdu, srsran::const_byte_span msg)
{
pdu = srsran::make_byte_buffer();
memcpy(pdu->msg, msg.data(), msg.size());
pdu->N_bytes = msg.size();
}
int bring_rrc_to_reconf_state(srsenb::rrc& rrc, srsran::timer_handler& timers, uint16_t rnti);
} // namespace test_helpers

Loading…
Cancel
Save