Change in osmo-ttcn3-hacks[master]: bsc: properly clean up conn after each test

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/.

neels gerrit-no-reply at lists.osmocom.org
Fri Dec 17 13:55:52 UTC 2021


neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/26621 )


Change subject: bsc: properly clean up conn after each test
......................................................................

bsc: properly clean up conn after each test

Make all tests clean up BSSAP conn and RSL link. Now all
f_verify_talloc_count() in f_shutdown_helper() should pass, verifying no
conn or bsc_subscr leaks.

Related: OS#5337
Change-Id: I9396efcabc085d2850244c6468b83c5f3a3ff3a2
---
M bsc/BSC_Tests.ttcn
1 file changed, 163 insertions(+), 16 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/21/26621/1

diff --git a/bsc/BSC_Tests.ttcn b/bsc/BSC_Tests.ttcn
index c9c9103..604c65e 100644
--- a/bsc/BSC_Tests.ttcn
+++ b/bsc/BSC_Tests.ttcn
@@ -1622,6 +1622,7 @@
 		}
 	[] BSSAP.receive { repeat; }
 	}
+	f_perform_clear_test_ct(dt);
 	f_shutdown_helper();
 }
 
@@ -1700,7 +1701,7 @@
 
 /* Run everything required up to sending a caller-specified assignment command and expect response */
 function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
-runs on test_CT {
+runs on test_CT return DchanTuple {
 	var BSSAP_N_CONNECT_ind rx_c_ind;
 	var RSL_Message rx_rsl;
 	var DchanTuple dt;
@@ -1727,13 +1728,15 @@
 		}
 	[] BSSAP.receive { repeat; }
 	}
+	return dt;
 }
 testcase TC_assignment_csd() runs on test_CT {
 	var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
 	var PDU_BSSAP ass_cmd := f_gen_ass_req();
 	ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
 	//exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
-	f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
+	var DchanTuple dt := f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
+	f_perform_clear_test_ct(dt);
 	f_shutdown_helper();
 }
 
@@ -1742,7 +1745,8 @@
 	var PDU_BSSAP ass_cmd := f_gen_ass_req();
 	ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
 	//exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
-	f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
+	var DchanTuple dt := f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
+	f_perform_clear_test_ct(dt);
 	f_shutdown_helper();
 }
 
@@ -1972,6 +1976,8 @@
 		{name := "TTCN3.bts.0.chan.rf_fail_sdcch", mtype := "c", min := 1, max := 1}
 	};
 	f_statsd_expect(expect);
+	BSSAP.receive(tr_BSSMAP_ClearRequest);
+	f_perform_clear();
 }
 testcase TC_stats_conn_fail() runs on test_CT {
 	var TestHdlrParams pars := f_gen_test_hdlr_pars();
@@ -2434,6 +2440,7 @@
 		/* Send MT message: BSSAP -> RSL */
 		f_mt_l3_transceive(RSL, link_id, dlci, l3);
 	}
+	f_perform_clear();
 }
 testcase TC_tch_dlci_link_id_sapi() runs on test_CT {
 	var TestHdlrParams pars := f_gen_test_hdlr_pars();
@@ -3545,8 +3552,10 @@
 	/* Expevct a CR with a matching Paging response on the A-Interface */
 	T.start;
 	alt {
-	[] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(rr_pag_resp))) {
+	[] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(rr_pag_resp))) -> value rx_c_ind {
 		setverdict(pass);
+		dt.sccp_conn_id := rx_c_ind.connectionId;
+		BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
 		}
 	[] BSSAP.receive {
 		setverdict(fail, "Received unexpected message on A-Interface!");
@@ -3556,6 +3565,7 @@
 		}
 	}
 
+	f_perform_clear_test_ct(dt);
 	f_shutdown_helper();
 }
 
@@ -3727,6 +3737,7 @@
 	exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
 
 	f_establish_fully(ass_cmd, exp_compl);
