Change in osmo-ttcn3-hacks[master]: PCU: introduce f_shutdown() to ensure proper tear down

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

fixeria gerrit-no-reply at lists.osmocom.org
Thu May 7 04:43:45 UTC 2020


fixeria has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/18082 )

Change subject: PCU: introduce f_shutdown() to ensure proper tear down
......................................................................

PCU: introduce f_shutdown() to ensure proper tear down

Most of existing test cases are built on top of the PCU interface
abstraction components (see PCUIF_Components.ttcn). This means
that during the test case execution, additional components are
running in parallel, among with the MTC (Main Test Component).

When a test case terminates, either normally or due to an error,
it may happen that the virtual BTS component is stopped before
the associated TDMA clock generator. In this situation, sending
a clock indication towards the stopped BTS component would
lead to a dynamic test case error.

Let's take the process of tear down under control, and ensure that
the clock generator is stopped first. To achieve that, every test
case needs to call f_shutdown() in case of an error, as well as
in case of the normal termination.

Note we cannot use the existing f_shutdown() from Misc_Helpers,
because doing 'all component.stop' does not gurantee that the
clock generator is stopped first, and I experienced at least
one DTE while trying to integrate it.

Change-Id: I6a859687d9605cc08c51ff44d946c279b79bedfa
Signed-off-by: Vadim Yanitskiy <axilirator at gmail.com>
---
M pcu/PCUIF_Components.ttcn
M pcu/PCU_Tests.ttcn
2 files changed, 142 insertions(+), 82 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, approved



diff --git a/pcu/PCUIF_Components.ttcn b/pcu/PCUIF_Components.ttcn
index c0266fb..aa2ab42 100644
--- a/pcu/PCUIF_Components.ttcn
+++ b/pcu/PCUIF_Components.ttcn
@@ -100,6 +100,7 @@
 /* Commands are mostly used by the MTC to configure the components
  * at run-time, e.g. to enable or disable some optional features. */
 type enumerated RAW_PCU_CommandType {
+	GENERAL_CMD_SHUTDOWN,		/*!< Shut down component and all its child components */
 	TDMA_CMD_ENABLE_PTCCH_UL_FWD	/*!< Enable forwarding of TDMA_EV_PTCCH_UL_BURST to the MTC */
 };
 
@@ -417,6 +418,11 @@
 	[] as_BTS_CT_TDMASched(bts_nr);
 
 	/* Command handling */
