BTS_Test_ASCI: Add UPLINK FREE / UPLINK BUSY test

A VGCS channel is activated. The BSC sends UPLINK FREE message and
UPLINK BUSY message. When the UPLINK FREE message is sent, the MS is
expected to receive several UPLINK FREE messages. Then the UPLINK BUSY
message is sent, the MS is expected to receive one UPLINK BUSY message.

Change-Id: I2f70adb4a6f71eb8972feccf9dda0f77e7a942b9
Related: OS#4851
diff --git a/bts/BTS_Tests_ASCI.ttcn b/bts/BTS_Tests_ASCI.ttcn
index dfab7f6..680f1e2 100644
--- a/bts/BTS_Tests_ASCI.ttcn
+++ b/bts/BTS_Tests_ASCI.ttcn
@@ -127,8 +127,72 @@
 	Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
 }
 
+/* Sub function to clean up MS and BTS. */
+private function f_vgcs_cleanup() runs on ConnHdlr
+{
+	/* Cleanup L1CTL. */
+	f_L1CTL_RESET(L1CTL);
+	f_l1_tune(L1CTL);
+
+	/* Cleanup VGCS Channel. */
+	f_rsl_chan_deact();
+}
+
+/* A VGCS channel is activated. The BSC sends UPLINK FREE message and UPLINK BUSY message.
+ * When the UPLINK FREE message is sent, the MS is expected to receive several UPLINK FREE messages.
+ * Then the UPLINK BUSY message is sent, the MS is expected to receive one UPLINK BUSY message.
+ */
+private function f_TC_vgcs_uplink_free_and_busy(charstring id) runs on ConnHdlr
+{
+	var octetstring uplink_free := '082B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O;
+	var octetstring uplink_busy := '062A'O;
+
+	f_l1_tune(L1CTL);
+	RSL.clear;
+
+	/* Activate channel on the BTS side */
+	log("Activating VGCS channel.");
+	f_rsl_chan_act(g_pars.chan_mode);
+
+	/* enable dedicated mode */
+	f_l1ctl_est_dchan(L1CTL, g_pars);
+
+	/* Send one UPLINK FREE message and expect them to be repeated. */
+	log("Send UPLINK FREE.");
+	RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), uplink_free));
+	for (var integer i := 0; i < 20; i := i + 1) {
+		f_l1_exp_lapdm(tr_LAPDm_Bter_UI(uplink_free));
+		log("Received UPLINK FREE.");
+	}
+
+	/* Send one UPLINK BUSY message and expect it to be received. */
+	log("Send UPLINK BUSY.");
+	RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), uplink_busy));
+	f_l1_exp_lapdm(tr_LAPDm_UI(0, cr_MT_CMD, uplink_busy));
+	log("Received UPLINK BUSY.");
+
+	/* Deactivate and cleanup. */
+	f_vgcs_cleanup();
+}
+testcase TC_vgcs_uplink_free_and_busy() runs on test_CT
+{
+	var template RSL_IE_ChannelMode ch_mode;
+	var ConnHdlrPars pars;
+	var ConnHdlr vc_conn;
+
+	f_init();
+
+	ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_F_GROUP, RSL_CMOD_SP_GSM1);
+	pars := valueof(t_Pars(t_RslChanNr_Bm(1), ch_mode));
+	vc_conn := f_start_handler(refers(f_TC_vgcs_uplink_free_and_busy), pars);
+	vc_conn.done;
+
+	Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
+}
+
 control {
 	execute( TC_vbs_notification() );
+	execute( TC_vgcs_uplink_free_and_busy() );
 
 }