+	f_perform_clear();
 }
 testcase TC_ciph_mode_a5_0() runs on test_CT {
 	var MSC_ConnHdlr vc_conn;
@@ -3815,6 +3826,7 @@
 	ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
 
 	f_establish_fully(ass_cmd, exp_compl);
+	f_perform_clear();
 }
 testcase TC_assignment_aoip_tla_v6() runs on test_CT {
 	var MSC_ConnHdlr vc_conn;
@@ -3837,6 +3849,7 @@
 	ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
 
 	f_establish_fully(ass_cmd, exp_compl);
+	f_perform_clear();
 }
 testcase TC_assignment_fr_a5_0() runs on test_CT {
 	var MSC_ConnHdlr vc_conn;
@@ -3910,6 +3923,7 @@
 	/* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
 
 	f_establish_fully(ass_cmd, exp_fail);
+	f_perform_clear();
 }
 testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
 	var MSC_ConnHdlr vc_conn;
@@ -3941,6 +3955,7 @@
 
 	/* Start ciphering, expect Cipher Mode Reject */
 	f_cipher_mode(g_pars.encr, exp_fail := true);
+	f_perform_clear();
 }
 testcase TC_assignment_fr_a5_not_sup() runs on test_CT {
 	var TestHdlrParams pars := f_gen_test_hdlr_pars();
@@ -3972,6 +3987,7 @@
 		{ name := "TTCN3.bsc.0.assignment.completed", mtype := "c", min := 1, max := 1}
 	};
 	f_statsd_expect(expect);
+	f_perform_clear();
 }
 
 testcase TC_assignment_sign() runs on test_CT {
@@ -4114,6 +4130,10 @@
 type record of CodecListTest CodecListTests
 
 private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
+	f_assignment_codec(id);
+}
+
+private function f_assignment_codec(charstring id, boolean do_perform_clear := true) runs on MSC_ConnHdlr {
 	var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
 	var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
 
@@ -4168,6 +4188,10 @@
 			}
 		}
 	}
+
+	if (do_perform_clear) {
+		f_perform_clear();
+	}
 }
 
 private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
@@ -4184,6 +4208,7 @@
 	log("expecting ASS FAIL like this: ", exp_fail);
 
 	f_establish_fully(ass_cmd, exp_fail);
+	f_perform_clear();
 }
 
 const CounterNameVals counternames_bsc_bts_assignment := {
@@ -4697,6 +4722,7 @@
 	ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
 	ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
 	f_establish_fully(ass_cmd, exp_compl);
+	f_perform_clear();
 }
 
 /* Allow FR only */
@@ -4709,6 +4735,7 @@
 	ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
 	ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
 	f_establish_fully(ass_cmd, exp_compl);
+	f_perform_clear();
 }
 
 /* Allow HR only (expect assignment failure) */
@@ -4721,6 +4748,7 @@
 	ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
 	ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
 	f_establish_fully(ass_cmd, exp_fail);
+	f_perform_clear();
 }
 
 /* Allow FR only (expect assignment failure) */
@@ -4733,6 +4761,7 @@
 	ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
 	ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
 	f_establish_fully(ass_cmd, exp_fail);
+	f_perform_clear();
 }
 
 /* Allow FR and HR, but prefer FR */
@@ -4746,6 +4775,7 @@
 	ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
 	exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
 	f_establish_fully(ass_cmd, exp_compl);
+	f_perform_clear();
 }
 
 /* Allow FR and HR, but prefer HR */
@@ -4759,6 +4789,7 @@
 	ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
 	exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
 	f_establish_fully(ass_cmd, exp_compl);
+	f_perform_clear();
 }
 
 /* Allow FR and HR, but prefer FR */
@@ -4772,6 +4803,7 @@
 	ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
 	exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
 	f_establish_fully(ass_cmd, exp_compl);
+	f_perform_clear();
 }
 
 /* Allow FR and HR, but prefer HR */
@@ -4785,6 +4817,7 @@
 	ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
 	exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
 	f_establish_fully(ass_cmd, exp_compl);
+	f_perform_clear();
 }
 
 /* Request a HR channel while all FR channels are exhausted, this is expected
@@ -4910,6 +4943,7 @@
 	ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
 	exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
 	f_establish_fully(ass_cmd, exp_compl);
+	f_perform_clear();
 }
 
 /* Allow FR and HR, but prefer FR */
@@ -4923,6 +4957,7 @@
 	ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
 	exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
 	f_establish_fully(ass_cmd, exp_compl);