+	[] TC.receive(tr_RAW_PCU_CMD(GENERAL_CMD_SHUTDOWN)) {
+		log("Shutting down virtual BTS #", bts_nr, "...");
+		vc_CLCK_GEN.stop;
+		break;
+		}
 	[] TC.receive(tr_RAW_PCU_CMD(TDMA_CMD_ENABLE_PTCCH_UL_FWD)) {
 		log("Enabling forwarding of PTCCH/U TDMA events to the TC");
 		cfg_ptcch_burst_fwd := true;
diff --git a/pcu/PCU_Tests.ttcn b/pcu/PCU_Tests.ttcn
index a40819d..ac2aaf3 100644
--- a/pcu/PCU_Tests.ttcn
+++ b/pcu/PCU_Tests.ttcn
@@ -101,6 +101,11 @@
 }
 
 type component RAW_PCU_Test_CT extends bssgp_CT {
+	/* PCU interface abstraction component */
+	var RAW_PCUIF_CT vc_PCUIF;
+	/* Virtual BTS component */
+	var RAW_PCU_BTS_CT vc_BTS;
+
 	/* Connection to the BTS component (one for now) */
 	port RAW_PCU_MSG_PT BTS;
 	/* Connection to the PCUIF component */
@@ -140,7 +145,7 @@
 private altstep as_Tguard_RAW() runs on RAW_PCU_Test_CT {
 	[] g_T_guard.timeout {
 		setverdict(fail, "Timeout of T_guard");
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 		}
 }
 
@@ -189,9 +194,6 @@
 
 function f_init_raw(charstring id, template (value) PCUIF_info_ind info_ind := ts_PCUIF_INFO_default)
 runs on RAW_PCU_Test_CT {
-	var RAW_PCUIF_CT vc_PCUIF;
-	var RAW_PCU_BTS_CT vc_BTS;
-
 	/* Start the guard timer */
 	g_T_guard.start;
 	activate(as_Tguard_RAW());
@@ -215,6 +217,26 @@
 	BTS.receive(tr_RAW_PCU_EV(BTS_EV_SI13_NEGO));
 }
 
+private function f_shutdown(charstring file, integer line,
+			    boolean final := false)
+runs on RAW_PCU_Test_CT {
+	/* Determine if the test case was aborted in the middle */
+	if (not final) {
+		log("Test case ", testcasename(), " aborted at ", file, ":", line);
+	} else {
+		/* Guard verdict to avoid 'none' */
+		setverdict(pass);
+	}
+
+	/* Properly shutdown virtual BTS and its clock generator */
+	BTS.send(ts_RAW_PCU_CMD(GENERAL_CMD_SHUTDOWN));
+	vc_BTS.done; /* wait untill it's done */
+
+	/* Shutdown the others and MTC */
+	all component.stop;
+	mtc.stop;
+}
+
 template AckNackDescription t_AckNackDescription_init := {
 	final_ack := '0'B,
 	starting_seq_nr := 0,
@@ -432,7 +454,7 @@
 	rr_imm_ass := dec_GsmRrMessage(macblock);
 	if (not match(rr_imm_ass, tr_IMM_TBF_ASS())) {
 		setverdict(fail, "Failed to match Immediate Assignment: ", rr_imm_ass);
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 	f_pcuif_tx_data_cnf(pcu_msg);
 }
@@ -461,13 +483,13 @@
 	rr_pag_req1 := dec_GsmRrMessage(macblock);
 	if (not match(rr_pag_req1, tr_PAG_REQ1(tr_MI_LV(mi1)))) {
 		setverdict(fail, "Failed to match Paging Request Type 1: ", rr_pag_req1);
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	/* Make sure that received paging froup matches the expected one */
 	if (not match(pag_group_rx, pag_group)) {
 		setverdict(fail, "Paging group", pag_group_rx, " does not match expected ", pag_group);
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	f_pcuif_tx_data_cnf(pcu_msg);
@@ -515,7 +537,7 @@
 	var CodingScheme cs_mcs := f_rlcmac_block_len2cs_mcs(len)
 	if (not match(f_rlcmac_block_len2cs_mcs(len), exp_cs_mcs)) {
 		setverdict(fail, "Failed to match Coding Scheme exp ", exp_cs_mcs, " vs ", cs_mcs, " (", len, ")");
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 }
 
@@ -526,7 +548,7 @@
 	f_rx_rlcmac_dl_block(dl_block, dl_fn);
 	if (not match(dl_block, tr_RLCMAC_UL_ACK_NACK(ul_tfi := ?, tlli := ?))) {
 		setverdict(fail, "Failed to match Packet Uplink ACK / NACK");
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	poll_fn := dl_fn + f_rrbp_fn_delay(dl_block.ctrl.mac_hdr.rrbp);
@@ -539,7 +561,7 @@
 	f_rx_rlcmac_dl_block(dl_block, dl_fn);
 	if (not match(dl_block, tr_RLCMAC_DUMMY_CTRL())) {
 		setverdict(fail, "Failed to match Packet DUMMY DL");
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 }
 
@@ -550,7 +572,7 @@
 	f_rx_rlcmac_dl_block(dl_block, dl_fn);
 	if (not match(dl_block, tr_RLCMAC_DL_PACKET_ASS())) {
 		setverdict(fail, "Failed to match Packet Downlink Assignment");
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	poll_fn := dl_fn + f_rrbp_fn_delay(dl_block.ctrl.mac_hdr.rrbp);
@@ -563,7 +585,7 @@
         f_rx_rlcmac_dl_block(dl_block, dl_fn);
         if (not match(dl_block, tr_RLCMAC_UL_PACKET_ASS())) {
                 setverdict(fail, "Failed to match Packet Uplink Assignment");
-                mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
         }
 
         poll_fn := dl_fn + f_rrbp_fn_delay(dl_block.ctrl.mac_hdr.rrbp);
@@ -577,12 +599,15 @@
 	f_rx_rlcmac_dl_block(dl_block, dl_fn);
 	if (not match(dl_block, tr_RLCMAC_PACKET_PAG_REQ())) {
 		setverdict(fail, "Failed to match Packet Paging Request: ", dl_block, " vs ", tr_RLCMAC_PACKET_PAG_REQ());
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 }
 
-private function f_rlcmac_dl_block_verify_data_gprs(RlcmacDlBlock dl_block, uint32_t dl_fn, out uint32_t ack_fn, octetstring data, template (present) uint7_t exp_bsn := ?, template (present) CodingScheme exp_cs := ?)
-{
+private function f_rlcmac_dl_block_verify_data_gprs(RlcmacDlBlock dl_block, uint32_t dl_fn,
+						    out uint32_t ack_fn, octetstring data,
+						    template (present) uint7_t exp_bsn := ?,
+						    template (present) CodingScheme exp_cs := ?)
+runs on RAW_PCU_Test_CT {
 	log("verifying dl data block (gprs): ", dl_block);
 
 	ack_fn := dl_fn + f_rrbp_fn_delay(dl_block.data.mac_hdr.mac_hdr.rrbp);
@@ -594,31 +619,34 @@
 
 	if (lengthof(dl_block.data.blocks) < 1) {
 		setverdict(fail, "DL block has no LLC payload: ", dl_block);
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	if (ispresent(dl_block.data.blocks[0].hdr) and dl_block.data.blocks[0].hdr.length_ind != lengthof(data)) {
 		setverdict(fail, "DL block has LLC header with wrong expected size: ",
 			   dl_block.data.blocks[0].hdr.length_ind, " vs ", lengthof(data));
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	if (dl_block.data.blocks[0].payload != data) {
 		setverdict(fail, "Failed to match content of LLC payload in DL Block: ", dl_block, " vs ", data);
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	/* Check next data blocks contain dummy frames */
 	if (lengthof(dl_block.data.blocks) > 1 and substr(dl_block.data.blocks[1].payload, 0, 3) != '43C001'O) {
 		setverdict(fail, "Second data payload is not a dummy frame: ", dl_block.data.blocks[1].payload);
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	/* TODO: check exp_cs */
 }
 
-private function f_rlcmac_dl_block_verify_data_egprs(RlcmacDlBlock dl_block, uint32_t dl_fn, out uint32_t ack_fn, octetstring data, template (present) uint14_t exp_bsn := ?, template (present) CodingScheme exp_cs := ?)
-{
+private function f_rlcmac_dl_block_verify_data_egprs(RlcmacDlBlock dl_block, uint32_t dl_fn,
+						     out uint32_t ack_fn, octetstring data,
+						     template (present) uint14_t exp_bsn := ?,
+						     template (present) CodingScheme exp_cs := ?)
+runs on RAW_PCU_Test_CT {
 	log("verifying dl data block (egprs): ", dl_block);
 
 	ack_fn := dl_fn + f_rrbp_fn_delay(dl_block.data_egprs.mac_hdr.rrbp);
@@ -630,31 +658,34 @@
 
 	if (lengthof(dl_block.data_egprs.blocks) < 1) {
 		setverdict(fail, "DL block has no LLC payload: ", dl_block);
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	if (ispresent(dl_block.data_egprs.blocks[0].hdr) and dl_block.data_egprs.blocks[0].hdr.length_ind != lengthof(data)) {
 		setverdict(fail, "DL block has LLC header with wrong expected size: ",
 			   dl_block.data_egprs.blocks[0].hdr.length_ind, " vs ", lengthof(data));
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	if (dl_block.data_egprs.blocks[0].payload != data) {
 		setverdict(fail, "Failed to match content of LLC payload in DL Block: ", dl_block, " vs ", data);
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	/* Check next data blocks contain dummy frames */
 	if (lengthof(dl_block.data_egprs.blocks) > 1 and substr(dl_block.data_egprs.blocks[1].payload, 0, 3) != '43C001'O) {
 		setverdict(fail, "Second data payload is not a dummy frame: ", dl_block.data.blocks[1].payload);
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	/* TODO: Check exp_cs. In the case of EGPRS, first check mac_hdr.header_type and then decode CPS = exp_cs based on mac_hdr.header_type.
 		See wireshark's egprs_Header_type1_coding_puncturing_scheme_to_mcs. */
 }
 
-private function f_rx_rlcmac_dl_block_exp_data(out RlcmacDlBlock dl_block, out uint32_t ack_fn, octetstring data, template (present) uint7_t exp_bsn := ?, template (present) CodingScheme exp_cs := ?)
+private function f_rx_rlcmac_dl_block_exp_data(out RlcmacDlBlock dl_block, out uint32_t ack_fn,
+					       octetstring data,
+					       template (present) uint7_t exp_bsn := ?,
+					       template (present) CodingScheme exp_cs := ?)
 runs on RAW_PCU_Test_CT {
 	var PCUIF_Message pcu_msg;
 	var uint32_t dl_fn;
@@ -668,7 +699,7 @@
 		dl_template.data_egprs.blocks := ?;
 		if (not match(dl_block, dl_template)) {
 			setverdict(fail, "Failed to match Packet data: ", dl_block, " vs ", dl_template);
-			mtc.stop;
+			f_shutdown(__BFILE__, __LINE__);
 		}
 		is_egprs := true;
 	}
@@ -705,6 +736,8 @@
 		setverdict(fail, "Timeout waiting for BSSGP SUSPEND");
 		}
 	}
+
+	f_shutdown(__BFILE__, __LINE__, final := true);
 }
 
 /* Test of correct Timing Advance at the time of TBF establishment
@@ -723,7 +756,7 @@
 		ok := f_establish_tbf(rr_msg, bts_nr := 0, ta := ta);
 		if (not ok) {
 			setverdict(fail, "Failed to establish an Uplink TBF");
-			mtc.stop;
+			break;
 		}
 
 		/* Make sure Timing Advance IE matches out expectations */
@@ -731,9 +764,11 @@
 			setverdict(fail, "Timing Advance mismatch: ",
 				   rr_msg.payload.imm_ass.timing_advance,
 				   " vs expected ", ta);
-			mtc.stop;
+			break;
 		}
 	}
+
+	f_shutdown(__BFILE__, __LINE__, final := true);
 }
 
 /* Verify Timing Advance value(s) indicated during the packet Downlink assignment
@@ -764,8 +799,9 @@
 	 * the procedures defined in 3GPP TS 44.060 or use the polling mechanism. */
 	if (not match(rr_imm_ass, tr_IMM_TBF_ASS(ta := 0))) {
 		setverdict(fail, "Timing Advance value doesn't match");
-		mtc.stop;
 	}
+
+	f_shutdown(__BFILE__, __LINE__, final := true);
 }
 
 /* Verify that the PCU generates valid PTCCH/D messages
@@ -792,7 +828,7 @@
 	[] BTS.receive(PCUIF_Message:?) { repeat; }
 	[] T.timeout {
 		setverdict(fail, "Timeout waiting for a PTCCH/D block");
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 		}
 	}
 
@@ -803,8 +839,9 @@
 	 * TODO: do we expect all TA values to be equal '1111111'B? */
 	if (not match(ptcch_msg, tr_PTCCHDownlinkMsg)) {
 		setverdict(fail, "Malformed PTCCH/D message");
-		mtc.stop;
 	}
+
+	f_shutdown(__BFILE__, __LINE__, final := true);
 }
 
 /* Test of correct Timing Advance during an active Uplink TBF.
@@ -856,7 +893,9 @@
 	/* Send Access Bursts on PTCCH/U for every TA Index */
 	[] BTS.receive(tr_RAW_PCU_EV(TDMA_EV_PTCCH_UL_BURST)) -> value event {
 		ss := f_tdma_ptcch_fn2ss(event.data.tdma_fn);
-		if (ss < 0) { mtc.stop; } /* Shall not happen */
+		if (ss < 0) { /* Shall not happen */
+			f_shutdown(__BFILE__, __LINE__);
+		}
 
 		log("Sending an Access Burst on PTCCH/U",
 		    ", sub-slot=", ss, " (TAI)",
@@ -898,16 +937,13 @@
 		log("Rx PTCCH/D message: ", ta_msg);
 
 		/* Make sure Timing Advance values match our expectations */
-		if (match(ta_msg, t_ta_msg)) {
-			setverdict(pass);
-		} else {
+		if (not match(ta_msg, t_ta_msg)) {
 			setverdict(fail, "PTCCH/D message does not match: ", t_ta_msg);
 		}
 		}
 	[] BTS.receive { repeat; }
 	[] T.timeout {
 		setverdict(fail, "Timeout waiting for a PTCCH/D block");
-		mtc.stop;
 		}
 	}
 }
@@ -929,7 +965,7 @@
 		ok := f_establish_tbf(rr_msg[i], ta := 0);
 		if (not ok) {
 			setverdict(fail, "Failed to establish an Uplink TBF #", i);
-			mtc.stop;
+			break;
 		}
 
 		/* Make sure we received an UL TBF Assignment */
@@ -938,14 +974,14 @@
 			log("Rx Uplink TBF assignment for #", i, ": ", ul_tbf_ass[i]);
 		} else {
 			setverdict(fail, "Failed to match UL TBF Assignment for #", i);
-			mtc.stop;
+			break;
 		}
 
 		/* We expect incremental TFI/USF assignment (dynamic allocation) */
 		t_ul_tbf_ass := tr_PacketUlDynAssign(tfi := i, usf := i);
 		if (not match(ul_tbf_ass[i], t_ul_tbf_ass)) {
 			setverdict(fail, "Failed to match Packet Uplink Assignment for #", i);
-			mtc.stop;
+			break;
 		}
 
 		/* We also expect Timing Advance Index to be a part of the assignment */
@@ -979,6 +1015,8 @@
 		tai3_ta := 28, tai4_ta := 35, tai5_ta := 42,
 		/* Other values are out of our interest */
 		tai6_ta := ?));
+
+	f_shutdown(__BFILE__, __LINE__, final := true);
 }
 
 /* Default link quality adaptation (Coding Scheme) ranges (inclusive).
@@ -1010,13 +1048,13 @@
 	ok := f_establish_tbf(rr_imm_ass);
 	if (not ok) {
 		setverdict(fail, "Failed to establish TBF");
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	ok := f_imm_ass_verify_ul_tbf_ass(rr_imm_ass, ul_tbf_ass);
 	if (not ok) {
 		setverdict(fail, "Immediate Assignment not an Uplink TBF");
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	var template (value) RlcmacUlBlock ul_data := t_RLCMAC_UL_DATA(
@@ -1068,10 +1106,10 @@
 
 		if (not match(dl_block.ctrl.payload.u.ul_ack_nack.gprs.ch_coding_cmd, ch_coding)) {
 			setverdict(fail, "Channel Coding does not match our expectations: ", ch_coding);
-		} else {
-			setverdict(pass);
 		}
 	}
+
+	f_shutdown(__BFILE__, __LINE__, final := true);
 }
 
 /* Test the max UL CS set by VTY works fine */
@@ -1099,13 +1137,13 @@
 	ok := f_establish_tbf(rr_imm_ass);
 	if (not ok) {
 		setverdict(fail, "Failed to establish TBF");
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	ok := f_imm_ass_verify_ul_tbf_ass(rr_imm_ass, ul_tbf_ass);
 	if (not ok) {
 		setverdict(fail, "Immediate Assignment not an Uplink TBF");
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	var template (value) RlcmacUlBlock ul_data := t_RLCMAC_UL_DATA(
@@ -1133,11 +1171,8 @@
 
 	if (last_ch_coding != CH_CODING_CS3) {
 		setverdict(fail, "Channel Coding does not match our expectations (CS-3): ", last_ch_coding);
-		mtc.stop;
 	}
 
-	setverdict(pass);
-
 	/* Remaining UL blocks are used to make sure regardless of initial
 	/* lqual, we can go lower at any time */
 
@@ -1158,9 +1193,9 @@
 
 	if (last_ch_coding != CH_CODING_CS1) {
 		setverdict(fail, "Channel Coding does not match our expectations (CS-1): ", last_ch_coding);
-	} else {
-		setverdict(pass);
 	}
+
+	f_shutdown(__BFILE__, __LINE__, final := true);
 }
 
 /* Test the max UL CS set by VTY works fine */
@@ -1184,13 +1219,13 @@
 	ok := f_establish_tbf(rr_imm_ass);
 	if (not ok) {
 		setverdict(fail, "Failed to establish TBF");
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	ok := f_imm_ass_verify_ul_tbf_ass(rr_imm_ass, ul_tbf_ass);
 	if (not ok) {
 		setverdict(fail, "Immediate Assignment not an Uplink TBF");
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	var template (value) RlcmacUlBlock ul_data := t_RLCMAC_UL_DATA(
@@ -1219,9 +1254,9 @@
 
 	if (last_ch_coding != CH_CODING_CS3) {
 		setverdict(fail, "Channel Coding does not match our expectations (CS-3): ", last_ch_coding);
-	} else {
-		setverdict(pass);
 	}
+
+	f_shutdown(__BFILE__, __LINE__, final := true);
 }
 
 /* Verify PCU drops TBF after some time of inactivity. */
@@ -1254,13 +1289,13 @@
 	ok := f_establish_tbf(rr_imm_ass);
 	if (not ok) {
 		setverdict(fail, "Failed to establish TBF");
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	ok := f_imm_ass_verify_ul_tbf_ass(rr_imm_ass, ul_tbf_ass);
 	if (not ok) {
 		setverdict(fail, "Immediate Assignment not an Uplink TBF");
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	/* Send one UL block and make sure it is ACKED fine */
@@ -1275,6 +1310,8 @@
 	/* Send an UL block once again, the TBF should be gone by now so no ACK */
 	f_tx_rlcmac_ul_n_blocks(ul_tbf_ass, 1);
 	f_rx_rlcmac_dl_block_exp_dummy(dl_block);
+
+	f_shutdown(__BFILE__, __LINE__, final := true);
 }
 
 /* Verify that a Downlink TBF can be assigned using PACCH shortly after the
@@ -1306,7 +1343,7 @@
 	ok := f_imm_ass_verify_dl_tbf_ass(rr_imm_ass, dl_tbf_ass);
 	if (not ok) {
 		setverdict(fail, "Immediate Assignment not a Downlink TBF");
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 	/* Wait timer X2002 and DL block is available after CCCH IMM ASS: */
 	f_sleep(X2002);
@@ -1329,6 +1366,8 @@
 	f_rx_rlcmac_dl_block_exp_data(dl_block, sched_fn, data, 0);
 	f_acknackdesc_ack_block(ack_nack_desc, dl_block, '1'B);
 	f_tx_rlcmac_ul_block(ts_RLCMAC_DL_ACK_NACK(f_rlcmac_dl_block_get_tfi(dl_block), ack_nack_desc), 0, sched_fn);
+
+	f_shutdown(__BFILE__, __LINE__, final := true);
 }
 
 /* Test scenario where MS wants to send some data on PDCH against SGSN and it is
@@ -1360,12 +1399,12 @@
 	ok := f_establish_tbf(rr_imm_ass);
 	if (not ok) {
 		setverdict(fail, "Failed to establish TBF");
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 	ok := f_imm_ass_verify_ul_tbf_ass(rr_imm_ass, ul_tbf_ass);
 	if (not ok) {
 		setverdict(fail, "Immediate Assignment not an Uplink TBF");
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	if (not istemplatekind(ms_racap, "omit")) {
@@ -1376,7 +1415,7 @@
 		f_rx_rlcmac_dl_block_exp_pkt_ul_ass(dl_block, sched_fn);
 		if (dl_block.ctrl.payload.u.ul_assignment.identity.tlli.tlli != tlli) {
 			setverdict(fail, "Wrong TLLI ", dl_block.ctrl.payload.u.ul_assignment.identity.tlli, " received vs exp ", tlli);
-			mtc.stop;
+			f_shutdown(__BFILE__, __LINE__);
 		}
 	}
 
@@ -1396,7 +1435,7 @@
 	ok := f_imm_ass_verify_dl_tbf_ass(rr_imm_ass, dl_tbf_ass);
 	if (not ok) {
 		setverdict(fail, "Immediate Assignment not a Downlink TBF");
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	/* Wait timer X2002 and DL block is available after CCCH IMM ASS: */
@@ -1406,6 +1445,8 @@
 	/* ACK the DL block */
 	f_acknackdesc_ack_block(ack_nack_desc, dl_block, '1'B);
 	f_tx_rlcmac_ul_block(ts_RLCMAC_DL_ACK_NACK(f_rlcmac_dl_block_get_tfi(dl_block), ack_nack_desc), 0, sched_fn);
+
+	f_shutdown(__BFILE__, __LINE__, final := true);
 }
 
 /* Test scenario where MS wants to send some data on PDCH against SGSN and it is
@@ -1460,7 +1501,7 @@
 	ok := f_imm_ass_verify_dl_tbf_ass(rr_imm_ass, dl_tbf_ass);
 	if (not ok) {
 		setverdict(fail, "Immediate Assignment not a Downlink TBF");
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	/* Wait timer X2002 and DL block is available after CCCH IMM ASS: */
@@ -1475,12 +1516,12 @@
 	ok := f_establish_tbf(rr_imm_ass);
 	if (not ok) {
 		setverdict(fail, "Failed to establish TBF");
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 	ok := f_imm_ass_verify_ul_tbf_ass(rr_imm_ass, ul_tbf_ass);
 	if (not ok) {
 		setverdict(fail, "Immediate Assignment not an Uplink TBF");
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	/* Send one UL block and make sure it is ACKED fine */
@@ -1491,6 +1532,8 @@
 
 	/* UL block should be received in SGSN */
 	BSSGP[0].receive(tr_BSSGP_UL_UD(tlli, mp_gb_cfg.cell_id));
+
+	f_shutdown(__BFILE__, __LINE__, final := true);
 }
 
 testcase TC_mt_ping_pong() runs on RAW_PCU_Test_CT {
@@ -1539,7 +1582,7 @@
 	ok := f_imm_ass_verify_dl_tbf_ass(rr_imm_ass, dl_tbf_ass);
 	if (not ok) {
 		setverdict(fail, "Immediate Assignment not a Downlink TBF");
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	/* Wait timer X2002 and DL block is available after CCCH IMM ASS: */
@@ -1553,7 +1596,7 @@
 	ok := f_imm_ass_verify_dl_tbf_ass(rr_imm_ass, dl_tbf_ass);
 	if (not ok) {
 	 	setverdict(fail, "Immediate Assignment not a Downlink TBF");
-	 	mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 	/* Wait timer X2002 and DL block is available after CCCH IMM ASS: */
 	f_sleep(X2002);
@@ -1562,35 +1605,40 @@
 	/* ACK the DL block */
 	f_acknackdesc_ack_block(ack_nack_desc, dl_block, '1'B);
 	f_tx_rlcmac_ul_block(ts_RLCMAC_DL_ACK_NACK(f_rlcmac_dl_block_get_tfi(dl_block), ack_nack_desc), 0, sched_fn);
+
+	f_shutdown(__BFILE__, __LINE__, final := true);
 }
 
-private function f_pkt_paging_match_imsi(in PacketPagingReq req, hexstring imsi) {
+private function f_pkt_paging_match_imsi(in PacketPagingReq req, hexstring imsi)
+runs on RAW_PCU_Test_CT {
 	var MobileIdentityLV_Paging mi_lv := req.repeated_pageinfo.cs.mobile_identity;
 	var MobileIdentityV mi := dec_MobileIdentityV(mi_lv.mobile_id);
 
 	if (mi_lv.len != 8) { /* 8 octets: type of ID (3 bits) + even/odd flag (1 bit) + 15 BCD-encoded digits (60 bits) */
 		setverdict(fail, "Mobile Identity length mismatch: ",
 			   "expected: 8, got: ", mi_lv.len);
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	/* Make sure MI contains IMSI before referencing it */
 	if (mi.typeOfIdentity != '001'B) {
 		setverdict(fail, "Mobile Identity must be of type IMSI ('001'B), ",
 			   "got: ", mi.typeOfIdentity);
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	} else if (mi.oddEvenInd_identity.imsi.digits != imsi) {
 		setverdict(fail, "Mobile Identity contains unexpected IMSI, ",
 			   "expected: ", imsi, " got: ", mi.oddEvenInd_identity.imsi.digits);
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 }
 
-private function f_pkt_paging_match_tmsi(in PacketPagingReq req, template GsmTmsi tmsi) {
+private function f_pkt_paging_match_tmsi(in PacketPagingReq req, template GsmTmsi tmsi)
+runs on RAW_PCU_Test_CT {
+	var MobileIdentityLV_Paging mi_lv := req.repeated_pageinfo.cs.mobile_identity;
 	if (not match(req.repeated_pageinfo.cs.tmsi, tmsi)) {
 		setverdict(fail, "Mobile Identity (TMSI/P-TMSI) mismatch: ",
 			   "expected: ", tmsi, "got: ", req.repeated_pageinfo.cs.tmsi);
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 }
 
@@ -1626,13 +1674,13 @@
 	ok := f_establish_tbf(rr_imm_ass);
 	if (not ok) {
 		setverdict(fail, "Failed to establish TBF");
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	ok := f_imm_ass_verify_ul_tbf_ass(rr_imm_ass, ul_tbf_ass);
 	if (not ok) {
 		setverdict(fail, "Immediate Assignment not an Uplink TBF");
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 
@@ -1649,7 +1697,7 @@
 	/* Make sure that Packet Paging Request contains the same IMSI */
 	f_pkt_paging_match_imsi(dl_block.ctrl.payload.u.paging, imsi);
 
-	setverdict(pass);
+	f_shutdown(__BFILE__, __LINE__, final := true);
 }
 
 /* Test CS paging over Gb (SGSN->PCU->BTS[PDCH]).
@@ -1678,13 +1726,13 @@
 	ok := f_establish_tbf(rr_imm_ass);
 	if (not ok) {
 		setverdict(fail, "Failed to establish TBF");
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	ok := f_imm_ass_verify_ul_tbf_ass(rr_imm_ass, ul_tbf_ass);
 	if (not ok) {
 		setverdict(fail, "Immediate Assignment not an Uplink TBF");
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	/* Send paging request with or without TMSI */
@@ -1705,7 +1753,7 @@
 		f_pkt_paging_match_imsi(dl_block.ctrl.payload.u.paging, imsi);
 	}
 
-	setverdict(pass);
+	f_shutdown(__BFILE__, __LINE__, final := true);
 }
 
 testcase TC_paging_cs_from_sgsn_sign_ptmsi() runs on RAW_PCU_Test_CT {
@@ -1749,7 +1797,7 @@
 		f_pcuif_rx_pch_pag_req1(tr_MI_IMSI(imsi), imsi_suff_tx);
 	}
 
-	setverdict(pass);
+	f_shutdown(__BFILE__, __LINE__, final := true);
 }
 
 testcase TC_paging_ps_from_sgsn_sign_ptmsi() runs on RAW_PCU_Test_CT {
@@ -1778,12 +1826,12 @@
 	ok := f_establish_tbf(rr_msg, ra := ra11, is_11bit := 1, burst_type := bt);
 	if (not ok) {
 		setverdict(fail, "Failed to establush an Uplink TBF");
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	if (not match(rr_msg, t_imm_ass)) {
 		setverdict(fail, "Immediate Assignment does not match");
-		mtc.stop;
+		f_shutdown(__BFILE__, __LINE__);
 	}
 
 	setverdict(pass);
@@ -1813,6 +1861,8 @@
 
 		f_TC_egprs_pkt_chan_req(req, imm_ass);
 	}
+
+	f_shutdown(__BFILE__, __LINE__, final := true);
 }
 
 testcase TC_egprs_pkt_chan_req_one_phase() runs on RAW_PCU_Test_CT {
@@ -1845,6 +1895,8 @@
 
 		f_TC_egprs_pkt_chan_req(req, imm_ass);
 	}
+
+	f_shutdown(__BFILE__, __LINE__, final := true);
 }
 
 testcase TC_egprs_pkt_chan_req_two_phase() runs on RAW_PCU_Test_CT {
@@ -1875,6 +1927,8 @@
 
 		f_TC_egprs_pkt_chan_req(req, imm_ass);
 	}
+
+	f_shutdown(__BFILE__, __LINE__, final := true);
 }
 
 control {

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/18082
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I6a859687d9605cc08c51ff44d946c279b79bedfa
Gerrit-Change-Number: 18082
Gerrit-PatchSet: 4
Gerrit-Owner: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200507/9e8f3f68/attachment.htm>


More information about the gerrit-log mailing list