bsc: TC_assignment_emerg_setup_allow(_imei): Test full voice establishment

Extend tests to also test the data plane setup.

Related: OS#5849
Change-Id: I9f39f861398669a8eb1da242595de584725e5b83
diff --git a/bsc/BSC_Tests.ttcn b/bsc/BSC_Tests.ttcn
index 45c319d..c0a64a9 100644
--- a/bsc/BSC_Tests.ttcn
+++ b/bsc/BSC_Tests.ttcn
@@ -9180,12 +9180,63 @@
 	}
 }
 
+private function f_assignment_emerg_setup_voice()
+runs on MSC_ConnHdlr {
+	/* Go on with voice call assignment */
+	var template PDU_BSSAP exp_compl := f_gen_exp_compl();
+	var PDU_BSSAP ass_cmd := f_gen_ass_req();
+
+	/* Below speechOrDataIndicator and codecList are copied from an emergency call captured during tests.
+	 * They seem a bit weird (AMR-WB, and the order differ between speechId_DataIndicator and the codecList), but
+	 * seems a good idea to see how osmo-bsc reacts to this. */
+	ass_cmd.pdu.bssmap.assignmentRequest.channelType := {
+		elementIdentifier := '0B'O,	/* overwritten */
+		lengthIndicator := 0,		/* overwritten */
+		speechOrDataIndicator := '0001'B,	/* speech */
+		spare1_4 := '0000'B,
+		channelRateAndType := ChRate_TCHForH_Fpref,
+		speechId_DataIndicator := 'c2918105'O
+	};
+	ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({
+		ts_CodecHR, ts_CodecAMR_WB, ts_CodecEFR, ts_CodecFR}));
+
+	f_rslem_dchan_queue_enable();
+
+	var ExpectCriteria mgcpcrit := {
+		connid := omit,
+		endpoint := omit,
+		transid := omit
+	};
+	f_create_mgcp_expect(mgcpcrit);
+
+	BSSAP.send(ass_cmd);
+
+	var AssignmentState st := valueof(ts_AssignmentStateInit);
+	st.voice_call := true;
+	st.is_assignment := false;
+	alt {
+	[] as_modify(st);
+	[] as_Media();
+	[st.modify_done] BSSAP.receive(exp_compl) {
+		setverdict(pass);
+		}
+	}
+
+	/* Voice call carries on ... */
+	f_sleep(2.0);
+}
+
 /* Test if the EMERGENCY SETUP gets passed on to the MSC via A when EMERGENCY
  * CALLS are permitted by the BSC config. */
 private function f_TC_assignment_emerg_setup_allow(charstring id) runs on MSC_ConnHdlr {
 
+	/* Make sure the CHAN RQD indicates an emergency call (0b101xxxxx). The difference is that osmo-bsc directly
+	 * assigns a TCH lchan and establishing voice for the emergency call will use Mode Modify, not reassignment to
+	 * another lchan. */
+	g_pars.ra := f_rnd_ra_emerg();
 	f_assignment_emerg_setup();
 	f_assignment_emerg_setup_exp_bssap();
+	f_assignment_emerg_setup_voice();
 
 	setverdict(pass);
 	f_perform_clear();
@@ -9197,6 +9248,10 @@
 	var PDU_BSSAP emerg_setup_data_ind_bssap;
 	timer T := 3.0;
 
+	/* Make sure the CHAN RQD indicates an emergency call (0b101xxxxx). The difference is that osmo-bsc directly
+	 * assigns a TCH lchan and establishing voice for the emergency call will use Mode Modify, not reassignment to
+	 * another lchan. */
+	g_pars.ra := f_rnd_ra_emerg();
 	f_assignment_emerg_setup();
 
 	T.start;
@@ -10488,48 +10543,7 @@
 	BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
 	BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
 
-	/* Go on with voice call assignment */
-	var template PDU_BSSAP exp_compl := f_gen_exp_compl();
-	var PDU_BSSAP ass_cmd := f_gen_ass_req();
-
-	/* Below speechOrDataIndicator and codecList are copied from an emergency call captured during tests.
-	 * They seem a bit weird (AMR-WB, and the order differ between speechId_DataIndicator and the codecList), but
-	 * seems a good idea to see how osmo-bsc reacts to this. */
-	ass_cmd.pdu.bssmap.assignmentRequest.channelType := {
-		elementIdentifier := '0B'O,	/* overwritten */
-		lengthIndicator := 0,		/* overwritten */
-		speechOrDataIndicator := '0001'B,	/* speech */
-		spare1_4 := '0000'B,
-		channelRateAndType := ChRate_TCHForH_Fpref,
-		speechId_DataIndicator := 'c2918105'O
-	};
-	ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({
-		ts_CodecHR, ts_CodecAMR_WB, ts_CodecEFR, ts_CodecFR}));
-
-	f_rslem_dchan_queue_enable();
-
-	var ExpectCriteria mgcpcrit := {
-		connid := omit,
-		endpoint := omit,
-		transid := omit
-	};
-	f_create_mgcp_expect(mgcpcrit);
-
-	BSSAP.send(ass_cmd);
-
-	var AssignmentState st := valueof(ts_AssignmentStateInit);
-	st.voice_call := true;
-	st.is_assignment := false;
-	alt {
-	[] as_modify(st);
-	[] as_Media();
-	[st.modify_done] BSSAP.receive(exp_compl) {
-		setverdict(pass);
-		}
-	}
-
-	/* Voice call carries on ... */
-	f_sleep(2.0);
+	f_assignment_emerg_setup_voice();
 
 	setverdict(pass);
 	f_perform_clear();