+	f_perform_clear();
 }
 
 /* Request a HR (prefered) or alternatively a FR channel, it is expected that
@@ -4973,6 +5008,8 @@
 		Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
 		}
 	}
+
+	f_perform_clear();
 }
 testcase TC_assignment_sdcch_exhausted_req_signalling() runs on test_CT {
 	var MSC_ConnHdlr vc_conn;
@@ -5035,6 +5072,7 @@
 		Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
 		}
 	}
+	f_perform_clear();
 }
 testcase TC_assignment_sdcch_exhausted_req_voice_tch_forbidden() runs on test_CT {
 	var MSC_ConnHdlr vc_conn;
@@ -5095,6 +5133,8 @@
 	f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
 	BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
 	setverdict(pass);
+
+	f_perform_clear();
 }
 testcase TC_classmark() runs on test_CT {
 	var MSC_ConnHdlr vc_conn;
@@ -5122,6 +5162,8 @@
 	f_vty_transceive_match_regexp_retry(BSCVTY, "show conns", regex, 0, 4, 1.0);
 
 	setverdict(pass);
+
+	f_perform_clear();
 }
 testcase TC_common_id() runs on test_CT {
 	var MSC_ConnHdlr vc_conn;
@@ -5160,6 +5202,7 @@
 private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
 	f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
 	f_bssap_expect_nothing();
+	f_perform_clear();
 }
 testcase TC_unsol_ass_fail() runs on test_CT {
 	var MSC_ConnHdlr vc_conn;
@@ -5175,6 +5218,7 @@
 private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
 	f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
 	f_bssap_expect_nothing();
+	f_perform_clear();
 }
 testcase TC_unsol_ass_compl() runs on test_CT {
 	var MSC_ConnHdlr vc_conn;
@@ -5190,6 +5234,7 @@
 private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
 	f_est_single_l3(ts_RRM_HandoverFailure('00'O));
 	f_bssap_expect_nothing();
+	f_perform_clear();
 }
 testcase TC_unsol_ho_fail() runs on test_CT {
 	var MSC_ConnHdlr vc_conn;
@@ -5210,6 +5255,7 @@
 	/* send short message */
 	RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
 	f_bssap_expect_nothing();
+	f_perform_clear();
 }
 testcase TC_err_82_short_msg() runs on test_CT {
 	var MSC_ConnHdlr vc_conn;
@@ -5232,6 +5278,7 @@
 	[] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
 	[] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
 	}
+	f_perform_clear();
 }
 testcase TC_err_84_unknown_msg() runs on test_CT {
 	var MSC_ConnHdlr vc_conn;
@@ -5338,6 +5385,8 @@
 
 	f_chan_act_verify_tsc(chan_act, BTS_TSC[1]);
 
+	f_perform_clear(RSL1, RSL1_PROC);
+
 	f_sleep(0.5);
 }
 
@@ -5488,7 +5537,9 @@
 			RSL1.send(ts_RSL_RF_CHAN_REL_ACK(new_chan_nr));
 			f_rslem_unregister(0, g_chan_nr, PT := RSL1_PROC);
 		}
-	[] BSSAP.receive(tr_BSSMAP_ClearComplete) {}
+	[] BSSAP.receive(tr_BSSMAP_ClearComplete) {
+			BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
+		}
 	}
 
 	f_sleep(0.5);
@@ -5604,7 +5655,9 @@
 	[] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE));
 	[] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr));
 	[] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr));
-	[] BSSAP.receive(tr_BSSMAP_ClearComplete);
+	[] BSSAP.receive(tr_BSSMAP_ClearComplete) {
+			BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
+		}
 	}
 	setverdict(pass);
 }
@@ -5711,6 +5764,7 @@
 
 	f_mo_l3_transceive();
 	f_sleep(1.0);
+	f_perform_clear();
 }
 testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
 	var MSC_ConnHdlr vc_conn;
@@ -5792,6 +5846,7 @@
 
 	setverdict(pass);
 	f_sleep(1.0);
+	f_perform_clear();
 }
 testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
 	var MSC_ConnHdlr vc_conn;
@@ -5889,6 +5944,7 @@
 
 	f_expect_dlcx_conns();
 	BSSAP.receive(tr_BSSMAP_ClearComplete);
+	BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
 
 	setverdict(pass);
 	f_sleep(1.0);
@@ -6222,6 +6278,7 @@
 
 	f_expect_dlcx_conns();
 	BSSAP.receive(tr_BSSMAP_ClearComplete);
+	BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
 
 	setverdict(pass);
 	f_sleep(1.0);
@@ -6315,6 +6372,7 @@
 
 	f_expect_dlcx_conns();
 	BSSAP.receive(tr_BSSMAP_ClearComplete);
