Skip to content

Commit 99d1742

Browse files
FabianEckermanncodebot
authored andcommitted
cu_cp,rrc: improve unittests and check for nas pdu in rrc reconfiguration
1 parent 5665faf commit 99d1742

File tree

4 files changed

+74
-7
lines changed

4 files changed

+74
-7
lines changed

tests/test_doubles/rrc/rrc_test_message_validators.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,39 @@ bool srsran::test_helpers::is_valid_rrc_security_mode_command(const byte_buffer&
6767
TRUE_OR_RETURN(dcch.unpack(bref) == asn1::SRSASN_SUCCESS);
6868
return is_valid_rrc_security_mode_command(dcch);
6969
}
70+
71+
bool srsran::test_helpers::is_valid_rrc_ue_capability_enquiry(const asn1::rrc_nr::dl_dcch_msg_s& msg)
72+
{
73+
TRUE_OR_RETURN(msg.msg.type().value == asn1::rrc_nr::dl_dcch_msg_type_c::types_opts::c1);
74+
TRUE_OR_RETURN(msg.msg.c1().type().value == asn1::rrc_nr::dl_dcch_msg_type_c::c1_c_::types_opts::ue_cap_enquiry);
75+
TRUE_OR_RETURN(msg.msg.c1().ue_cap_enquiry().crit_exts.type().value ==
76+
asn1::rrc_nr::ue_cap_enquiry_s::crit_exts_c_::types_opts::ue_cap_enquiry);
77+
return true;
78+
}
79+
80+
bool srsran::test_helpers::is_valid_rrc_ue_capability_enquiry(const byte_buffer& dl_dcch_msg)
81+
{
82+
asn1::cbit_ref bref{dl_dcch_msg};
83+
asn1::rrc_nr::dl_dcch_msg_s dcch;
84+
TRUE_OR_RETURN(dcch.unpack(bref) == asn1::SRSASN_SUCCESS);
85+
return is_valid_rrc_ue_capability_enquiry(dcch);
86+
}
87+
88+
bool srsran::test_helpers::is_valid_rrc_reconfiguration(const asn1::rrc_nr::dl_dcch_msg_s& msg)
89+
{
90+
TRUE_OR_RETURN(msg.msg.type().value == asn1::rrc_nr::dl_dcch_msg_type_c::types_opts::c1);
91+
TRUE_OR_RETURN(msg.msg.c1().type().value == asn1::rrc_nr::dl_dcch_msg_type_c::c1_c_::types_opts::rrc_recfg);
92+
TRUE_OR_RETURN(msg.msg.c1().rrc_recfg().crit_exts.type().value ==
93+
asn1::rrc_nr::rrc_recfg_s::crit_exts_c_::types_opts::rrc_recfg);
94+
TRUE_OR_RETURN(msg.msg.c1().rrc_recfg().crit_exts.rrc_recfg().non_crit_ext_present);
95+
TRUE_OR_RETURN(msg.msg.c1().rrc_recfg().crit_exts.rrc_recfg().non_crit_ext.ded_nas_msg_list.size() != 0);
96+
return true;
97+
}
98+
99+
bool srsran::test_helpers::is_valid_rrc_reconfiguration(const byte_buffer& dl_dcch_msg)
100+
{
101+
asn1::cbit_ref bref{dl_dcch_msg};
102+
asn1::rrc_nr::dl_dcch_msg_s dcch;
103+
TRUE_OR_RETURN(dcch.unpack(bref) == asn1::SRSASN_SUCCESS);
104+
return is_valid_rrc_reconfiguration(dcch);
105+
}

tests/test_doubles/rrc/rrc_test_message_validators.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,13 @@ bool is_valid_rrc_reestablishment(const byte_buffer& dl_dcch_msg);
2828
bool is_valid_rrc_security_mode_command(const asn1::rrc_nr::dl_dcch_msg_s& msg);
2929
bool is_valid_rrc_security_mode_command(const byte_buffer& dl_dcch_msg);
3030

31+
/// \brief Check if DL-DCCH message is a valid RRC UE Capability Enquiry message.
32+
bool is_valid_rrc_ue_capability_enquiry(const asn1::rrc_nr::dl_dcch_msg_s& msg);
33+
bool is_valid_rrc_ue_capability_enquiry(const byte_buffer& dl_dcch_msg);
34+
35+
/// \brief Check if DL-DCCH message is a valid RRC Reconfiguration message.
36+
bool is_valid_rrc_reconfiguration(const asn1::rrc_nr::dl_dcch_msg_s& msg);
37+
bool is_valid_rrc_reconfiguration(const byte_buffer& dl_dcch_msg);
38+
3139
} // namespace test_helpers
3240
} // namespace srsran

tests/unittests/cu_cp/cu_cp_initial_context_setup_test.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "tests/test_doubles/f1ap/f1ap_test_messages.h"
1414
#include "tests/test_doubles/ngap/ngap_test_message_validators.h"
1515
#include "tests/test_doubles/rrc/rrc_test_message_validators.h"
16-
#include "tests/test_doubles/rrc/rrc_test_messages.h"
1716
#include "tests/unittests/e1ap/common/e1ap_cu_cp_test_messages.h"
1817
#include "tests/unittests/f1ap/common/f1ap_cu_test_messages.h"
1918
#include "tests/unittests/ngap/ngap_test_messages.h"
@@ -82,7 +81,7 @@ class cu_cp_initial_context_setup_test : public cu_cp_test_environment, public :
8281
const byte_buffer& rrc_container = test_helpers::get_rrc_container(f1ap_pdu);
8382
report_fatal_error_if_not(
8483
test_helpers::is_valid_rrc_security_mode_command(test_helpers::extract_dl_dcch_msg(rrc_container)),
85-
"Invalid Security Mode command");
84+
"Invalid Security Mode Command");
8685

