mirror of https://github.com/pvnis/srsRAN_4G.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
98 lines
4.0 KiB
C++
98 lines
4.0 KiB
C++
4 years ago
|
/**
|
||
7 years ago
|
*
|
||
4 years ago
|
* \section COPYRIGHT
|
||
7 years ago
|
*
|
||
4 years ago
|
* Copyright 2013-2021 Software Radio Systems Limited
|
||
7 years ago
|
*
|
||
4 years ago
|
* 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.
|
||
7 years ago
|
*
|
||
|
*/
|
||
|
|
||
4 years ago
|
#include "srsran/asn1/rrc/ul_dcch_msg.h"
|
||
|
#include "srsran/asn1/rrc_utils.h"
|
||
|
#include "srsran/common/bcd_helpers.h"
|
||
|
#include "srsran/interfaces/rrc_interface_types.h"
|
||
7 years ago
|
#include <iostream>
|
||
|
|
||
6 years ago
|
#define TESTASSERT(cond) \
|
||
|
{ \
|
||
|
if (!(cond)) { \
|
||
|
std::cout << "[" << __FUNCTION__ << "][Line " << __LINE__ << "]: FAIL at " << (#cond) << std::endl; \
|
||
|
return -1; \
|
||
|
} \
|
||
|
}
|
||
|
|
||
|
using namespace asn1;
|
||
|
using namespace asn1::rrc;
|
||
7 years ago
|
|
||
5 years ago
|
int meas_obj_test()
|
||
6 years ago
|
{
|
||
5 years ago
|
uint8_t rrc_msg[] = {
|
||
|
0x08, 0x10, 0x49, 0x3C, 0x0D, 0x97, 0x89, 0x83, 0xC0, 0x84, 0x20, 0x82, 0x08, 0x21, 0x00, 0x01, 0xBC, 0x48};
|
||
6 years ago
|
uint32_t rrc_msg_len = sizeof(rrc_msg);
|
||
|
// 0810493C0D978983C084208208210001BC48
|
||
7 years ago
|
|
||
5 years ago
|
cbit_ref bref(&rrc_msg[0], sizeof(rrc_msg));
|
||
7 years ago
|
|
||
6 years ago
|
ul_dcch_msg_s ul_dcch_msg;
|
||
|
ul_dcch_msg.unpack(bref);
|
||
7 years ago
|
|
||
6 years ago
|
TESTASSERT(ul_dcch_msg.msg.type() == ul_dcch_msg_type_c::types::c1);
|
||
|
TESTASSERT(ul_dcch_msg.msg.c1().type() == ul_dcch_msg_type_c::c1_c_::types::meas_report);
|
||
7 years ago
|
|
||
6 years ago
|
meas_report_s* rep = &ul_dcch_msg.msg.c1().meas_report();
|
||
|
TESTASSERT(rep->crit_exts.type() == meas_report_s::crit_exts_c_::types::c1);
|
||
|
TESTASSERT(rep->crit_exts.c1().type() == meas_report_s::crit_exts_c_::c1_c_::types::meas_report_r8);
|
||
|
TESTASSERT(not rep->crit_exts.c1().meas_report_r8().non_crit_ext_present);
|
||
|
meas_results_s* meas = &rep->crit_exts.c1().meas_report_r8().meas_results;
|
||
7 years ago
|
|
||
6 years ago
|
TESTASSERT(not meas->ext);
|
||
|
TESTASSERT(meas->meas_id == 1);
|
||
|
TESTASSERT(meas->meas_result_pcell.rsrp_result == 73);
|
||
|
TESTASSERT(meas->meas_result_pcell.rsrq_result == 15);
|
||
|
TESTASSERT(meas->meas_result_neigh_cells_present);
|
||
|
TESTASSERT(meas->meas_result_neigh_cells.type() ==
|
||
|
meas_results_s::meas_result_neigh_cells_c_::types::meas_result_list_eutra);
|
||
|
meas_result_list_eutra_l& meas_list = meas->meas_result_neigh_cells.meas_result_list_eutra();
|
||
|
TESTASSERT(meas_list.size() == 1);
|
||
|
TESTASSERT(meas_list[0].pci == 357);
|
||
|
TESTASSERT(meas_list[0].cgi_info_present);
|
||
|
TESTASSERT(meas_list[0].cgi_info.plmn_id_list_present);
|
||
|
TESTASSERT(meas_list[0].cgi_info.cell_global_id.plmn_id.mcc_present);
|
||
4 years ago
|
srsran::plmn_id_t plmn = srsran::make_plmn_id_t(meas_list[0].cgi_info.cell_global_id.plmn_id);
|
||
6 years ago
|
TESTASSERT(plmn.to_string() == "89878");
|
||
6 years ago
|
TESTASSERT(meas_list[0].cgi_info.cell_global_id.cell_id.to_number() == 0x1084104);
|
||
|
TESTASSERT(meas_list[0].cgi_info.tac.to_number() == 0x1042);
|
||
|
TESTASSERT(meas_list[0].cgi_info.plmn_id_list.size() == 1);
|
||
|
TESTASSERT(not meas_list[0].cgi_info.plmn_id_list[0].mcc_present);
|
||
|
TESTASSERT(not meas_list[0].meas_result.ext);
|
||
|
TESTASSERT(meas_list[0].meas_result.rsrp_result_present);
|
||
|
TESTASSERT(meas_list[0].meas_result.rsrp_result == 60);
|
||
|
TESTASSERT(meas_list[0].meas_result.rsrq_result_present);
|
||
|
TESTASSERT(meas_list[0].meas_result.rsrq_result == 18);
|
||
7 years ago
|
|
||
6 years ago
|
uint8_t rrc_msg2[rrc_msg_len];
|
||
6 years ago
|
bzero(rrc_msg2, rrc_msg_len);
|
||
6 years ago
|
bit_ref bref2(&rrc_msg2[0], sizeof(rrc_msg2));
|
||
|
ul_dcch_msg.pack(bref2);
|
||
5 years ago
|
TESTASSERT(bref.distance() == bref2.distance());
|
||
6 years ago
|
TESTASSERT(memcmp(rrc_msg2, rrc_msg, rrc_msg_len) == 0);
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
7 years ago
|
|
||
6 years ago
|
int main(int argc, char** argv)
|
||
|
{
|
||
4 years ago
|
auto& asn1_logger = srslog::fetch_basic_logger("ASN1", false);
|
||
|
asn1_logger.set_level(srslog::basic_levels::debug);
|
||
|
asn1_logger.set_hex_dump_max_size(-1);
|
||
|
|
||
|
srslog::init();
|
||
|
|
||
5 years ago
|
TESTASSERT(meas_obj_test() == 0);
|
||
4 years ago
|
|
||
6 years ago
|
return 0;
|
||
7 years ago
|
}
|