Skip to content

Commit 9fa997b

Browse files
cu_cp,ngap: Add check for error indication to unittests
1 parent 7740766 commit 9fa997b

File tree

5 files changed

+39
-13
lines changed

5 files changed

+39
-13
lines changed

tests/unittests/ngap/ngap_error_indication_test.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,26 @@ class ngap_error_indication_test : public ngap_test
3232
// Inject Initial Context Setup Request
3333
run_inital_context_setup(ue_index);
3434
}
35+
36+
bool was_error_indication_sent() const
37+
{
38+
return msg_notifier.last_ngap_msg.pdu.init_msg().value.type() ==
39+
asn1::ngap::ngap_elem_procs_o::init_msg_c::types_opts::error_ind;
40+
}
3541
};
3642

3743
// Note that this is currently a manual test without asserts, as we currently don't handle the error indication
3844

3945
/// Test handling of error indication message for inexisting ue
40-
TEST_F(ngap_error_indication_test, when_error_indication_message_for_inexisting_ue_received_message_is_dropped)
46+
TEST_F(ngap_error_indication_test,
47+
when_error_indication_message_for_inexisting_ue_received_message_is_dropped_and_error_indication_is_sent)
4148
{
4249
// Inject error indication message
4350
ngap_message error_indication_msg = generate_error_indication_message(uint_to_amf_ue_id(10), uint_to_ran_ue_id(0));
4451
ngap->handle_message(error_indication_msg);
52+
53+
// Check that Error Indication has been sent to AMF
54+
ASSERT_TRUE(was_error_indication_sent());
4555
}
4656

4757
/// Test handling of error indication message for existing ue

tests/unittests/ngap/ngap_nas_message_test.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ class ngap_nas_message_routine_test : public ngap_test
4343
return msg_notifier.last_ngap_msg.pdu.init_msg().value.type() ==
4444
asn1::ngap::ngap_elem_procs_o::init_msg_c::types_opts::ul_nas_transport;
4545
}
46+
47+
bool was_error_indication_sent() const
48+
{
49+
return msg_notifier.last_ngap_msg.pdu.init_msg().value.type() ==
50+
asn1::ngap::ngap_elem_procs_o::init_msg_c::types_opts::error_ind;
51+
}
4652
};
4753

4854
/// Initial UE message tests
@@ -80,7 +86,7 @@ TEST_F(ngap_nas_message_routine_test, when_ue_present_dl_nas_transport_is_forwar
8086
ASSERT_TRUE(was_dl_nas_transport_forwarded());
8187
}
8288

83-
TEST_F(ngap_nas_message_routine_test, when_no_ue_present_dl_nas_transport_is_dropped)
89+
TEST_F(ngap_nas_message_routine_test, when_no_ue_present_dl_nas_transport_is_dropped_and_error_indication_is_sent)
8490
{
8591
// Inject DL NAS transport message from AMF
8692
ngap_message dl_nas_transport = generate_downlink_nas_transport_message(
@@ -93,6 +99,8 @@ TEST_F(ngap_nas_message_routine_test, when_no_ue_present_dl_nas_transport_is_dro
9399

94100
// Check that no message has been sent to RRC
95101
ASSERT_TRUE(was_dl_nas_transport_dropped());
102+
// Check that Error Indication has been sent to AMF
103+
ASSERT_TRUE(was_error_indication_sent());
96104
}
97105

98106
/// Test UL NAS transport handling

tests/unittests/ngap/ngap_paging_test.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ class ngap_paging_test : public ngap_test
169169
bool was_minimal_paging_forwarded() const { return was_minimal_conversion_successful(); }
170170

171171
bool was_full_paging_forwarded() const { return was_full_conversion_successful(); }
172+
173+
bool was_error_indication_sent() const
174+
{
175+
return msg_notifier.last_ngap_msg.pdu.init_msg().value.type() ==
176+
asn1::ngap::ngap_elem_procs_o::init_msg_c::types_opts::error_ind;
177+
}
172178
};
173179

174180
/// Test handling of valid paging message with optional fields
@@ -194,12 +200,12 @@ TEST_F(ngap_paging_test, when_valid_paging_message_with_optional_values_received
194200
}
195201

196202
/// Test handling of invalid paging message
197-
TEST_F(ngap_paging_test, when_invalid_paging_message_received_message_is_forwarded)
203+
TEST_F(ngap_paging_test, when_invalid_paging_message_received_message_is_not_forwarded_and_error_indication_is_sent)
198204
{
199205
// Inject paging message
200206
ngap_message paging_msg = generate_invalid_paging_message();
201207
ngap->handle_message(paging_msg);
202208

203-
// check that paging message has been forwarded
204-
ASSERT_FALSE(was_full_paging_forwarded());
209+
// Check that Error Indication has been sent to AMF
210+
ASSERT_TRUE(was_error_indication_sent());
205211
}

tests/unittests/ngap/ngap_pdu_session_resource_setup_procedure_test.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ class ngap_pdu_session_resource_setup_procedure_test : public ngap_test
7979

8080
return test_1 && test_2 && test_3;
8181
}
82+
83+
bool was_error_indication_sent() const
84+
{
85+
return msg_notifier.last_ngap_msg.pdu.init_msg().value.type() ==
86+
asn1::ngap::ngap_elem_procs_o::init_msg_c::types_opts::error_ind;
87+
}
8288
};
8389

8490
/// Test valid PDU Session Resource Setup Request
@@ -147,7 +153,6 @@ TEST_F(ngap_pdu_session_resource_setup_procedure_test, when_security_not_enabled
147153
ue.amf_ue_id.value(), ue.ran_ue_id.value(), pdu_session_id);
148154
ngap->handle_message(pdu_session_resource_setup_request);
149155

150-
// Check that PDU Session Resource Setup Request was dropped (last transmitted message is InitialContextSetupResponse)
151-
ASSERT_EQ(msg_notifier.last_ngap_msg.pdu.successful_outcome().value.type(),
152-
asn1::ngap::ngap_elem_procs_o::successful_outcome_c::types_opts::init_context_setup_resp);
156+
// Check that Error Indication has been sent to AMF
157+
ASSERT_TRUE(was_error_indication_sent());
153158
}

tests/unittests/ngap/ngap_test_messages.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -542,11 +542,8 @@ ngap_message srsran::srs_cu_cp::generate_invalid_paging_message()
542542
ngap_msg.pdu.init_msg().load_info_obj(ASN1_NGAP_ID_PAGING);
543543

544544
// add ue paging id
545-
auto& paging = ngap_msg.pdu.init_msg().value.paging();
546-
auto& five_g_s_tmsi = paging->ue_paging_id.set_five_g_s_tmsi();
547-
five_g_s_tmsi.amf_set_id.from_number(0);
548-
five_g_s_tmsi.amf_pointer.from_number(0);
549-
five_g_s_tmsi.five_g_tmsi.from_number(0);
545+
auto& paging = ngap_msg.pdu.init_msg().value.paging();
546+
paging->ue_paging_id.set_choice_exts();
550547
return ngap_msg;
551548
}
552549

0 commit comments

Comments
 (0)