8786
// Inject UE Context Setup Response
8887
f1ap_message ue_ctxt_setup_response = generate_ue_context_setup_response(ue_ctx->cu_ue_id.value(), du_ue_id);
@@ -98,9 +97,13 @@ class cu_cp_initial_context_setup_test : public cu_cp_test_environment, public :
9897

9998
// Wait for UE Capability Enquiry
10099
bool result = this->wait_for_f1ap_tx_pdu(du_idx, f1ap_pdu);
101-
report_fatal_error_if_not(result, "Failed to receive DL RRC Message, containing RRC UE Capability Enquiry");
100+
report_fatal_error_if_not(result, "Failed to receive UE Capability Enquiry");
102101
report_fatal_error_if_not(test_helpers::is_valid_dl_rrc_message_transfer(f1ap_pdu),
103102
"Invalid DL RRC Message Transfer");
103+
const byte_buffer& rrc_container = test_helpers::get_rrc_container(f1ap_pdu);
104+
report_fatal_error_if_not(
105+
test_helpers::is_valid_rrc_ue_capability_enquiry(test_helpers::extract_dl_dcch_msg(rrc_container)),
106+
"Invalid UE Capability Enquiry");
104107
}
105108

106109
void send_ue_capability_info_and_await_registration_accept_and_initial_context_setup_response()
@@ -169,6 +172,12 @@ class cu_cp_initial_context_setup_test : public cu_cp_test_environment, public :
169172
report_fatal_error_if_not(result, "Failed to receive F1AP DL RRC Message (containing RRC Reconfiguration)");
170173
report_fatal_error_if_not(test_helpers::is_valid_dl_rrc_message_transfer(f1ap_pdu),
171174
"Invalid DL RRC Message Transfer");
175+
176+
// Make sure RRC Reconfiguration contains NAS PDU
177+
const byte_buffer& rrc_container = test_helpers::get_rrc_container(f1ap_pdu);
178+
report_fatal_error_if_not(
179+
test_helpers::is_valid_rrc_reconfiguration(test_helpers::extract_dl_dcch_msg(rrc_container)),
180+
"Invalid RRC Reconfiguration");
172181
}
173182

174183
void send_rrc_reconfiguration_complete_and_await_initial_context_setup_response()

tests/unittests/cu_cp/cu_cp_test_environment.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,12 @@ bool cu_cp_test_environment::setup_ue_security(unsigned du_idx, gnb_du_ue_f1ap_i
386386
report_fatal_error_if_not(result, "Failed to receive Security Mode Command");
387387
report_fatal_error_if_not(test_helpers::is_valid_ue_context_setup_request(f1ap_pdu),
388388
"Invalid UE Context Setup Request");
389-
const byte_buffer& rrc_container = test_helpers::get_rrc_container(f1ap_pdu);
390-
report_fatal_error_if_not(
391-
test_helpers::is_valid_rrc_security_mode_command(test_helpers::extract_dl_dcch_msg(rrc_container)),
392-
"Invalid Security Mode command");
389+
{
390+
const byte_buffer& rrc_container = test_helpers::get_rrc_container(f1ap_pdu);
391+
report_fatal_error_if_not(
392+
test_helpers::is_valid_rrc_security_mode_command(test_helpers::extract_dl_dcch_msg(rrc_container)),
393+
"Invalid Security Mode command");
394+
}
393395

394396
// Inject UE Context Setup Response
395397
f1ap_message ue_ctxt_setup_response = generate_ue_context_setup_response(ue_ctx.cu_ue_id.value(), du_ue_id);
@@ -405,6 +407,12 @@ bool cu_cp_test_environment::setup_ue_security(unsigned du_idx, gnb_du_ue_f1ap_i
405407
report_fatal_error_if_not(result, "Failed to receive DL RRC Message, containing RRC UE Capability Enquiry");
406408
report_fatal_error_if_not(test_helpers::is_valid_dl_rrc_message_transfer(f1ap_pdu),
407409
"Invalid DL RRC Message Transfer");
410+
{
411+
const byte_buffer& rrc_container = test_helpers::get_rrc_container(f1ap_pdu);
412+
report_fatal_error_if_not(
413+
test_helpers::is_valid_rrc_ue_capability_enquiry(test_helpers::extract_dl_dcch_msg(rrc_container)),
414+
"Invalid UE Capability Enquiry");
415+
}
408416

409417
// Inject UL RRC Message Transfer (containing UE Capability Info)
410418
get_du(du_idx).push_ul_pdu(test_helpers::create_ul_rrc_message_transfer(
@@ -520,6 +528,12 @@ bool cu_cp_test_environment::attach_ue(unsigned du_idx,
520528
report_fatal_error_if_not(result, "Failed to receive F1AP DL RRC Message (containing RRC Reconfiguration)");
521529
report_fatal_error_if_not(test_helpers::is_valid_dl_rrc_message_transfer(f1ap_pdu),
522530
"Invalid DL RRC Message Transfer");
531+
{
532+
const byte_buffer& rrc_container = test_helpers::get_rrc_container(f1ap_pdu);
533+
report_fatal_error_if_not(
534+
test_helpers::is_valid_rrc_reconfiguration(test_helpers::extract_dl_dcch_msg(rrc_container)),
535+
"Invalid RRC Reconfiguration");
536+
}
523537

524538
// Inject RRC Reconfiguration Complete and wait for PDU Session Resource Setup Response to be sent to AMF.
525539
get_du(du_idx).push_ul_pdu(test_helpers::create_ul_rrc_message_transfer(

0 commit comments

Comments
 (0)