BTS_Tests: cosmetic: add as_pcuif_msg() for convenience

This altstep eliminates the need to wrap the actual PCUIF message
template into another (port specific) template t_SD_PCUIF.

Change-Id: Iabefddd54a4a2e2183feea04fdb8526e74efc7ac
diff --git a/bts/BTS_Tests.ttcn b/bts/BTS_Tests.ttcn
index 8d02c40..b1af138 100644
--- a/bts/BTS_Tests.ttcn
+++ b/bts/BTS_Tests.ttcn
@@ -5315,6 +5315,17 @@
  * PCU Socket related tests
  ***********************************************************************/
 
+/* Catch a PCUIF message (without having to use t_SD_PCUIF) */
+private altstep as_pcuif_msg(out PCUIF_Message msg,
+			     template (present) PCUIF_Message tr_msg := ?)
+runs on test_CT {
+	var PCUIF_send_data sd;
+
+	[] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_msg)) -> value sd {
+		msg := sd.data;
+	}
+}
+
 /* Tune the L1 to PDCH on the given timeslot number */
 private function f_TC_pcu_l1ctl_est_pdch(uint3_t tn) runs on test_CT {
 	var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_PDCH(tn), ts_RSL_ChanMode_SIGN));
@@ -5326,12 +5337,13 @@
 /* Verify no RTS before ACT_REQ; verify RTS after ACT_REQ */
 friend function f_TC_pcu_act_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, boolean exp_success)
 runs on test_CT {
+	var PCUIF_Message msg;
 	timer T := 3.0;
 
 	/* we don't expect any RTS.req before PDCH are active */
 	T.start;
 	alt {
-	[] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr))) {
+	[] as_pcuif_msg(msg, tr_PCUIF_RTS_REQ(bts_nr)) {
 		Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "PCU RTS.req before PDCH active?");
 		}
 	[] PCU.receive { repeat; }