+	BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
 
 	f_sleep(1.0);
 }
@@ -6404,6 +6462,7 @@
 
 	f_expect_dlcx_conns();
 	BSSAP.receive(tr_BSSMAP_ClearComplete);
+	BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
 
 	f_sleep(1.0);
 }
@@ -6485,6 +6544,7 @@
 	};
 	f_expect_dlcx_conns();
 	BSSAP.receive(tr_BSSMAP_ClearComplete);
+	BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
 
 	f_sleep(1.0);
 }
@@ -6700,6 +6760,8 @@
 	f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
 			"handover any to arfcn 871 bsic 11",
 			true, expect_target_tsc := BTS_TSC[1]);
+
+	f_perform_clear();
 }
 testcase TC_ho_neighbor_config_1() runs on test_CT {
 	var MSC_ConnHdlr vc_conn;
@@ -6764,6 +6826,7 @@
 	f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
 			"handover any to arfcn 871 bsic 12",
 			false);
+	f_perform_clear();
 }
 testcase TC_ho_neighbor_config_2() runs on test_CT {
 	var MSC_ConnHdlr vc_conn;
@@ -6815,6 +6878,7 @@
 	f_probe_for_handover("3.b", "HO to bts 2 works, explicitly listed as neighbor; no ambiguity because bts 3 is not listed as neighbor",
 			"handover any to arfcn 871 bsic 12",
 			true, expect_target_tsc := BTS_TSC[2]);
+	f_perform_clear();
 }
 testcase TC_ho_neighbor_config_3() runs on test_CT {
 	var MSC_ConnHdlr vc_conn;
@@ -6869,6 +6933,7 @@
 	f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
 			"handover any to arfcn 123 bsic 45",
 			true, true);
+	f_perform_clear();
 }
 testcase TC_ho_neighbor_config_4() runs on test_CT {
 	var MSC_ConnHdlr vc_conn;
@@ -6919,6 +6984,7 @@
 	f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
 			"handover any to arfcn 871 bsic 12",
 			true, true);
+	f_perform_clear();
 }
 testcase TC_ho_neighbor_config_5() runs on test_CT {
 	var MSC_ConnHdlr vc_conn;
@@ -6962,6 +7028,7 @@
 	f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
 			"handover any to arfcn 871 bsic 12",
 			false);
+	f_perform_clear();
 }
 testcase TC_ho_neighbor_config_6() runs on test_CT {
 	var MSC_ConnHdlr vc_conn;
@@ -7006,6 +7073,7 @@
 	f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
 			"handover any to arfcn 123 bsic 45",
 			true, true);
+	f_perform_clear();
 }
 testcase TC_ho_neighbor_config_7() runs on test_CT {
 	var MSC_ConnHdlr vc_conn;
@@ -7467,9 +7535,11 @@
 
 	/* Fill TS0 SDCCH channels (NOTE: only 3 SDCCH/4 channels are available
 	 * on CCCH+SDCCH4+CBCH) */
+	var DchanTuples sdcch_cleanup := {};
 	var integer i;
 	for (i := 0; i < NUM_SDCCH_PER_BTS; i := i + 1) {
 		dt := f_est_dchan('23'O, i, '00010203040506'O);
+		sdcch_cleanup := sdcch_cleanup & { dt };
 	}
 
 	/* Now the dyn ts is selected. First PDCH is released, then sdcch chan is activated */
@@ -7501,6 +7571,11 @@
 	f_sleep(1.0);
 	f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE);
 
+	/* Clean up SDCCH lchans */
+	for (i := 0; i < lengthof(sdcch_cleanup); i := i + 1) {
+		f_perform_clear_test_ct(sdcch_cleanup[i]);
+	}
+
 	/* clean up config */
 	f_ts_set_chcomb(0, 0, 6, "PDCH");
 
@@ -7523,7 +7598,7 @@
 	}
 	f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
 
-	f_init(1);
+	f_init(1, guard_timeout := 60.0);
 
 	/* The dyn TS want to activate PDCH mode, ACK that. */
 	var RslChannelNr chan_nr;
@@ -7537,15 +7612,21 @@
 	/* GSM 44.018 Table 9.1.8.2:
 	 * RA = '13'O -> Establishment cause = 0001xxxx (MS dual rate capable and asks for "SDCCH").
 	 */
