bts: f_est_dchan: verify Chan Rqd originated by RACH arrives on RSL

We cannot notify RSL Emulation layer about expecting a specific FN
(during ts_RSLDC_ChanRqd) because we only know the FN after sending the
RACH request, and since notification to RSL Emulation happens async, it
can happen (verified) that ChanRqd message from BTS arrives and is
handled before we register the RACH req into the ConnectionTable.

Change-Id: I438fd3ee82d88498d928dbcc89ce9bd80d37ab64
diff --git a/bts/BTS_Tests.ttcn b/bts/BTS_Tests.ttcn
index 5b073ef..64c2510 100644
--- a/bts/BTS_Tests.ttcn
+++ b/bts/BTS_Tests.ttcn
@@ -1344,6 +1344,28 @@
 	}
 }
 
+/* Send RACH request through l1CTL and wait for ChanReq on RSL BST->BSC */
+private function f_rach_req_wait_chan_rqd(integer ra) runs on ConnHdlr return GsmFrameNumber {
+	var GsmFrameNumber fn;
+	timer T := 8.0;
+
+	/* advertise to RSL Emulation that we expect to receive confirmation from RACH */
+	RSL.send(ts_RSLDC_ChanRqd_anyFN(int2oct(ra,1)));
+
+	f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, g_pars.l1_pars.ms_power_level);
+	/* Send the actual RACH */
+	fn := f_L1CTL_RACH(L1CTL, ra);
+
+	T.start;
+	alt {
+	[] RSL.receive(tr_RSL_CHAN_RQD(int2oct(ra,1), fn)) { setverdict(pass, "Received CHAN-RQD from RACH REQ") }
+	[] T.timeout {
+		Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN-RQD from RACH REQ <", ra, ", ", fn, ">"));
+		}
+	}
+	T.stop
+	return fn;
+}
 
 /* Establish dedicated channel: L1CTL + RSL side */
 private function f_est_dchan(boolean encr_enable := false) runs on ConnHdlr {
@@ -1351,10 +1373,8 @@
 	var ImmediateAssignment imm_ass;
 	var integer ra := 23;
 
-	f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, g_pars.l1_pars.ms_power_level);
-	fn := f_L1CTL_RACH(L1CTL, ra);
-	/* This arrives on CCHAN, so we cannot test for receiving CHAN RQDhere */
-	//RSL.receive(tr_RSL_CHAN_RQD(int2oct(23,1)));
+	/* Send RACH request and wait for ChanReq */
+	fn := f_rach_req_wait_chan_rqd(ra);
 
 	/* Activate channel on BTS side */
 	f_rsl_chan_act(g_pars.chan_mode, encr_enable);