bsc: add TC_no_msc()

Related: OS#4832
Change-Id: I4ffcfd4be551e0647abe00c4eaa8e9c490887190
diff --git a/bsc/BSC_Tests.ttcn b/bsc/BSC_Tests.ttcn
index 9a5faa7..8b92c99 100644
--- a/bsc/BSC_Tests.ttcn
+++ b/bsc/BSC_Tests.ttcn
@@ -98,6 +98,11 @@
 	{ "mscpool:subscr:paged", 0 }
 };
 
+/* List of global mscpool counters, not related to a specific 'msc' entity. */
+const CounterNameVals counternames_bsc_mscpool := {
+	{ "mscpool:subscr:no_msc", 0 }
+};
+
 /* Default list of counters for 'bsc' and 'bts' entities. */
 const CounterNameVals counternames_bsc_bts_handover := {
 	{ "assignment:attempted", 0 },
@@ -8130,6 +8135,47 @@
 	vc_conn.done;
 }
 
+/* Attempt Complete Layer 3 without any MSC available (OS#4832) */
+private function f_tc_no_msc(charstring id) runs on MSC_ConnHdlr {
+	f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
+
+	/* Also disable attach for the single connected MSC */
+	f_vty_msc_allow_attach(BSCVTY, { false });
+
+	var octetstring l3_enc := enc_PDU_ML3_MS_NW(valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000100001'H)), '00F110'O) ));
+	f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
+
+	/* No MSC is found, expecting a proper release on RSL */
+	interleave {
+	[] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
+			f_logp(BSCVTY, "Got RSL RR Release");
+		}
+	[] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
+			f_logp(BSCVTY, "Got RSL Deact SACCH");
+		}
+	[] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
+			f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
+			RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
+		}
+	}
+	setverdict(pass);
+}
+testcase TC_no_msc() runs on test_CT {
+
+	f_init(1, true);
+	f_sleep(1.0);
+	var MSC_ConnHdlr vc_conn;
+	var TestHdlrParams pars := f_gen_test_hdlr_pars();
+
+	f_ctrs_bsc_init(counternames_bsc_mscpool);
+
+	vc_conn := f_start_handler(refers(f_tc_no_msc), pars);
+	vc_conn.done;
+
+	f_ctrs_bsc_add("mscpool:subscr:no_msc");
+	f_ctrs_bsc_verify();
+}
+
 /* Dyn PDCH todo:
    * activate OSMO as TCH/F
    * activate OSMO as TCH/H
@@ -8385,6 +8431,8 @@
 		execute( TC_cm_service_during_lcs_loc_req() );
 		execute( TC_ho_during_lcs_loc_req() );
 	}
+
+	execute( TC_no_msc() );
 }
 
 }