pespin submitted this change.
hnbgw: Get rid of pars param in void_fn
Store pars into component field "g_pars" before caling void_fn.
This simplifies ConnHdlr test functions and also avoids potential
problems modifying pars vs g_pars.
This is the same as we do in lots of other testsuites.
Change-Id: I674b2a6a6a0e39f2904f9125783180da8ade5f44
---
M hnbgw/ConnHdlr.ttcn
M hnbgw/HNBGW_Tests.ttcn
2 files changed, 57 insertions(+), 73 deletions(-)
diff --git a/hnbgw/ConnHdlr.ttcn b/hnbgw/ConnHdlr.ttcn
index 803ed8a..7df3008 100644
--- a/hnbgw/ConnHdlr.ttcn
+++ b/hnbgw/ConnHdlr.ttcn
@@ -171,7 +171,8 @@
/* RAB release cause */
RANAP_IEs.Cause rab_rel_cause,
integer hnbgw_timer_x31,
- IuSignallingConnectionIdentifier sigc_id
+ IuSignallingConnectionIdentifier sigc_id,
+ float t_guard
}
template (value) TestHdlrParams
@@ -183,7 +184,8 @@
integer cn_idx := 0,
charstring pfcp_local_addr := "127.0.0.1",
template (value) RANAP_IEs.Cause rab_rel_cause := ts_RanapCause_nas_normal,
- integer hnbgw_timer_x31 := 5) := {
+ integer hnbgw_timer_x31 := 5,
+ float t_guard := 20.0) := {
hnb_idx := hnb_idx,
cn_idx := cn_idx,
imsi := f_gen_imsi(imsi_suffix),
@@ -198,7 +200,8 @@
sccp_addr_hnbgw := omit,
rab_rel_cause := rab_rel_cause,
hnbgw_timer_x31 := hnbgw_timer_x31,
- sigc_id := int2bit(f_rnd_int(1000), 24)
+ sigc_id := int2bit(f_rnd_int(1000), 24),
+ t_guard := t_guard
}
@@ -208,14 +211,15 @@
}
}
-type function void_fn(charstring id, TestHdlrParams pars) runs on ConnHdlr;
+type function void_fn(charstring id) runs on ConnHdlr;
-function f_init_handler(TestHdlrParams pars, float t_guard := 20.0) runs on ConnHdlr {
+/* first function inside ConnHdlr component; sets g_pars + starts function */
+function f_handler_init(void_fn fn, charstring id, TestHdlrParams pars) runs on ConnHdlr {
/* make parameters available via component variable */
g_pars := pars;
/* start guard timer and activate it as default */
- g_Tguard.start(t_guard);
+ g_Tguard.start(g_pars.t_guard);
activate(as_Tguard_ConnHdlr());
map(self:HNBGWVTY, system:HNBGWVTY);
@@ -225,6 +229,8 @@
/* TODO: CTRL? */
f_sleep(1.0);
+
+ fn.apply(id);
}
/* global altstep for global guard timer; */
@@ -657,14 +663,14 @@
f_rab_ass_resp(pars);
}
-altstep as_mgcp_dlcx(inout TestHdlrParams pars) runs on ConnHdlr {
+altstep as_mgcp_dlcx() runs on ConnHdlr {
var MgcpCommand mgcp_cmd;
- [] MGCP.receive(tr_DLCX(pars.mgcp_pars.mgcp_ep)) -> value mgcp_cmd {
+ [] MGCP.receive(tr_DLCX(g_pars.mgcp_pars.mgcp_ep)) -> value mgcp_cmd {
log("DLCX", mgcp_cmd);
MGCP.send(ts_DLCX_ACK2(mgcp_cmd.line.trans_id));
- pars.mgcp_pars.got_dlcx_count := pars.mgcp_pars.got_dlcx_count + 1;
- if (pars.mgcp_pars.got_dlcx_count != pars.mgcp_pars.got_crcx_count) {
+ g_pars.mgcp_pars.got_dlcx_count := g_pars.mgcp_pars.got_dlcx_count + 1;
+ if (g_pars.mgcp_pars.got_dlcx_count != g_pars.mgcp_pars.got_crcx_count) {
repeat;
}
setverdict(pass);
diff --git a/hnbgw/HNBGW_Tests.ttcn b/hnbgw/HNBGW_Tests.ttcn
index bfe854b..2328733 100644
--- a/hnbgw/HNBGW_Tests.ttcn
+++ b/hnbgw/HNBGW_Tests.ttcn
@@ -567,10 +567,8 @@
private function f_start_handler_run(ConnHdlr vc_conn, void_fn fn, TestHdlrParams pars) runs on test_CT {
var charstring id := testcasename(); // & int2str(pars.ran_idx);
- /* We cannot use vc_conn.start(f_init_handler(fn, id, pars)); as we cannot have
- * a stand-alone 'derefers()' call, see https://www.eclipse.org/forums/index.php/t/1091364/ */
pars.hnb := g_hnb_cfg[pars.hnb_idx];
- vc_conn.start(derefers(fn)(id, pars));
+ vc_conn.start(f_handler_init(fn, id, pars))
}
function f_start_handler_with_pars(void_fn fn, template (value) TestHdlrParams pars)
@@ -846,8 +844,7 @@
***********************************************************************/
/* Create an Iuh connection; send InitialUE; expect it to appear on new SCCP conenction */
-friend function f_tc_initial_ue(charstring id, TestHdlrParams pars) runs on ConnHdlr {
- f_init_handler(pars);
+friend function f_tc_initial_ue(charstring id) runs on ConnHdlr {
var RANAP_PDU tx := f_build_initial_ue(g_pars);
f_iuh2iu_connect(tx);
}
@@ -974,13 +971,12 @@
f_shutdown_helper();
}
-friend function f_tc_rab_assignment(charstring id, TestHdlrParams pars) runs on ConnHdlr {
+friend function f_tc_rab_assignment(charstring id) runs on ConnHdlr {
const charstring hnb0_ctr_prefix := "TTCN3.hnb.001-01-L2342-R0-S55-C1.";
var MgcpCommand mgcp_cmd;
var RANAP_PDU tx;
timer T := 5.0;
- f_init_handler(pars);
f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
f_statsd_reset();
@@ -996,7 +992,7 @@
};
f_statsd_expect(expect);
- f_create_rab(pars.mgcp_pars);
+ f_create_rab(g_pars.mgcp_pars);
expect := {
{name := hnb0_ctr_prefix & "ranap.cs.rab_act.req", mtype := "c", min := 1, max := 1},
@@ -1006,12 +1002,12 @@
f_statsd_expect(expect);
/* Send Iu Release */
- tx := valueof(ts_RANAP_IuReleaseCommand(pars.rab_rel_cause));
+ tx := valueof(ts_RANAP_IuReleaseCommand(g_pars.rab_rel_cause));
f_iu2iuh(tx);
T.start;
alt {
- [] as_mgcp_dlcx(pars) {}
+ [] as_mgcp_dlcx() {}
[] T.timeout {
setverdict(fail, "Timeout waiting for DLCX");
}
@@ -1033,13 +1029,12 @@
f_shutdown_helper();
}
-friend function f_tc_rab_assign_fail(charstring id, TestHdlrParams pars) runs on ConnHdlr {
+friend function f_tc_rab_assign_fail(charstring id) runs on ConnHdlr {
const charstring hnb0_ctr_prefix := "TTCN3.hnb.001-01-L2342-R0-S55-C1.";
var MgcpCommand mgcp_cmd;
var RANAP_PDU tx;
timer T := 5.0;
- f_init_handler(pars);
f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
f_statsd_reset();
@@ -1055,10 +1050,10 @@
};
f_statsd_expect(expect);
- f_rab_ass_req(pars.mgcp_pars);
+ f_rab_ass_req(g_pars.mgcp_pars);
/* Send RAB failed list in response */
- tx := valueof(ts_RANAP_RabAssResp(rab_fl := ts_RAB_FL(t_RAB_id(23), pars.rab_rel_cause)));
+ tx := valueof(ts_RANAP_RabAssResp(rab_fl := ts_RAB_FL(t_RAB_id(23), g_pars.rab_rel_cause)));
f_iuh2iu(tx);
expect := {
@@ -1071,7 +1066,7 @@
T.start;
alt {
- [] as_mgcp_dlcx(pars) {}
+ [] as_mgcp_dlcx() {}
[] T.timeout {
setverdict(fail, "Timeout waiting for DLCX");
}
@@ -1090,13 +1085,12 @@
f_shutdown_helper();
}
-friend function f_tc_rab_release(charstring id, TestHdlrParams pars) runs on ConnHdlr {
+friend function f_tc_rab_release(charstring id) runs on ConnHdlr {
const charstring hnb0_ctr_prefix := "TTCN3.hnb.001-01-L2342-R0-S55-C1.";
var MgcpCommand mgcp_cmd;
var RANAP_PDU tx;
timer T := 15.0;
- f_init_handler(pars);
f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
f_statsd_reset();
@@ -1104,10 +1098,10 @@
tx := f_build_initial_ue(g_pars);
f_iuh2iu_connect(tx);
- f_create_rab(pars.mgcp_pars);
+ f_create_rab(g_pars.mgcp_pars);
var charstring ctr_name;
- if (pars.rab_rel_cause == valueof(ts_RanapCause_nas_normal)) {
+ if (g_pars.rab_rel_cause == valueof(ts_RanapCause_nas_normal)) {
ctr_name := "ranap.cs.rab_rel.req.normal";
} else {
ctr_name := "ranap.cs.rab_rel.req.abnormal";
@@ -1120,7 +1114,7 @@
f_statsd_expect(expect);
/* Send RAB Release */
- tx := valueof(ts_RANAP_RabAssReq(rab_rl := ts_RAB_RL(t_RAB_id(23), pars.rab_rel_cause)));
+ tx := valueof(ts_RANAP_RabAssReq(rab_rl := ts_RAB_RL(t_RAB_id(23), g_pars.rab_rel_cause)));
BSSAP.send(tx);
expect := {
@@ -1131,7 +1125,7 @@
T.start;
alt {
- [] as_mgcp_dlcx(pars) {}
+ [] as_mgcp_dlcx() {}
[] T.timeout {
setverdict(fail, "Timeout waiting for DLCX");
}
@@ -1166,14 +1160,13 @@
f_shutdown_helper();
}
-friend function f_tc_rab_assign_mgcp_to(charstring id, TestHdlrParams pars) runs on ConnHdlr {
+friend function f_tc_rab_assign_mgcp_to(charstring id) runs on ConnHdlr {
var MgcpCommand mgcp_cmd;
var RANAP_PDU tx;
var template RAB_SetupOrModifyList rab_sml;
timer T := 15.0;
T.start;
- f_init_handler(pars);
f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
tx := f_build_initial_ue(g_pars);
@@ -1181,7 +1174,9 @@
/* Send RAB Assignment Request */
- rab_sml := ts_RAB_SML(t_RAB_id(23), f_ts_RAB_TLA(pars.mgcp_pars.cn_rtp_ip), t_RAB_binding_port(pars.mgcp_pars.cn_rtp_port));
+ rab_sml := ts_RAB_SML(t_RAB_id(23),
+ f_ts_RAB_TLA(g_pars.mgcp_pars.cn_rtp_ip),
+ t_RAB_binding_port(g_pars.mgcp_pars.cn_rtp_port));
tx := valueof(ts_RANAP_RabAssReq(rab_sml));
BSSAP.send(tx);
@@ -1198,7 +1193,7 @@
}
/* Send Iu Release */
- tx := valueof(ts_RANAP_IuReleaseCommand(pars.rab_rel_cause));
+ tx := valueof(ts_RANAP_IuReleaseCommand(g_pars.rab_rel_cause));
f_iu2iuh(tx);
tx := valueof(ts_RANAP_IuReleaseComplete());
@@ -1234,9 +1229,7 @@
}
/* Create an Iuh connection; send InitialUE; transceive data both directions */
-friend function f_tc_ranap_bidir(charstring id, TestHdlrParams pars) runs on ConnHdlr {
- f_init_handler(pars);
-
+friend function f_tc_ranap_bidir(charstring id) runs on ConnHdlr {
/* HNB -> MSC: InitialUE */
f_iuh2iu_connect(f_build_initial_ue(g_pars));
@@ -1246,7 +1239,7 @@
f_iuh2iu(ts_RANAP_DirectTransfer(f_rnd_octstring(10)));
/* HNB <- MSC: CommonID */
- f_iu2iuh(ts_RANAP_CommonId(hex2oct(pars.imsi)));
+ f_iu2iuh(ts_RANAP_CommonId(hex2oct(g_pars.imsi)));
}
testcase TC_ranap_cs_bidir() runs on test_CT {
var ConnHdlr vc_conn;
@@ -1270,9 +1263,7 @@
}
-private function f_tc_ranap_mo_disconnect(charstring id, TestHdlrParams pars) runs on ConnHdlr {
- f_init_handler(pars);
-
+private function f_tc_ranap_mo_disconnect(charstring id) runs on ConnHdlr {
/* HNB -> MSC: InitialUE */
f_iuh2iu_connect(f_build_initial_ue(g_pars));
@@ -1306,9 +1297,7 @@
}
/* SCCP Connect Req is answererd with Connect Refused: */
-private function f_tc_ranap_creq_cref_ConnHdlr(charstring id, TestHdlrParams pars) runs on ConnHdlr {
- f_init_handler(pars);
-
+private function f_tc_ranap_creq_cref_ConnHdlr(charstring id) runs on ConnHdlr {
/* HNB -> MSC: InitialUE */
f_iuh2iu_connect(f_build_initial_ue(g_pars));
@@ -1385,14 +1374,12 @@
}
}
-friend function f_tc_ps_rab_assignment_with_pfcp(charstring id, TestHdlrParams pars) runs on ConnHdlr {
+friend function f_tc_ps_rab_assignment_with_pfcp(charstring id) runs on ConnHdlr {
const OCT8 c_SEID0 := '0000000000000000'O;
const OCT8 c_SEID1 := '1111111111111111'O;
var RANAP_PDU tx;
var RANAP_PDU rx;
- f_init_handler(pars);
-
/* ask PFCPEM to route all PDUs to us */
f_PFCPEM_subscribe_bcast();
@@ -1470,7 +1457,7 @@
f_bssap_expect(tr_RANAP_RabAssResp(rab_smdl));
f_sleep(2.0);
- tx := valueof(ts_RANAP_IuReleaseCommand(pars.rab_rel_cause));
+ tx := valueof(ts_RANAP_IuReleaseCommand(g_pars.rab_rel_cause));
f_iu2iuh(tx);
tx := valueof(ts_RANAP_IuReleaseComplete());
@@ -1498,13 +1485,11 @@
f_shutdown_helper();
}
-friend function f_tc_ps_rab_assignment_without_pfcp(charstring id, TestHdlrParams pars) runs on ConnHdlr {
+friend function f_tc_ps_rab_assignment_without_pfcp(charstring id) runs on ConnHdlr {
var RANAP_PDU tx;
var RANAP_PDU rx;
timer T := 5.0;
- f_init_handler(pars);
-
/* ask PFCPEM to route all PDUs to us */
f_PFCPEM_subscribe_bcast();
activate(as_disallow_pfcp());
@@ -1535,7 +1520,7 @@
f_bssap_expect(tr_RANAP_RabAssResp(rab_smdl));
f_sleep(2.0);
- tx := valueof(ts_RANAP_IuReleaseCommand(pars.rab_rel_cause));
+ tx := valueof(ts_RANAP_IuReleaseCommand(g_pars.rab_rel_cause));
f_iu2iuh(tx);
tx := valueof(ts_RANAP_IuReleaseComplete());
@@ -1610,8 +1595,7 @@
f_counter_name_vals_list_add(g_ctr_cn, cn_nr, countername, val);
}
-private function f_tc_cnpool_compl_l3(charstring id, TestHdlrParams pars) runs on ConnHdlr {
- f_init_handler(pars);
+private function f_tc_cnpool_compl_l3(charstring id) runs on ConnHdlr {
f_perform_compl_l3(g_pars.nas_pdu);
}
@@ -2048,18 +2032,16 @@
/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by IMSI, which would be
* round-robined to another MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
-friend function f_tc_mscpool_paging_imsi(charstring id, TestHdlrParams pars) runs on ConnHdlr {
- f_init_handler(pars);
-
+friend function f_tc_mscpool_paging_imsi(charstring id) runs on ConnHdlr {
var hexstring imsi := '001010000000123'H;
var RANAP_IEs.CN_DomainIndicator domain_ind;
- if (pars.ps_domain) {
+ if (g_pars.ps_domain) {
domain_ind := ps_domain;
} else {
domain_ind := cs_domain;
}
var template (value) RANAP_PDU paging := ts_RANAP_Paging(domain_ind, imsi_hex2oct(imsi));
- BSSAP.send(ts_RANAP_UNITDATA_req(pars.sccp_addr_hnbgw, pars.sccp_addr_msc, paging));
+ BSSAP.send(ts_RANAP_UNITDATA_req(g_pars.sccp_addr_hnbgw, g_pars.sccp_addr_msc, paging));
/* TODO: Expect RUA ConnectionlessTransfer Paging (on all HNB).
* We could verify the Paging sent from osmo-hnbgw to RUA with some effort,
* but, this test does not care whether the Paging was forwarded to RUA or not, only that osmo-hnbgw *received*
@@ -2096,22 +2078,20 @@
/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by TMSI with an NRI value
* that matches a different MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
-friend function f_tc_mscpool_paging_tmsi(charstring id, TestHdlrParams pars) runs on ConnHdlr {
- f_init_handler(pars);
-
+friend function f_tc_mscpool_paging_tmsi(charstring id) runs on ConnHdlr {
var hexstring imsi := '001010000000124'H;
var integer nri_v := 300; /* <-- second MSC's NRI */
var octetstring tmsi := f_gen_tmsi(suffix := 0, nri_v := nri_v);
var RANAP_IEs.CN_DomainIndicator domain_ind;
- if (pars.ps_domain) {
+ if (g_pars.ps_domain) {
domain_ind := ps_domain;
} else {
domain_ind := cs_domain;
}
var template (value) RANAP_PDU paging := ts_RANAP_Paging_temp_id(domain_ind, imsi_hex2oct(imsi),
ts_RANAP_TemporaryUE_ID_TMSI(tmsi));
- BSSAP.send(ts_RANAP_UNITDATA_req(pars.sccp_addr_hnbgw, pars.sccp_addr_msc, paging));
+ BSSAP.send(ts_RANAP_UNITDATA_req(g_pars.sccp_addr_hnbgw, g_pars.sccp_addr_msc, paging));
/* TODO: Expect RUA ConnectionlessTransfer Paging (on all HNB).
* We could verify the Paging sent from osmo-hnbgw to RUA with some effort,
* but, this test does not care whether the Paging was forwarded to RUA or not, only that osmo-hnbgw *received*
@@ -2301,10 +2281,9 @@
}
/* With a cnlink up, change the SCCP address, and verify that it restarts upon vty 'apply sccp' */
-private function f_tc_apply_sccp(charstring id, TestHdlrParams pars) runs on ConnHdlr
+private function f_tc_apply_sccp(charstring id) runs on ConnHdlr
{
- f_init_handler(pars);
- f_perform_compl_l3(f_gen_compl3_by_domain(pars.ps_domain, 1)[0]);
+ f_perform_compl_l3(f_gen_compl3_by_domain(g_pars.ps_domain, 1)[0]);
f_sleep(1.0);
f_logp(HNBGWVTY, "Changing SCCP address, don't apply yet");
@@ -2345,18 +2324,17 @@
/* In the field, we encountered a "normal" RAB Assignment that concludes successfully, followed by another RAB
* Assignment that has different SDU subflow parameters, and does not contain RTP information. At the time of writing,
* it seems that the second RAB Assignment causes a crash. Play through this scenario. */
-friend function f_tc_second_rab_assignment(charstring id, TestHdlrParams pars) runs on ConnHdlr {
+friend function f_tc_second_rab_assignment(charstring id) runs on ConnHdlr {
var MgcpCommand mgcp_cmd;
var RANAP_PDU tx;
timer T := 5.0;
- f_init_handler(pars);
f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
tx := f_build_initial_ue(g_pars);
f_iuh2iu_connect(tx);
- f_create_rab(pars.mgcp_pars);
+ f_create_rab(g_pars.mgcp_pars);
/* Now send a second RAB Assignment with different subflows and omitting transportLayerInformation. (Assuming
* the first RAB Assignment's transportLayerInformation remains in use unchanged.) */
@@ -2383,12 +2361,12 @@
f_bssap_expect(tx);
/* Send Iu Release */
- tx := valueof(ts_RANAP_IuReleaseCommand(pars.rab_rel_cause));
+ tx := valueof(ts_RANAP_IuReleaseCommand(g_pars.rab_rel_cause));
f_iu2iuh(tx);
T.start;
alt {
- [] as_mgcp_dlcx(pars) {}
+ [] as_mgcp_dlcx() {}
[] T.timeout {
setverdict(fail, "Timeout waiting for DLCX");
}
To view, visit change 38575. To unsubscribe, or for help writing mail filters, visit settings.