@@ -5344,14 +5356,13 @@
 	/* we now expect RTS.req for this timeslot (only) */
 	T.start;
 	alt {
-	[exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
+	[exp_success] as_pcuif_msg(msg, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr)) {
 		setverdict(pass);
 		}
-	[not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
-						 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
+	[not exp_success] as_pcuif_msg(msg, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr)) {
 		Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RTS.req for supposedly failing activation");
 		}
-	[] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) {
+	[] as_pcuif_msg(msg, tr_PCUIF_RTS_REQ) {
 		Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RTS.req for wrong TRX/TS");
 		}
 	[] PCU.receive { repeat; }
@@ -5367,6 +5378,7 @@
 /* verify no more RTS after DEACT_REQ */
 friend function f_TC_pcu_deact_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr)
 runs on test_CT {
+	var PCUIF_Message msg;
 	timer T := 3.0;
 
 	/* Send PDCH activate request for known PDCH timeslot */
@@ -5378,7 +5390,7 @@
 	/* we now expect no RTS.req for this timeslot */
 	T.start;
 	alt {
-	[] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
+	[] as_pcuif_msg(msg, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr)) {
 		Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected PCU RTS.req");
 		}
 	[] PCU.receive { repeat; }
@@ -5443,8 +5455,9 @@
 
 /* Test the PCU->BTS Version and BTS->PCU SI13 handshake */
 function f_TC_pcu_ver_siXX(octetstring si, RSL_IE_SysinfoType rsl_si_type) runs on test_CT {
-	var PCUIF_send_data sd;
-	timer T:= 3.0;
+	var PCUIF_Message msg;
+	timer T := 3.0;
+
 	f_init_with_pcuif();
 
 	/* Set SI13 via RSL */
@@ -5452,8 +5465,8 @@
 
 	T.start;
 	alt {
-	[] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_DATA_IND(0, 0, 0, ?, PCU_IF_SAPI_BCCH))) -> value sd {
-		if (substr(sd.data.u.data_ind.data, 0, lengthof(si)) == si) {
+	[] as_pcuif_msg(msg, tr_PCUIF_DATA_IND(0, 0, 0, sapi := PCU_IF_SAPI_BCCH)) {
+		if (substr(msg.u.data_ind.data, 0, lengthof(si)) == si) {
 			setverdict(pass);
 		} else {
 			repeat;
@@ -5500,15 +5513,14 @@
 					    PCUIF_Sapi sapi, octetstring data)
 runs on test_CT
 {
-	var PCUIF_send_data sd;
-
+	var PCUIF_Message msg;
 	timer T := 3.0;
+
 	T.start;
 	alt {
-	[] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
-				tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi))) -> value sd {
-		f_pcu_data_req(bts_nr, trx_nr, ts_nr, sd.data.u.rts_req.block_nr,
-				  sd.data.u.rts_req.fn, sapi, data);
+	[] as_pcuif_msg(msg, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi)) {
+		f_pcu_data_req(bts_nr, trx_nr, ts_nr, msg.u.rts_req.block_nr,
+			       msg.u.rts_req.fn, sapi, data);
 		}
 	[] PCU.receive { repeat; }
 	[] T.timeout {
@@ -5638,7 +5650,7 @@
 private function f_TC_pcu_ptcch_ul(uint16_t ra)
 runs on test_CT {
 	var template PCUIF_Message pcu_rach_ind;
-	var PCUIF_send_data sd;
+	var PCUIF_Message msg;
 	var GsmFrameNumber fn;
 	timer T;
 
@@ -5653,8 +5665,8 @@
 	/* Expect a RACH.ind on the PCU interface (timeout is one multi-frame) */
 	T.start(52.0 * 4.615 / 1000.0);
 	alt {
-	[] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) -> value sd {
-		log("Rx an Access Burst on the PCU interface: ", sd.data);
+	[] as_pcuif_msg(msg, pcu_rach_ind) {
+		log("Rx an Access Burst on the PCU interface: ", msg);
 		setverdict(pass);
 		T.stop;
 		}
@@ -5787,6 +5799,7 @@
 
 	var GsmFrameNumber fn_last := 0;
 	for (var integer i := 0; i < 1000; i := i+1) {
+		var PCUIF_Message msg;
 		var OCT1 ra := f_rnd_ra_ps();
 		var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
 		if (fn == fn_last) {
@@ -5797,10 +5810,10 @@
 		timer T := 2.0;
 		T.start;
 		alt {
-		[] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND(0, 0, 0, oct2int(ra), 0, ?, fn))) {
+		[] as_pcuif_msg(msg, tr_PCUIF_RACH_IND(0, 0, 0, oct2int(ra), 0, ?, fn)) {
 			T.stop;
 			}
-		[] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) {
+		[] as_pcuif_msg(msg, tr_PCUIF_RACH_IND) {
 			Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND");
 			}
 		[] PCU.receive { repeat; }
@@ -5819,7 +5832,7 @@
 	var GsmFrameNumber fn_last := 0;
 	var L1ctlRachSynchSeq synch_seq;
 	var PCUIF_BurstType pcu_bt;
-	var GsmFrameNumber fn;
+	var GsmFrameNumber fn
 	var BIT11 ra11;
 
 	f_init_with_pcuif();
@@ -5852,13 +5865,14 @@
 			burst_type := pcu_bt,
 			fn := fn);
 
+		var PCUIF_Message msg;
 		timer T := 2.0;
 		T.start;
 		alt {
-		[] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) {
+		[] as_pcuif_msg(msg, pcu_rach_ind) {
 			T.stop;
 			}
-		[] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) {
+		[] as_pcuif_msg(msg, tr_PCUIF_RACH_IND) {
 			Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND");
 			}
 		[] PCU.receive { repeat; }
@@ -5872,14 +5886,10 @@
 
 private function f_TC_pcu_data_ind_lqual_cb(int16_t lqual_cb_exp, int16_t thresh)
 runs on test_CT {
-	var template PCUIF_send_data sdt;
-	var PCUIF_send_data sd;
+	var PCUIF_Message msg;
 	var int16_t lqual_cb;
 	timer T := 1.0;
 
-	/* PCUIF_DATA.ind is encapsulated into a supplementary record */
-	sdt := t_SD_PCUIF_MSGT(g_pcu_conn_id, PCU_IF_MSG_DATA_IND);
-
 	/* Send a random PDTCH frame over Um
 	 * FIXME: we need to wait for a DL block and user Fn from there. */
 	L1CTL.send(ts_L1CTL_GPRS_UL_BLOCK_REQ(0, 7, '0000'O & f_rnd_octstring(21)));
@@ -5887,8 +5897,8 @@
 	T.start;
 	alt {
 	/* If expected link quality is above the threshold */
-	[lqual_cb_exp >= thresh] PCU.receive(sdt) -> value sd {
-		lqual_cb := sd.data.u.data_ind.lqual_cb;
+	[lqual_cb_exp >= thresh] as_pcuif_msg(msg, tr_PCUIF_DATA_IND) {
+		lqual_cb := msg.u.data_ind.lqual_cb;
 		log("Rx PCUIF_DATA.ind (lqual_cb=", lqual_cb, ")");
 
 		/* Make sure the actual link quality matches the expected value */
@@ -5900,9 +5910,9 @@
 		}
 		}
 	/* If expected link quality is below the threshold */
-	[lqual_cb_exp < thresh] PCU.receive(sdt) -> value sd {
+	[lqual_cb_exp < thresh] as_pcuif_msg(msg, tr_PCUIF_DATA_IND) {
 		Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
-					log2str("Rx unexpected PCUIF_DATA.ind: ", sd.data));
+					log2str("Rx unexpected PCUIF_DATA.ind: ", msg));
 		}
 	/* Ignore PCUIF_RTS.req and PCUIF_TIME.ind */
 	[] PCU.receive { repeat; }
@@ -5951,6 +5961,7 @@
 		var MobileIdentityLV mi_lv;
 		var octetstring mi_lv_enc;
 		var MobileIdentityV mi;
+		var PCUIF_Message msg;
 		timer T := 3.0;
 
 		if (i < 50) {
@@ -5968,9 +5979,9 @@
 		RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_PAGING_CMD(mi, i mod 4)));
 		T.start;
 		alt {
-		[] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ(0, mi_lv_enc))) {
+		[] as_pcuif_msg(msg, tr_PCUIF_PAG_REQ(0, mi_lv_enc)) {
 			}
-		[] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ)) {
+		[] as_pcuif_msg(msg, tr_PCUIF_PAG_REQ) {
 			Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PAGING REQ");
 			}
 		[] PCU.receive { repeat; }
@@ -5984,10 +5995,10 @@
 
 /* test for periodic TIME_IND; check number of FN expired and number of TIME_IND within frames */
 testcase TC_pcu_time_ind() runs on test_CT {
-	var PCUIF_send_data pcu_sd;
 	var integer num_time_ind := 0;
 	var integer first_fn, last_fn;
 	var float test_duration := 5.0;
+	var PCUIF_Message msg;
 	timer T;
 
 	f_init_with_pcuif();
@@ -5996,16 +6007,16 @@
 	PCU.clear;
 	T.start(test_duration);
 	alt {
-	[] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(0, ?))) -> value pcu_sd {
+	[] as_pcuif_msg(msg, tr_PCUIF_TIME_IND(0, ?)) {
 		num_time_ind := num_time_ind + 1;
 		if (not isbound(first_fn)) {
-			first_fn := pcu_sd.data.u.time_ind.fn;
+			first_fn := msg.u.time_ind.fn;
 		}
-		last_fn := pcu_sd.data.u.time_ind.fn;
+		last_fn := msg.u.time_ind.fn;
 		repeat;
 		}
-	[] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(?, ?))) -> value pcu_sd {
-		setverdict(fail, "Received unexpected PCUIF_TIME_IND: ", pcu_sd.data);
+	[] as_pcuif_msg(msg, tr_PCUIF_TIME_IND(?, ?)) {
+		setverdict(fail, "Received unexpected PCUIF_TIME_IND: ", msg);
 		repeat;
 		}
 	[] PCU.receive {
@@ -6037,11 +6048,11 @@
 
 /* test for periodic RTS_REQ; check number of FN expired and number of RTS_IND per SAPI */
 testcase TC_pcu_rts_req() runs on test_CT {
-	var PCUIF_send_data pcu_sd;
 	var integer first_fn, last_fn;
 	var integer num_rts_pdtch := 0;
 	var integer num_rts_ptcch := 0;
 	var float test_duration := 5.0;
+	var PCUIF_Message msg;
 	timer T;
 
 	f_init_with_pcuif();
@@ -6050,26 +6061,24 @@
 	PCU.clear;
 	T.start(test_duration);
 	alt {
-	[] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PDTCH, ?, ?)))
-			-> value pcu_sd {
+	[] as_pcuif_msg(msg, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PDTCH, ?, ?)) {
 		num_rts_pdtch := num_rts_pdtch + 1;
 		if (not isbound(first_fn)) {
-			first_fn := pcu_sd.data.u.rts_req.fn;
+			first_fn := msg.u.rts_req.fn;
 		}
-		last_fn := pcu_sd.data.u.rts_req.fn;
+		last_fn := msg.u.rts_req.fn;
 		repeat;
 		}
-	[] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PTCCH, ?, ?)))
-			-> value pcu_sd {
+	[] as_pcuif_msg(msg, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PTCCH, ?, ?)) {
 		num_rts_ptcch := num_rts_ptcch + 1;
 		if (not isbound(first_fn)) {
-			first_fn := pcu_sd.data.u.rts_req.fn;
+			first_fn := msg.u.rts_req.fn;
 		}
-		last_fn := pcu_sd.data.u.rts_req.fn;
+		last_fn := msg.u.rts_req.fn;
 		repeat;
 		}
-	[] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) -> value pcu_sd {
-		setverdict(fail, "Received unexpected PCUIF_RTS_REQ: ", pcu_sd.data);
+	[] as_pcuif_msg(msg, tr_PCUIF_RTS_REQ) {
+		setverdict(fail, "Received unexpected PCUIF_RTS_REQ: ", msg);
 		repeat;
 		}
 	[] PCU.receive {
@@ -6540,7 +6549,7 @@
 	var template PCUIF_Message tr_interf_ind;
 	var integer interf_ind_num := 0;
 	var boolean first := true;
-	var PCUIF_send_data sd;
+	var PCUIF_Message msg;
 	timer T;
 
 	/* Set the averaging/reporting period to 480ms */
@@ -6566,25 +6575,25 @@
 	T.start(0.480 * 1.5);
 	alt {
 	/* The first interference report may contain unreliable values, so we ignore it */
-	[first] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_INTERF_IND(0, 0))) {
+	[first] as_pcuif_msg(msg, tr_PCUIF_INTERF_IND(0, 0)) {
 		/* 4 SACCH periods => 4 reports (plus some guard time) */
 		T.start(0.480 * 4.0 + 0.480 / 2.0);
 		first := false;
 		repeat;
 		}
 	/* Subsequent interference reports shall match our expectations */
-	[not first] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_interf_ind)) -> value sd {
+	[not first] as_pcuif_msg(msg, tr_interf_ind) {
 		/* Check TDMA frame number period */
-		if (sd.data.u.interf_ind.fn mod 104 != 0) {
+		if (msg.u.interf_ind.fn mod 104 != 0) {
 			setverdict(fail, "Odd TDMA frame number := ",
-				   sd.data.u.interf_ind.fn);
+				   msg.u.interf_ind.fn);
 		}
 		interf_ind_num := interf_ind_num + 1;
 		if (interf_ind_num < 4)
 			{ repeat; }
 		}
-	[not first] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_INTERF_IND(0, 0))) -> value sd {
-		setverdict(fail, "Received unexpected interference report: ", sd.data);
+	[not first] as_pcuif_msg(msg, tr_PCUIF_INTERF_IND(0, 0)) {
+		setverdict(fail, "Received unexpected interference report: ", msg);
 		}
 	[] PCU.receive { repeat; }
 	[] T.timeout {