hnbgw: test SCCP CR without payload

Various tweaks are required to allow RAN_Emulation to handle, and also
to expect, an SCCP CR that has no payload data.

Related: SYS#5968
Related: If0c5c0a76e5230bf22871f527dcb2dbdf34d7328 (osmo-hnbgw)
Change-Id: I827e081eaacfb8e76684ed1560603e6c8f896c38
diff --git a/hnbgw/HNBGW_Tests.ttcn b/hnbgw/HNBGW_Tests.ttcn
index b2c491e..1b1d709 100644
--- a/hnbgw/HNBGW_Tests.ttcn
+++ b/hnbgw/HNBGW_Tests.ttcn
@@ -167,7 +167,8 @@
 	hexstring imsi,
 	boolean ps_domain,
 	MgcpParameters mgcp_pars optional,
-	HnbConfig hnb optional
+	HnbConfig hnb optional,
+	boolean separate_sccp_cr
 }
 
 /* We extend:
@@ -498,12 +499,21 @@
 	}
 
 	/* create an expect on the Iu side for the random NAS portion */
-	var template (omit) octetstring nas := f_ranap_extract_l3(valueof(tx));
-	f_ran_register_exp(valueof(nas));
+	if (g_pars.separate_sccp_cr) {
+		f_ran_register_sccp_cr_without_payload();
+	} else {
+		var template (omit) octetstring nas := f_ranap_extract_l3(valueof(tx));
+		f_ran_register_exp(valueof(nas));
+	}
 
 	/* send it via Iuh (creating a RUA connection) */
 	RUA.send(RUA_Conn_Req:{g_pars.ps_domain, tx});
 
+	if (g_pars.separate_sccp_cr) {
+		/* Acknowledge the empty SCCP CR. RAN_Emulation does the confirmation, no need to respond. */
+		BSSAP.receive(tr_RANAP_Conn_Req());
+	}
+
 	/* expect to receive it on the Iu side */
 	T.start;
 	alt {
@@ -634,11 +644,13 @@
  ***********************************************************************/
 
 private template (value) TestHdlrParams
-t_pars(integer imsi_suffix, boolean ps_domain := false,integer hnb_idx := 0) := {
+t_pars(integer imsi_suffix, boolean ps_domain := false, integer hnb_idx := 0,
+       boolean separate_sccp_cr := false) := {
 	hnb_idx := hnb_idx,
 	imsi := f_gen_imsi(imsi_suffix),
 	ps_domain := ps_domain,
-	hnb := omit	/* filled in later */
+	hnb := omit,	/* filled in later */
+	separate_sccp_cr := separate_sccp_cr
 }
 
 /* Create an Iuh connection; send InitialUE; expect it to appear on new SCCP conenction */
@@ -666,6 +678,43 @@
 	vc_conn.done;
 }
 
+private function f_vty_set_sccp_cr_max_payload_len(TELNETasp_PT pt, integer val := 999999)
+{
+	f_vty_enter_config(pt);
+	f_vty_transceive(pt, "hnbgw");
+	f_vty_transceive(pt, "sccp cr max-payload-len " & int2str(val));
+	f_vty_transceive(pt, "end");
+}
+
+testcase TC_ranap_cs_initial_ue_empty_cr() runs on test_CT {
+	var ConnHdlr vc_conn;
+
+	f_init();
+	f_start_hnbs();
+
+	f_vty_set_sccp_cr_max_payload_len(HNBGWVTY, 0);
+
+	vc_conn := f_start_handler_with_pars(refers(f_tc_initial_ue), t_pars(1, separate_sccp_cr := true));
+	vc_conn.done;
+
+	/* reset */
+	f_vty_set_sccp_cr_max_payload_len(HNBGWVTY);
+}
+testcase TC_ranap_ps_initial_ue_empty_cr() runs on test_CT {
+	var ConnHdlr vc_conn;
+
+	f_init();
+	f_start_hnbs();
+
+	f_vty_set_sccp_cr_max_payload_len(HNBGWVTY, 0);
+
+	vc_conn := f_start_handler_with_pars(refers(f_tc_initial_ue), t_pars(2, true, separate_sccp_cr := true));
+	vc_conn.done;
+
+	/* reset */
+	f_vty_set_sccp_cr_max_payload_len(HNBGWVTY);
+}
+
 /* Reply to a received CRCX with an OK (or the reply configured in cpars), using the given parameters.
  * Return true when an OK reply was sent, false otherwise.
  * Count occurrence of Osmux, include Osmux parameters in the reply if necessary. */
@@ -1104,6 +1153,8 @@
 	execute(TC_hnb_register());
 	execute(TC_ranap_cs_initial_ue());
 	execute(TC_ranap_ps_initial_ue());
+	execute(TC_ranap_cs_initial_ue_empty_cr());
+	execute(TC_ranap_ps_initial_ue_empty_cr());
 	execute(TC_ranap_cs_bidir());
 	execute(TC_ranap_ps_bidir());
 	execute(TC_rab_assignment());