+	var DchanTuples chan_cleanup := {};
 	for (i := 0; i < NUM_SDCCH_PER_BTS; i := i+1) {
-		f_est_dchan('13'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
+		chan_cleanup := chan_cleanup & { f_est_dchan('13'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O) };
 	}
 
 	/* Only the dyn TS is still available. Its first lchan gets converted to SDCCH8 */
-	f_est_dchan_dyn('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
+	chan_cleanup := chan_cleanup & { f_est_dchan_dyn('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O) };
 	/* Also occupy the seven other SDCCH of the dyn TS */
 	for (i := 0; i < 7; i := i+1) {
-		f_est_dchan('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
+		chan_cleanup := chan_cleanup & { f_est_dchan('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O) };
+	}
+
+	/* Clean up SDCCH lchans */
+	for (i := 0; i < lengthof(chan_cleanup); i := i + 1) {
+		f_perform_clear_test_ct(chan_cleanup[i]);
 	}
 
 	/* clean up config */
@@ -7591,9 +7672,11 @@
 
 	/* Fill TS0 SDCCH channels (NOTE: only 3 SDCCH/4 channels are available
 	 * on CCCH+SDCCH4+CBCH) */
+	var DchanTuples chan_cleanup := {};
 	var OCT1 ra := '43'O; /* RA containing reason=originating speech call*/
 	for (i := 0; i < NUM_SDCCH_PER_BTS; i := i + 1) {
 		dt := f_est_dchan(ra, i, '00010203040506'O);
+		chan_cleanup := chan_cleanup & { dt };
 	}
 
 	/* Now the dyn ts is selected. First PDCH is released, then TCH chan is activated */
@@ -7625,6 +7708,11 @@
 	f_sleep(1.0);
 	f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE);
 
+	/* Clean up SDCCH lchans */
+	for (i := 0; i < lengthof(chan_cleanup); i := i + 1) {
+		f_perform_clear_test_ct(chan_cleanup[i]);
+	}
+
 	/* clean up config */
 	f_ts_reset_chcomb(0);
 	/* TODO: clean up other channels? */
@@ -7661,9 +7749,11 @@
 
 	/* Fill TS0 SDCCH channels (NOTE: only 3 SDCCH/4 channels are available
 	 * on CCCH+SDCCH4+CBCH) */
+	var DchanTuples chan_cleanup := {};
 	var integer i;
 	for (i := 0; i < NUM_SDCCH_PER_BTS; i := i + 1) {
 		dt := f_est_dchan('23'O, i, '00010203040506'O);
+		chan_cleanup := chan_cleanup & { dt };
 	}
 
 	/* Now the dyn ts is selected. First PDCH is released, then sdcch chan is activated */
@@ -7691,6 +7781,11 @@
 	 * f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE)
 	 */
 
+	/* Clean up SDCCH lchans */
+	for (i := 0; i < lengthof(chan_cleanup); i := i + 1) {
+		f_perform_clear_test_ct(chan_cleanup[i]);
+	}
+
 	/* clean up config */
 	f_ts_set_chcomb(0, 0, 6, "PDCH");
 
@@ -7825,6 +7920,15 @@
 	deactivate(ack_rel_req);
 }
 
+private function f_perform_clear_test_ct(DchanTuple dt)
+	runs on test_CT
+{
+	/* Instruct BSC to clear channel */
+	var BssmapCause cause := 0;
+	BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
+	f_exp_chan_rel_and_clear(dt, 0);
+}
+
 private function f_perform_compl_l3(RSL_DCHAN_PT rsl_pt, RSLEM_PROC_PT rsl_proc_pt,
                                     template PDU_ML3_MS_NW l3_info, boolean do_clear := true, boolean expect_bssmap_l3 := true)
 runs on MSC_ConnHdlr {
@@ -8567,6 +8671,7 @@
 	}
 
 	setverdict(pass);
+	f_perform_clear();
 }
 
 /* Test if the EMERGENCY SETUP gets blocked by the BSC if EMERGENCY CALLS are
@@ -8589,6 +8694,8 @@
 		setverdict(fail, "timout waiting for RR CHANNEL RELEASE!");
 		}
 	}
+	BSSAP.receive(tr_BSSMAP_ClearRequest);
+	f_perform_clear();
 }
 
 /* EMERGENCY CALL situation #1, allowed globally and by BTS */
@@ -9076,6 +9183,8 @@
 			setverdict(fail, "FH disabled, but Mobile Allocation IE is present");
 			continue;
 		}
+
+		f_perform_clear_test_ct(dt);
 	}
 
 	/* Give the IUT some time to release all channels */
@@ -9147,6 +9256,8 @@
 		setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
 		return;
 	}
