bsc: Use Misc_Helpers.f_shutdown for setverdict(fail)
Unfortunately all component.stop can not be called from the non-mtc
component. f_shutdown is a wrapper that will try to shutdown a test in
the best way calling all component.stop if it is called from the mtc and
just stopping the mtc if called from any other component.
Change-Id: I9b71f7f7bd70d2da21fbad60c340d5bf8b3b9536
diff --git a/bsc/MSC_ConnectionHandler.ttcn b/bsc/MSC_ConnectionHandler.ttcn
index dfdf10c..546fa2d 100644
--- a/bsc/MSC_ConnectionHandler.ttcn
+++ b/bsc/MSC_ConnectionHandler.ttcn
@@ -1,5 +1,6 @@
module MSC_ConnectionHandler {
+import from Misc_Helpers all;
import from General_Types all;
import from Osmocom_Types all;
import from GSM_Types all;
@@ -146,8 +147,9 @@
return i;
}
}
- setverdict(fail, "Only 2 Connections per EP!");
- mtc.stop;
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Only 2 Connections per EP!");
+ /* Should never be reached */
+ return -1;
}
/* Helper function to pick a specific connection by its cid. Since we reach out
@@ -159,8 +161,9 @@
return i;
}
}
- setverdict(fail, "No Connection for ID ", cid);
- mtc.stop;
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("No Connection for ID ", cid));
+ /* Should not be reached */
+ return -1;
}
/* altstep for handling of IPACC media related commands. Activated by as_Media() to test
@@ -188,8 +191,7 @@
/* Extract conn_id, ip, port, rtp_pt2 from request + use in response */
b_unused := f_rsl_find_ie(rsl, RSL_IE_IPAC_CONN_ID, ie);
if (g_media.bts.conn_id != ie.ipa_conn_id) {
- setverdict(fail, "IPA MDCX for unknown ConnId", rsl);
- mtc.stop;
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("IPA MDCX for unknown ConnId", rsl));
}
/* mandatory */
b_unused := f_rsl_find_ie(rsl, RSL_IE_IPAC_REMOTE_IP, ie);
@@ -232,8 +234,7 @@
/* Extract conn_id, ip, port, rtp_pt2 from request + use in response */
b_unused := f_rsl_find_ie(rsl, RSL_IE_IPAC_CONN_ID, ie);
if (g_media.bts1.conn_id != ie.ipa_conn_id) {
- setverdict(fail, "IPA MDCX for unknown ConnId", rsl);
- mtc.stop;
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("IPA MDCX for unknown ConnId", rsl));
}
/* mandatory */
b_unused := f_rsl_find_ie(rsl, RSL_IE_IPAC_REMOTE_IP, ie);
@@ -268,8 +269,7 @@
var integer cid := f_get_free_mgcp_conn();
if (match(mgcp_cmd.line.ep, t_MGCP_EP_wildcard)) {
if (cid != 0) {
- setverdict(fail, "MGCP wildcard EP only works in first CRCX");
- mtc.stop;
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "MGCP wildcard EP only works in first CRCX");
}
/* we keep the endpoint name allocated during MediaState_init */
} else {
@@ -305,7 +305,7 @@
g_media.mgcp_conn[cid].peer.host := sdp.connection.conn_addr.addr;
g_media.mgcp_conn[cid].peer.port_nr := sdp.media_list[0].media_field.ports.port_number;
} else {
- setverdict(fail, "MDCX has no [recognizable] SDP");
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "MDCX has no [recognizable] SDP");
}
var MgcpConnState mgcp_conn := g_media.mgcp_conn[cid];
sdp := valueof(ts_SDP(mgcp_conn.peer.host, mgcp_conn.peer.host, "foo", "21",
@@ -519,7 +519,7 @@
else if (alg_bssmap == '80'O) {
return RSL_ALG_ID_A5_7;
} else {
- setverdict(fail, "Unexpected Encryption Algorithm");
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected Encryption Algorithm");
return RSL_ALG_ID_A5_0;
}
}
@@ -553,14 +553,14 @@
[] BSSAP.receive(tr_BSSMAP_CipherModeCompl) -> value bssap {
// bssap.bssmap.cipherModeComplete.chosenEncryptionAlgorithm.algoritmhIdentifier
if (exp_fail == true) {
- setverdict(fail, "Unexpected Cipher Mode Complete");
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected Cipher Mode Complete");
} else {
setverdict(pass);
}
}
[] BSSAP.receive(tr_BSSMAP_CipherModeRej) -> value bssap {
if (exp_fail == false) {
- setverdict(fail, "Ciphering Mode Reject");
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Ciphering Mode Reject");
} else {
setverdict(pass);
}
@@ -586,13 +586,11 @@
chan_nr := valueof(t_RslChanNr_SDCCH8(tn, bit2int(substr(inp, 2, 3))));
}
else {
- setverdict(fail, "Unknown ChDesc!");
- mtc.stop;
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknown ChDesc!");
}
if (ch_desc.octet3 and4b '10'O == '10'O) {
- setverdict(fail, "No support for Hopping");
- mtc.stop;
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No support for Hopping");
} else {
var OCT2 concat := ch_desc.octet3 & ch_desc.octet4;
arfcn := oct2int(concat);
@@ -635,17 +633,17 @@
var RSL_IE_Body encr_info;
if (ispresent(g_pars.encr) and g_pars.encr.enc_alg != '01'O) {
if (not f_rsl_find_ie(chan_act, RSL_IE_ENCR_INFO, encr_info)) {
- setverdict(fail, "Missing Encryption IE in CHAN ACT");
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Missing Encryption IE in CHAN ACT");
} else {
var RSL_AlgId alg := f_chipher_mode_bssmap_to_rsl(g_pars.encr.enc_alg);
if (not match(encr_info, tr_EncrInfo(alg, g_pars.encr.enc_key))) {
- setverdict(fail, "Wrong Encryption IE in CHAN ACT");
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Wrong Encryption IE in CHAN ACT");
}
}
} else {
if (f_rsl_find_ie(chan_act, RSL_IE_ENCR_INFO, encr_info)) {
if (encr_info.encr_info.alg_id != RSL_ALG_ID_A5_0) {
- setverdict(fail, "Unexpected Encryption in CHAN ACT");
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected Encryption in CHAN ACT");
}
}
}
@@ -681,8 +679,7 @@
f_check_chan_act(st, chan_act);
repeat;
} else {
- setverdict(fail, "Unexpected L3 received", l3);
- mtc.stop;
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected L3 received", l3));
}
}
[st.rr_ass_cmpl_seen] RSL.receive(tr_RSL_REL_REQ(st.old_chan_nr, tr_RslLinkID_DCCH(0))) {
@@ -820,10 +817,10 @@
", mdcx_seen=", g_media.mgcp_conn[i].mdcx_seen, ", mdcx_seen_exp=", g_media.mgcp_conn[i].mdcx_seen_exp);
if(g_media.mgcp_conn[i].crcx_seen != g_media.mgcp_conn[i].crcx_seen_exp) {
- setverdict(fail, "unexpected number of MGW-CRCX transactions");
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "unexpected number of MGW-CRCX transactions");
}
if(g_media.mgcp_conn[i].mdcx_seen != g_media.mgcp_conn[i].mdcx_seen_exp) {
- setverdict(fail, "unexpected number of MGW-MDCX transactions");
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "unexpected number of MGW-MDCX transactions");
}
}
}
@@ -862,14 +859,10 @@
alt {
[] BSSAP.receive(exp_l3_compl);
[] BSSAP.receive(tr_BSSMAP_ComplL3) {
- setverdict(fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
- all component.stop;
- mtc.stop;
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
}
[] T.timeout {
- setverdict(fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
- all component.stop;
- mtc.stop;
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
}
}
@@ -965,29 +958,19 @@
[(st.is_assignment and st.assignment_done or
(not st.is_assignment and (st.modify_done or not exp_modify))) and
exp_compl] BSSAP.receive(tr_BSSMAP_AssignmentComplete) {
- setverdict(fail, "Received non-matching ASSIGNMENT COMPLETE");
- all component.stop;
- mtc.stop;
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching ASSIGNMENT COMPLETE");
}
[exp_compl] BSSAP.receive(tr_BSSMAP_AssignmentFail) {
- setverdict(fail, "Received unexpected ASSIGNMENT FAIL");
- all component.stop;
- mtc.stop;
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected ASSIGNMENT FAIL");
}
[not exp_compl] BSSAP.receive(tr_BSSMAP_AssignmentComplete) {
- setverdict(fail, "Received unexpected ASSIGNMENT COMPLETE");
- all component.stop;
- mtc.stop;
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected ASSIGNMENT COMPLETE");
}
[not exp_compl] BSSAP.receive(tr_BSSMAP_AssignmentFail) {
- setverdict(fail, "Received non-matching ASSIGNMENT FAIL");
- all component.stop;
- mtc.stop;
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching ASSIGNMENT FAIL");
}
[] T.timeout {
- setverdict(fail, "Timeout waiting for ASSIGNMENT COMPLETE");
- all component.stop;
- mtc.stop;
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for ASSIGNMENT COMPLETE");
}
}
log("g_media ", g_media);
@@ -1055,8 +1038,7 @@
st.mdcx_seen_before_ho := g_media.mgcp_conn[0].mdcx_seen;
repeat;
} else {
- setverdict(fail, "Unexpected L3 received", l3);
- mtc.stop;
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected L3 received", l3));
}
}
[st.rr_ho_cmpl_seen] as_Media_ipacc();