add HNBGW_Tests.TC_second_rab_assignment

Related: SYS#6624
Related: osmo-hnbgw I25bf19981cd75a87a7ceb3382dae1ec626ae475c
Change-Id: Iadaba0e5e82ad6d163ad509904ede213e2462d5c
diff --git a/hnbgw/HNBGW_Tests.ttcn b/hnbgw/HNBGW_Tests.ttcn
index 505beab..adb32bd 100644
--- a/hnbgw/HNBGW_Tests.ttcn
+++ b/hnbgw/HNBGW_Tests.ttcn
@@ -2596,6 +2596,73 @@
 	f_shutdown_helper();
 }
 
+/* In the field, we encountered a "normal" RAB Assignment that concludes successfully, followed by another RAB
+ * Assignment that has different SDU subflow parameters, and does not contain RTP information. At the time of writing,
+ * it seems that the second RAB Assignment causes a crash. Play through this scenario. */
+friend function f_tc_second_rab_assignment(charstring id, TestHdlrParams pars) runs on ConnHdlr {
+	var MgcpCommand mgcp_cmd;
+	var RANAP_PDU tx;
+	timer T := 5.0;
+
+	f_init_handler(pars);
+	f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
+
+	tx := f_build_initial_ue(g_pars);
+	f_iuh2iu_connect(tx);
+
+	f_create_rab(pars.mgcp_pars);
+
+	/* Now send a second RAB Assignment with different subflows and omitting transportLayerInformation. (Assuming
+	 * the first RAB Assignment's transportLayerInformation remains in use unchanged.) */
+	var template RAB_SetupOrModifyList rab_sml;
+	rab_sml := ts_RAB_SML2(t_RAB_id(23),
+			       ts_RabParams,
+			       user_plane_info := omit,
+			       transport_layer_info := omit);
+	tx := valueof(ts_RANAP_RabAssReq(rab_sml));
+	BSSAP.send(tx);
+	T.start;
+
+	/* Expect this secondary RAB Assignment to go through unchanged. */
+	f_rua_expect(tx);
+
+	/* I'm guessing that the RAB Assignment Response also omits transportLayerInformation, so far not known because
+	 * osmo-hnbgw crashed before we could receive the response. */
+
+	/* Send back RAB Assignment Response via Iuh */
+	var template RAB_SetupOrModifiedList rab_smdl;
+	rab_smdl := ts_RAB_SMdL_no_tla(t_RAB_id(23));
+	tx := valueof(ts_RANAP_RabAssResp(rab_smdl));
+	RUA.send(tx);
+	f_bssap_expect(tx);
+
+	/* Send Iu Release */
+	tx := valueof(ts_RANAP_IuReleaseCommand(ts_RanapCause_om_intervention));
+	f_iu2iuh(tx);
+
+	T.start;
+	alt {
+	[] as_mgcp_dlcx(pars) {}
+	[] T.timeout {
+		setverdict(fail, "Timeout waiting for DLCX");
+	}
+	}
+
+	tx := valueof(ts_RANAP_IuReleaseComplete());
+	f_iuh2iu(tx);
+}
+
+testcase TC_second_rab_assignment() runs on test_CT {
+	var ConnHdlr vc_conn;
+	g_num_hnbs := 1;
+	f_init();
+
+	vc_conn := f_start_handler_with_pars(refers(f_tc_second_rab_assignment), t_pars(3));
+	vc_conn.done;
+
+	f_shutdown_helper();
+}
+
 control {
 	execute(TC_hnb_register());
 	execute(TC_hnb_register_duplicate());
@@ -2643,6 +2710,8 @@
 	execute( TC_sgsnpool_sccp_n_pcstate_detaches_cnlink() );
 	execute( TC_sgsnpool_sccp_n_pcstate_attaches_cnlink() );
 
+	execute(TC_second_rab_assignment());
+
 	/* Run at the end since it makes osmo-hnbgw <= 1.3.0 crash: OS#5676 */
 	execute(TC_hnb_reregister_reuse_sctp_assoc());