+
+	f_perform_clear_test_ct(dt);
 }
 testcase TC_fh_params_handover_cmd() runs on test_CT {
 	var FHParamsTrx fhp := f_TC_fh_params_gen();
@@ -9888,6 +9999,8 @@
 		}
 	}
 	T.stop;
+
+	f_perform_clear();
 }
 
 /* The BSC does *not* indicate BTS_FEAT_VAMOS; make sure that a channel Mode Modify to VAMOS mode is refused by
@@ -9937,7 +10050,7 @@
 
 private function f_TC_reassignment_codec(charstring id) runs on MSC_ConnHdlr {
 	/* First fully set up a speech lchan */
-	f_TC_assignment_codec(id);
+	f_assignment_codec(id, do_perform_clear := false);
 
 	/* Trigger re-assignment to another lchan */
 	var AssignmentState assignment_st := valueof(ts_AssignmentStateInit);
@@ -10235,6 +10348,8 @@
 
 	/* First send the Chan Act ACK */
 	var RslChannelNr chan_nr := chan_act.ies[0].body.chan_nr;
+	var DchanTuple dt;
+	dt.rsl_chan_nr := chan_nr;
 	var RSL_IE_Body chan_ident_ie;
 	if (not f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, chan_ident_ie)) {
 		setverdict(fail, "RSL Channel Identification IE is absent");
@@ -10255,9 +10370,11 @@
 
 	var BSSAP_N_CONNECT_ind rx_c_ind;
 	BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
+	dt.sccp_conn_id := rx_c_ind.connectionId;
 	BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
 
 	f_sleep(1.0);
+	f_perform_clear_test_ct(dt);
 	f_shutdown_helper();
 }
 
@@ -10280,6 +10397,8 @@
 
 	chan_act := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
 	var RslChannelNr chan_nr := chan_act.ies[0].body.chan_nr;
+	var DchanTuple dt;
+	dt.rsl_chan_nr := chan_nr;
 	var RSL_IE_Body chan_ident_ie;
 	if (not f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, chan_ident_ie)) {
 		setverdict(fail, "RSL Channel Identification IE is absent");
@@ -10300,9 +10419,11 @@
 
 	var BSSAP_N_CONNECT_ind rx_c_ind;
 	BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
+	dt.sccp_conn_id := rx_c_ind.connectionId;
 	BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
 
 	f_sleep(1.0);
+	f_perform_clear_test_ct(dt);
 	f_shutdown_helper();
 }
 
@@ -10325,6 +10446,8 @@
 
 	chan_act := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
 	var RslChannelNr chan_nr := chan_act.ies[0].body.chan_nr;
+	var DchanTuple dt;
+	dt.rsl_chan_nr := chan_nr;
 	var RSL_IE_Body chan_ident_ie;
 	if (not f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, chan_ident_ie)) {
 		setverdict(fail, "RSL Channel Identification IE is absent");
@@ -10345,9 +10468,11 @@
 
 	var BSSAP_N_CONNECT_ind rx_c_ind;
 	BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
+	dt.sccp_conn_id := rx_c_ind.connectionId;
 	BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
 
 	f_sleep(1.0);
+	f_perform_clear_test_ct(dt);
 	f_shutdown_helper();
 }
 
@@ -10395,6 +10520,8 @@
 
 	/* Now activation as SDCCH8 */
 	chan_nr := valueof(t_RslChanNr_SDCCH8(tn := 6, sub_slot := 0));
+	var DchanTuple dt;
+	dt.rsl_chan_nr := chan_nr;
 
 	chan_act := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
 	var RSL_IE_Body chan_ident_ie;
@@ -10417,9 +10544,11 @@
 
 	var BSSAP_N_CONNECT_ind rx_c_ind;
 	BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
+	dt.sccp_conn_id := rx_c_ind.connectionId;
 	BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
 
 	f_sleep(1.0);
+	f_perform_clear_test_ct(dt);
 	f_shutdown_helper();
 }
 
@@ -10472,6 +10601,8 @@
 
 	/* Now activation as SDCCH8 */
 	chan_nr := valueof(t_RslChanNr_SDCCH8(tn := 6, sub_slot := 0));
