bsc: test TSC in various messages

In a recent osmo-bsc patch:

"allow explixit TSC Set and TSC on chan activ / modif / assignment"
c33eb8d56943b8981523754b081967e6ff5f245d
Ic665125255d7354f5499d10dda1dd866ab243d24

I accidentally changed the default behavior of the Training Sequence
Code sent to BTS and MS. So now, make sure that we verify the expected
Training Sequence Code in BSC_Tests, in:

RSL Channel Activate
RR Immediate Assignment
RR Assignment Command
RR Channel Mode Modify
RSL Mode Modify

Related: OS#5172 SYS#5315
Change-Id: Id67a949e0f61ec8123976eb8d336f04510c55c01
diff --git a/library/RSL_Emulation.ttcn b/library/RSL_Emulation.ttcn
index cb8b763..91fa2db 100644
--- a/library/RSL_Emulation.ttcn
+++ b/library/RSL_Emulation.ttcn
@@ -135,18 +135,37 @@
 }
 
 /* establish a dedicated channel using 'ra' */
-function f_chan_est(OCT1 ra, octetstring est_l3, template RslLinkId link_id, GsmFrameNumber fn := 23)
+function f_chan_est(OCT1 ra, octetstring est_l3, template RslLinkId link_id, GsmFrameNumber fn := 23,
+		    template uint3_t tsc := ?)
 runs on RSL_DchanHdlr {
 	var RSL_Message rx_rsl;
 	var GsmRrMessage rr;
 
 	/* request a channel to be established */
 	RSL.send(ts_RSLDC_ChanRqd(ra, fn));
+	/* At this point the BSC sends a CHAN ACTIV which we always ACK. Checking it below. */
 	/* expect immediate assignment */
 	rx_rsl := f_rx_or_fail(tr_RSL_IMM_ASSIGN);
 	rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
+	if (not match(rr.payload.imm_ass.chan_desc.tsc, tsc)) {
+		setverdict(fail, "Immediate Assignment: unexpected TSC in Channel Description: expected ", tsc, " got ",
+			   rr.payload.imm_ass.chan_desc.tsc);
+		mtc.stop;
+	}
 	g_chan_nr := rr.payload.imm_ass.chan_desc.chan_nr;
 	RSL.send(ts_RSL_EST_IND(g_chan_nr, valueof(link_id), est_l3));
+
+	/* Check above CHAN ACTIV */
+	var RSL_Message chan_act := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
+	var RSL_IE_Body ie;
+	if (f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, ie)) {
+		var uint3_t got_tsc := ie.chan_ident.ch_desc.v.tsc;
+		if (not match(got_tsc, tsc)) {
+			setverdict(fail, "RSL CHANnel ACTIVation: unexpected TSC in Channel Description: expected ",
+				   tsc, " got ", got_tsc);
+			mtc.stop;
+		}
+	}
 }
 
 function f_deact_chan(RSL_Cause cause) runs on RSL_DchanHdlr