summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2018-03-20 21:09:55 +0100
committerHarald Welte <laforge@gnumonks.org>2018-03-21 22:48:14 +0100
commita0630034bde6745fbe2a674c3b910b64217c7fa2 (patch)
tree04442be9dbeaad5a5724814dc1e4d5da273ce41f
parent458fd37fb94cc34986719a0e5b52f552d9d34e27 (diff)
bsc: Move TestHdlrParams to global per-component var g_pars
-rw-r--r--bsc/BSC_Tests.ttcn54
-rw-r--r--bsc/MSC_ConnectionHandler.ttcn11
2 files changed, 38 insertions, 27 deletions
diff --git a/bsc/BSC_Tests.ttcn b/bsc/BSC_Tests.ttcn
index ea90f06..94f38fd 100644
--- a/bsc/BSC_Tests.ttcn
+++ b/bsc/BSC_Tests.ttcn
@@ -1,7 +1,7 @@
module BSC_Tests {
/* Integration Tests for OsmoBSC
- * (C) 2017 by Harald Welte <laforge@gnumonks.org>
+ * (C) 2017-2018 by Harald Welte <laforge@gnumonks.org>
* All rights reserved.
*
* Released under the terms of GNU General Public License, Version 2 or
@@ -1397,7 +1397,8 @@ import from MSC_ConnectionHandler all;
type function void_fn(charstring id) runs on MSC_ConnHdlr;
/* helper function to create, connect and start a MSC_ConnHdlr component */
-function f_start_handler(void_fn fn, charstring id) runs on test_CT return MSC_ConnHdlr {
+function f_start_handler(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
+runs on test_CT return MSC_ConnHdlr {
var MSC_ConnHdlr vc_conn;
vc_conn := MSC_ConnHdlr.create(id);
@@ -1411,12 +1412,21 @@ function f_start_handler(void_fn fn, charstring id) runs on test_CT return MSC_C
}
connect(vc_conn:BSSAP, g_bssap.vc_BSSMAP:CLIENT);
connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
- vc_conn.start(derefers(fn)(id));
+ vc_conn.start(f_handler_init(fn, id, pars));
return vc_conn;
}
+/* first function inside ConnHdlr component; sets g_pars + starts function */
+private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
+runs on MSC_ConnHdlr {
+ if (isvalue(pars)) {
+ g_pars := valueof(pars);
+ }
+ fn.apply(id);
+}
+
private function f_tc_assignment_fr_a5_0(charstring id) runs on MSC_ConnHdlr {
- var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
+ g_pars := valueof(t_def_TestHdlrPars);
var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?);
var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
@@ -1425,7 +1435,7 @@ private function f_tc_assignment_fr_a5_0(charstring id) runs on MSC_ConnHdlr {
ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
- f_establish_fully(pars, ass_cmd, exp_compl);
+ f_establish_fully(ass_cmd, exp_compl);
f_cipher_mode('01'O, kc);
}
@@ -1442,7 +1452,7 @@ testcase TC_assignment_fr_a5_0() runs on test_CT {
private function f_tc_assignment_fr_a5_1(charstring id) runs on MSC_ConnHdlr {
- var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
+ g_pars := valueof(t_def_TestHdlrPars);
var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?);
var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
@@ -1452,7 +1462,7 @@ private function f_tc_assignment_fr_a5_1(charstring id) runs on MSC_ConnHdlr {
ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
- f_establish_fully(pars, ass_cmd, exp_compl);
+ f_establish_fully(ass_cmd, exp_compl);
f_cipher_mode('02'O, kc);
}
@@ -1468,14 +1478,14 @@ testcase TC_assignment_fr_a5_1() runs on test_CT {
/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
- var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
+ g_pars := valueof(t_def_TestHdlrPars);
var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
const OCT8 kc := '0001020304050607'O;
ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
- f_establish_fully(pars, ass_cmd, exp_fail);
+ f_establish_fully(ass_cmd, exp_fail);
}
testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
@@ -1490,7 +1500,7 @@ testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
private function f_tc_assignment_fr_a5_3(charstring id ) runs on MSC_ConnHdlr {
- var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
+ g_pars := valueof(t_def_TestHdlrPars);
var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?);
var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
@@ -1499,7 +1509,7 @@ private function f_tc_assignment_fr_a5_3(charstring id ) runs on MSC_ConnHdlr {
ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
- f_establish_fully(pars, ass_cmd, exp_compl);
+ f_establish_fully(ass_cmd, exp_compl);
f_cipher_mode('08'O, kc);
}
@@ -1515,7 +1525,7 @@ testcase TC_assignment_fr_a5_3() runs on test_CT {
private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
- var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
+ g_pars := valueof(t_def_TestHdlrPars);
var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?);
var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
@@ -1524,7 +1534,7 @@ private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
- f_establish_fully(pars, ass_cmd, exp_compl);
+ f_establish_fully(ass_cmd, exp_compl);
f_cipher_mode('10'O, kc, kc128, true);
/* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
}
@@ -1546,7 +1556,7 @@ private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, omit));
ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
- f_establish_fully(pars, ass_cmd, exp_compl);
+ f_establish_fully(ass_cmd, exp_compl);
}
testcase TC_assignment_sign() runs on test_CT {
@@ -1561,8 +1571,8 @@ testcase TC_assignment_sign() runs on test_CT {
/* test if L3 RR CLASSMARK CHANGE is translated to BSSMAP CLASSMARK UPDATE */
private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
- var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
- f_create_chan_and_exp(pars);
+ g_pars := valueof(t_def_TestHdlrPars);
+ f_create_chan_and_exp();
/* we should now have a COMPL_L3 at the MSC */
BSSAP.receive(tr_BSSMAP_ComplL3);
@@ -1579,8 +1589,8 @@ testcase TC_classmark() runs on test_CT {
}
private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
- var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
- f_create_chan_and_exp(pars);
+ g_pars := valueof(t_def_TestHdlrPars);
+ f_create_chan_and_exp();
/* we should now have a COMPL_L3 at the MSC */
BSSAP.receive(tr_BSSMAP_ComplL3);
@@ -1647,8 +1657,8 @@ testcase TC_unsol_ho_fail() runs on test_CT {
/* short message from MS should be ignored */
private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
- var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
- f_create_chan_and_exp(pars);
+ g_pars := valueof(t_def_TestHdlrPars);
+ f_create_chan_and_exp();
/* we should now have a COMPL_L3 at the MSC */
BSSAP.receive(tr_BSSMAP_ComplL3);
@@ -1717,7 +1727,7 @@ runs on MSC_ConnHdlr {
/* intra-BSC hand-over between BTS0 and BTS1 */
private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
- var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
+ g_pars := valueof(t_def_TestHdlrPars);
var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?);
var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
@@ -1726,7 +1736,7 @@ private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
- f_establish_fully(pars, ass_cmd, exp_compl);
+ f_establish_fully(ass_cmd, exp_compl);
var HandoverState hs := {
rr_ho_cmpl_seen := false,
diff --git a/bsc/MSC_ConnectionHandler.ttcn b/bsc/MSC_ConnectionHandler.ttcn
index 7c5a6d7..32f834d 100644
--- a/bsc/MSC_ConnectionHandler.ttcn
+++ b/bsc/MSC_ConnectionHandler.ttcn
@@ -296,6 +296,7 @@ type component MSC_ConnHdlr extends BSSAP_ConnHdlr, RSL_DchanHdlr, MGCP_ConnHdlr
port TELNETasp_PT BSCVTY;
var MediaState g_media;
+ var TestHdlrParams g_pars;
}
/* initialize all parameters */
@@ -352,13 +353,13 @@ template (value) TestHdlrParams t_def_TestHdlrPars := {
link_id := valueof(ts_RslLinkID_DCCH(0))
}
-function f_create_chan_and_exp(TestHdlrParams pars) runs on MSC_ConnHdlr {
- var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(pars.imsi));
+function f_create_chan_and_exp() runs on MSC_ConnHdlr {
+ var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, mi));
var octetstring l3_enc := enc_PDU_ML3_MS_NW(l3_info);
/* call helper function for CHAN_RQD -> IMM ASS ->EST_IND */
- RSL_Emulation.f_chan_est(pars.ra, l3_enc, pars.link_id, pars.fn);
+ RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
f_create_bssmap_exp(l3_enc);
}
@@ -619,7 +620,7 @@ return boolean {
}
/* establish a channel fully, expecting an assignment matching 'exp' */
-function f_establish_fully(TestHdlrParams pars, PDU_BSSAP ass_cmd, template PDU_BSSAP exp_ass_cpl)
+function f_establish_fully(PDU_BSSAP ass_cmd, template PDU_BSSAP exp_ass_cpl)
runs on MSC_ConnHdlr return PDU_BSSAP {
var PDU_BSSAP bssap;
timer T := 10.0;
@@ -642,7 +643,7 @@ runs on MSC_ConnHdlr return PDU_BSSAP {
f_MscConnHdlr_init(1, "127.0.0.2", "127.0.0.3");
- f_create_chan_and_exp(pars);
+ f_create_chan_and_exp();
/* we should now have a COMPL_L3 at the MSC */
BSSAP.receive(tr_BSSMAP_ComplL3);
f_create_mgcp_expect(mgcpcrit);