+	var DchanTuple dt;
+	dt.rsl_chan_nr := chan_nr;
 
 	chan_act := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
 	var RSL_IE_Body chan_ident_ie;
@@ -10490,9 +10621,11 @@
 
 	var BSSAP_N_CONNECT_ind rx_c_ind;
 	BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
+	dt.sccp_conn_id := rx_c_ind.connectionId;
 	BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
 
 	f_sleep(1.0);
+	f_perform_clear_test_ct(dt);
 	f_shutdown_helper();
 }
 
@@ -10596,6 +10729,8 @@
 	f_create_chan_and_exp();
 	/* we should now have a COMPL_L3 at the MSC */
 	BSSAP.send(ts_PDU_DTAP_MT(ts_CM_SERV_REJ('02'O), '00'O));
+	RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_CM_SERV_REJ));
+	f_perform_clear();
 	f_sleep(1.0);
 }
 testcase TC_cm_serv_rej() runs on test_CT {
@@ -10722,15 +10857,16 @@
 	var integer i;
 	var integer chreq_total, chreq_nochan;
 
-	f_init(1);
+	f_init(1, guard_timeout := 60.0);
 	f_sleep(1.0);
 
 	/* Exhaust all dedicated SDCCH lchans.
 	/* GSM 44.018 Table 9.1.8.2:
 	 * RA = '13'O -> Establishment cause = 0001xxxx (MS dual rate capable and asks for "SDCCH").
 	 */
+	var DchanTuples chan_cleanup := {};
 	for (i := 0; i < NUM_SDCCH_PER_BTS; i := i+1) {
-		f_est_dchan('13'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
+		chan_cleanup := chan_cleanup & { f_est_dchan('13'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O) };
 	}
 
 	/* Since only bts 0 is connected, expecting all_allocated to become true for both bts 0 and the "global" bsc
@@ -10740,13 +10876,18 @@
 
 	/* Also fill up all remaining (TCH) channels */
 	for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS; i := i+1) {
-		f_est_dchan('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
+		chan_cleanup := chan_cleanup & { f_est_dchan('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O) };
 	}
 
 	/* All TCH are now also occupied */
 	f_all_allocated_expect_counter_change({"all_allocated:sdcch", "all_allocated:static_sdcch",
 			"all_allocated:tch", "all_allocated:static_tch"});
 
+	/* Clean up SDCCH lchans */
+	for (i := 0; i < lengthof(chan_cleanup); i := i + 1) {
+		f_perform_clear_test_ct(chan_cleanup[i]);
+	}
+
 	f_shutdown_helper();
 }
 
@@ -10773,8 +10914,9 @@
 	/* GSM 44.018 Table 9.1.8.2:
 	 * RA = '13'O -> Establishment cause = 0001xxxx (MS dual rate capable and asks for "SDCCH").
 	 */
+	var DchanTuples chan_cleanup := {};
 	for (i := 0; i < NUM_SDCCH_PER_BTS; i := i+1) {
-		f_est_dchan('13'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
+		chan_cleanup := chan_cleanup & { f_est_dchan('13'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O) };
 	}
 
 	/* The static SDCCH should now be occupied, while still 3x8 dynamic SDCCH potentially remain. So only
@@ -10796,7 +10938,7 @@
 
 	/* occupy the remaining TCH, three TCH/F and two TCH/H lchans */
 	for (i := 0; i < 5; i := i+1) {
-		f_est_dchan('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
+		chan_cleanup := chan_cleanup & { f_est_dchan('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O) };
 	}
 
 	/* All TCH lchans are now also occupied, both static and dynamic */
@@ -10830,6 +10972,11 @@
 	/* Now all channels are occupied except the dyn TS, so expecting only the static counters to increment */
 	f_all_allocated_expect_counter_change({"all_allocated:static_sdcch", "all_allocated:static_tch"});
 
+	/* Clean up SDCCH lchans */
+	for (i := 0; i < lengthof(chan_cleanup); i := i + 1) {
+		f_perform_clear_test_ct(chan_cleanup[i]);
+	}
+
 	/* clean up config */
 	f_ts_reset_chcomb(0);
 

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/26621
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: I9396efcabc085d2850244c6468b83c5f3a3ff3a2
Gerrit-Change-Number: 26621
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211217/d73d36f6/attachment.htm>


More information about the gerrit-log mailing list