bsc: add TC_imm_ass_pre_ts_ack_dyn_ts

Test the experimental 'immediate-assignment pre-ts-ack' implemented in
I19e6a3d614aa5ae24d64eed96caf53e6f0e8bb74

Related: SYS#5559
Change-Id: I2ae28cd92910d4bc341a88571599347a64a18fe5
diff --git a/bsc/BSC_Tests.ttcn b/bsc/BSC_Tests.ttcn
index 42d7b54..2471a50 100644
--- a/bsc/BSC_Tests.ttcn
+++ b/bsc/BSC_Tests.ttcn
@@ -9770,6 +9770,73 @@
 	f_shutdown_helper();
 }
 
+testcase TC_imm_ass_pre_ts_ack_dyn_ts() runs on test_CT {
+	/* change Timeslot 6 before f_init() starts RSL */
+	f_init_vty();
+	f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
+	f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
+
+	f_init(1, false);
+	f_sleep(1.0);
+
+	var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
+	/* The BSC will activate the dynamic PDCH by default, so confirm that */
+	f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
+	f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2323));
+
+	/* clean up timeslot 6 config, will only take effect when the OML drops the next time */
+	f_ts_set_chcomb(0, 0, 6, "PDCH");
+
+	/* block all static timeslots so that the dyn TS will be used */
+	f_disable_all_tch_f();
+	f_disable_all_tch_h();
+	f_disable_all_sdcch();
+
+	var RSL_Message chan_act;
+	var RSL_Message imm_ass;
+
+	f_init(1, false);
+	f_sleep(1.0);
+
+	f_vty_set_imm_ass(BSCVTY, 0, "pre-ts-ack");
+
+	/* RA containing reason=LU */
+	var GsmFrameNumber fn := 2342;
+	var uint8_t ra := 2;
+	f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(ra, 1), fn));
+
+	/* (set bts 0 cfg back to default) */
+	f_vty_set_imm_ass(BSCVTY);
+
+	/* Expect the dyn TS to deactivate PDCH first */
+	f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
+
+	/* And already the Immediate Assignment even before the PDCH Deact ACK */
+	imm_ass := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
+
+	/* continue the Osmo style PDCH Deact (usual chan rel) */
+	f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
+
+	/* Now activation as SDCCH8 */
+	chan_nr := valueof(t_RslChanNr_SDCCH8(tn := 6, sub_slot := 0));
+
+	chan_act := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
+	f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
+
+	f_verify_imm_ass(imm_ass, ra, fn, chan_nr);
+
+	/* Check that the lchan is working */
+	var octetstring l3 := '00010203040506'O;
+	f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
+
+	var BSSAP_N_CONNECT_ind rx_c_ind;
+	BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
+	BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
+
+	f_sleep(1.0);
+	f_shutdown_helper();
+}
+
 control {
 	/* CTRL interface testing */
 	execute( TC_ctrl_msc_connection_status() );
@@ -10063,6 +10130,7 @@
 	execute( TC_imm_ass_post_chan_ack() );
 	execute( TC_imm_ass_pre_chan_ack() );
 	execute( TC_imm_ass_pre_chan_ack_dyn_ts() );
+	execute( TC_imm_ass_pre_ts_ack_dyn_ts() );
 }
 
 }