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
This commit is contained in:
Harald Welte 2018-06-14 10:58:35 +02:00
parent e6bf4ac879
commit 641fcbe890
1 changed files with 19 additions and 40 deletions

View File

@ -667,9 +667,23 @@ runs on test_CT return DchanTuple {
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 @@ testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
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 @@ testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
/* 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 @@ testcase TC_chan_rel_conn_fail() runs on test_CT {
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 @@ testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
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 @@ testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
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 @@ testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
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 @@ testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
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