Change in osmo-ttcn3-hacks[master]: bsc: Factor out duplicated code into f_exp_chan_rel_and_clear()

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

Harald Welte gerrit-no-reply at lists.osmocom.org
Thu Jun 14 12:36:13 UTC 2018


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/9629 )

Change subject: bsc: Factor out duplicated code into f_exp_chan_rel_and_clear()
......................................................................

bsc: Factor out duplicated code into f_exp_chan_rel_and_clear()

There's a sequence of commands which was repeated over at least
four test cases.  Let's factor this out into the new
f_exp_chan_rel_and_clear() function, and use that function from
all the former copy+pasted sections.

Change-Id: Ic6791fce4e8787e38b818a12ed526d3e47f313ef
---
M bsc/BSC_Tests.ttcn
1 file changed, 19 insertions(+), 40 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/bsc/BSC_Tests.ttcn b/bsc/BSC_Tests.ttcn
index bab56d1..a5509fd 100644
--- a/bsc/BSC_Tests.ttcn
+++ b/bsc/BSC_Tests.ttcn
@@ -667,9 +667,23 @@
 	return dt;
 }
 
+/* expect RF CAN REL from BTS, acknowledge it and clear the MSC side */
+private function f_exp_chan_rel_and_clear(DchanTuple dt, integer bts_nr := 0) runs on test_CT {
+	var RSL_Message rx_rsl;
+	/* expect BSC to disable the channel */
+	rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
+	/* respond with CHAN REL ACK */
+	f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
+
+	/* expect Clear Complete from BSC */
+	BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
+
+	/* MSC disconnects as instructed. */
+	BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
+}
+
 /* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
 testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
-	var RSL_Message rx_rsl;
 	var BSSAP_N_DATA_ind rx_di;
 	var DchanTuple dt;
 
@@ -688,15 +702,7 @@
 	BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
 
 	/* expect BSC to disable the channel */
-	rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
-	/* respond with CHAN REL ACK */
-	f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
-
-	/* expect Clear Complete from BSC */
-	BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
-
-	/* release the SCCP connection */
-	BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
+	f_exp_chan_rel_and_clear(dt, 0);
 
 	/* wait for SCCP emulation to do its job */
 	f_sleep(1.0);
@@ -707,7 +713,6 @@
 /* Test behavior of channel release after CONN FAIL IND from BTS */
 testcase TC_chan_rel_conn_fail() runs on test_CT {
 	var BSSAP_N_DATA_ind rx_di;
-	var RSL_Message rx_rsl;
 	var DchanTuple dt;
 
 	f_init(1);
@@ -726,15 +731,7 @@
 	BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
 
 	/* expect BSC to disable the channel */
-	rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
-	/* respond with CHAN REL ACK */
-	f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
-
-	/* expect Clear Complete from BSC */
-	BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
-
-	/* release the SCCP connection */
-	BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
+	f_exp_chan_rel_and_clear(dt, 0);
 
 	/* wait for SCCP emulation to do its job */
 	f_sleep(1.0);
@@ -2092,7 +2089,6 @@
 	var integer i;
 	var DchanTuple dt;
 	var BSSAP_N_DATA_ind rx_di;
-	var RSL_Message rx_rsl;
 	var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
 	var BssmapCause cause := enum2int(cause_val);
 
@@ -2120,15 +2116,7 @@
 		BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
 
 		/* expect BSC to disable the channel */
-		rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
-		/* respond with CHAN REL ACK */
-		f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
-
-		/* expect Clear Complete from BSC */
-		BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
-
-		/* MSC disconnects as instructed. */
-		BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
+		f_exp_chan_rel_and_clear(dt, 0);
 	}
 
 	/* In the buggy behavior, a timeout of 2 seconds happens between above
@@ -2148,7 +2136,6 @@
 	var integer i;
 	var DchanTuple dt;
 	var BSSAP_N_DATA_ind rx_di;
-	var RSL_Message rx_rsl;
 	var integer j;
 
 	f_init();
@@ -2182,15 +2169,7 @@
 		BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
 
 		/* expect BSC to disable the channel */
-		rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
-		/* respond with CHAN REL ACK */
-		f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
-
-		/* expect Clear Complete from BSC */
-		BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
-
-		/* MSC disconnects as instructed. */
-		BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
+		f_exp_chan_rel_and_clear(dt, 0);
 	}
 
 	/* In the buggy behavior, a timeout of 2 seconds happens between above

-- 
To view, visit https://gerrit.osmocom.org/9629
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic6791fce4e8787e38b818a12ed526d3e47f313ef
Gerrit-Change-Number: 9629
Gerrit-PatchSet: 2
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180614/7f387442/attachment.htm>


More information about the gerrit-log mailing list