Change in osmo-ttcn3-hacks[master]: pcu: Move NS tests to PCU_Tests_RAW_NS.ttcn

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

pespin gerrit-no-reply at lists.osmocom.org
Mon Dec 30 13:16:07 UTC 2019


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/16685 )


Change subject: pcu: Move NS tests to PCU_Tests_RAW_NS.ttcn
......................................................................

pcu: Move NS tests to PCU_Tests_RAW_NS.ttcn

Tests from PCU_Tests_RAW_SNS inherit most infrastructure from NS tests
defined in PCU_Tests_RAW, which in turn don't share that much with other
tests present in that file. This way we simplify file PCU_Tests_RAW.ttcn,
which will potentially grow once more tests are added.

Change-Id: If680d1bd7dbfe98829f330c33705e0f13bedf3c7
---
M pcu/PCU_Tests.cfg
M pcu/PCU_Tests_RAW.ttcn
A pcu/PCU_Tests_RAW_NS.ttcn
M pcu/PCU_Tests_RAW_SNS.ttcn
4 files changed, 458 insertions(+), 386 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/85/16685/1

diff --git a/pcu/PCU_Tests.cfg b/pcu/PCU_Tests.cfg
index 6ea5a5a..0424e4f 100644
--- a/pcu/PCU_Tests.cfg
+++ b/pcu/PCU_Tests.cfg
@@ -22,3 +22,4 @@
 
 [EXECUTE]
 PCU_Tests_RAW.control
+PCU_Tests_RAW_NS.control
diff --git a/pcu/PCU_Tests_RAW.ttcn b/pcu/PCU_Tests_RAW.ttcn
index c800d43..d19093c 100644
--- a/pcu/PCU_Tests_RAW.ttcn
+++ b/pcu/PCU_Tests_RAW.ttcn
@@ -16,6 +16,8 @@
  * SPDX-License-Identifier: GPL-2.0-or-later
  */
 
+friend module PCU_Tests_RAW_NS;
+
 import from General_Types all;
 import from Osmocom_Types all;
 import from GSM_Types all;
@@ -42,8 +44,6 @@
 import from PCUIF_CodecPort all;
 import from PCUIF_RAW_Components all;
 import from IPL4asp_Types all;
-import from NS_CodecPort all;
-import from NS_CodecPort_CtrlFunct all;
 import from Native_Functions all;
 import from PCU_Tests all;
 
@@ -53,32 +53,9 @@
 	float X2002 := 0.2; /* Timer -2002, IMM ASSIGN confirm delay */
 }
 
-type component RAW_NS_CT {
-	/* UDP port towards the bottom (IUT) */
-	port NS_CODEC_PT NSCP[4];
-	var ConnectionId g_ns_conn_id[4] := {-1, -1, -1, -1};
-	var NSConfiguration g_nsconfig[4];
-	timer g_T_guard;
-}
-
-type component RAW_PCU_CT {
-	/* PCUIF (we emulate the BTS part) */
-	port PCUIF_CODEC_PT PCU;
-	var ConnectionId g_pcu_conn_id := -1;
-}
-
-type component RAW_Test_CT extends RAW_NS_CT, RAW_PCU_CT {
-}
-
-private altstep as_Tguard() runs on RAW_NS_CT {
-	[] g_T_guard.timeout {
-		setverdict(fail, "Timeout of T_guard");
-		mtc.stop;
-		}
-}
 
 /* FIXME: make sure to use parameters from mp_gb_cfg.cell_id in the PCU INFO IND */
-template (value) PCUIF_info_ind ts_PCUIF_INFO_default := {
+private template (value) PCUIF_info_ind ts_PCUIF_INFO_default := {
 	version := PCU_IF_VERSION,
 	flags := c_PCUIF_Flags_default,
 	trx := valueof(ts_PCUIF_InfoTrxs_def),
@@ -114,356 +91,6 @@
 	remote_ip := { f_inet_haddr(mp_nsconfig.local_ip) , '00000000'O }
 }
 
-function f_init_pcuif() runs on RAW_PCU_CT {
-	var PCUIF_info_ind info_ind;
-	map(self:PCU, system:PCU);
-
-
-	info_ind := valueof(ts_PCUIF_INFO_default);
-
-	/* Connect the Unix Domain Socket */
-	g_pcu_conn_id := f_pcuif_listen(PCU, mp_pcu_sock_path);
-	PCU.receive(UD_connected:?);
-
-	/* Wait for PCU_VERSION and return INFO_IND */
-	PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TXT_IND(0, PCU_VERSION, ?)));
-	/* FIXME: make sure to use parameters from mp_gb_cfg.cell_id in the PCU INFO IND */
-	var template PCUIF_Message info_ind_msg := ts_PCUIF_INFO_IND(0, info_ind);
-	PCU.send(t_SD_PCUIF(g_pcu_conn_id, info_ind_msg));
-}
-
-function f_pcuif_tx(template (value) PCUIF_Message msg) runs on RAW_PCU_CT {
-	PCU.send(t_SD_PCUIF(g_pcu_conn_id, msg));
-}
-
-function f_init_ns_codec(integer idx := 0, float guard_secs := 60.0) runs on RAW_NS_CT {
-	var Result res;
-
-	if (not g_T_guard.running) {
-		g_T_guard.start(guard_secs);
-		activate(as_Tguard());
-	}
-
-	if (not isbound(g_nsconfig) or not isbound(g_nsconfig[idx])) {
-		/* copy most parts from mp_nsconfig */
-		g_nsconfig[idx] := mp_nsconfig;
-		/* adjust those parts different for each NS-VC */
-		g_nsconfig[idx].nsvci := mp_nsconfig.nsvci + idx;
-		g_nsconfig[idx].local_udp_port := mp_nsconfig.local_udp_port + idx;
-	}
-
-	map(self:NSCP[idx], system:NSCP);
-	/* Connect the UDP socket */
-	log("connecting NSCP[", idx, "] to ", g_nsconfig[idx]);
-	res := f_IPL4_connect(NSCP[idx], g_nsconfig[idx].remote_ip, g_nsconfig[idx].remote_udp_port,
-				g_nsconfig[idx].local_ip, g_nsconfig[idx].local_udp_port, 0, { udp := {}});
-	if (not ispresent(res.connId)) {
-		setverdict(fail, "Could not connect NS UDP socket, check your configuration ", g_nsconfig[idx]);
-		mtc.stop;
-	}
-	g_ns_conn_id[idx] := res.connId;
-
-}
-
-function f_ns_exp(template PDU_NS exp_rx, integer idx := 0) runs on RAW_NS_CT return PDU_NS {
-	var NS_RecvFrom nrf;
-	log("f_ns_exp() expecting ", exp_rx);
-	alt {
-	[] NSCP[idx].receive(t_NS_RecvFrom(exp_rx)) -> value nrf { }
-	[] NSCP[idx].receive {
-		setverdict(fail, "Received unexpected NS: ", nrf);
-		mtc.stop;
-		}
-	}
-	return nrf.msg;
-}
-
-/* perform outbound NS-ALIVE procedure */
-function f_outgoing_ns_alive(integer idx := 0) runs on RAW_NS_CT {
-	NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_ALIVE));
-	alt {
-	[] NSCP[idx].receive(t_NS_RecvFrom(t_NS_ALIVE_ACK));
-	[] NSCP[idx].receive { repeat; }
-	}
-}
-
-/* perform outbound NS-ALIVE procedure */
-function f_outgoing_ns_alive_no_ack(integer idx := 0, float tout := 10.0) runs on RAW_NS_CT {
-	timer T := tout;
-	NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_ALIVE));
-	T.start;
-	alt {
-	[] NSCP[idx].receive(t_NS_RecvFrom(t_NS_ALIVE_ACK)) {
-		setverdict(fail, "Received unexpected NS-ALIVE ACK");
-		}
-	[] NSCP[idx].receive { repeat; }
-	[] T.timeout {
-		setverdict(pass);
-		}
-	}
-}
-
-/* ensure no matching message is received within 'tout' */
-function f_ensure_no_ns(template PDU_NS ns := ?, integer idx := 0, float tout := 3.0)
-runs on RAW_Test_CT {
-	timer T := tout;
-	T.start;
-	alt {
-	[] NSCP[idx].receive(t_NS_RecvFrom(ns)) {
-		setverdict(fail, "NS-ALIVE from unconfigured (possibly initial) endpoint");
-		}
-	[] T.timeout {
-		setverdict(pass);
-		}
-	}
-}
-
-/* perform outbound NS-BLOCK procedure */
-function f_outgoing_ns_block(NsCause cause, integer idx := 0) runs on RAW_NS_CT {
-	NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_BLOCK(cause, g_nsconfig[idx].nsvci)));
-	alt {
-	[] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_BLOCK_ACK(g_nsconfig[idx].nsvci)));
-	[] NSCP[idx].receive { repeat; }
-	}
-}
-
-/* receive NS-ALIVE and ACK it */
-altstep as_rx_alive_tx_ack(boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
-	[] NSCP[idx].receive(t_NS_RecvFrom(t_NS_ALIVE)) {
-		NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_ALIVE_ACK));
-		if (not oneshot) { repeat; }
-		}
-}
-
-/* Transmit BSSGP RESET for given BVCI and expect ACK */
-function f_tx_bvc_reset_rx_ack(BssgpBvci bvci, integer idx := 0, boolean exp_ack := true)
-runs on RAW_NS_CT {
-	var PDU_BSSGP bssgp_tx := valueof(ts_BVC_RESET(BSSGP_CAUSE_NET_SV_CAP_MOD_GT_ZERO_KBPS, bvci,
-							mp_gb_cfg.cell_id));
-	timer T := 5.0;
-	NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_UNITDATA(t_SduCtrlB, 0, enc_PDU_BSSGP(bssgp_tx))));
-	T.start;
-	alt {
-	[exp_ack] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, 0,
-						  decmatch tr_BVC_RESET_ACK(bvci, ?)))) {
-		setverdict(pass);
-		}
-	[exp_ack] T.timeout {
-		setverdict(fail, "No response to BVC-RESET");
-		}
-	[not exp_ack] T.timeout {
-		setverdict(pass);
-		}
-	[] NSCP[idx].receive { repeat; }
-	}
-}
-
-/* Receive a BSSGP RESET for given BVCI and ACK it */
-altstep as_rx_bvc_reset_tx_ack(BssgpBvci bvci, boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
-	var NS_RecvFrom ns_rf;
-	/* FIXME: nail down received cell_id in match */
-	[] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, 0,
-						  decmatch tr_BVC_RESET(?, bvci, ?))))
-								-> value ns_rf {
-		var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.msg.pDU_NS_Unitdata.nS_SDU);
-		var PDU_BSSGP bssgp_tx := valueof(ts_BVC_RESET_ACK(bvci, mp_gb_cfg.cell_id));
-		NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_UNITDATA(t_SduCtrlB, 0, enc_PDU_BSSGP(bssgp_tx))));
-		if (not oneshot) { repeat; }
-		}
-}
-
-
-/* Receive a BSSGP UNBLOCK for given BVCI and ACK it */
-altstep as_rx_bvc_unblock_tx_ack(BssgpBvci bvci, boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
-	var NS_RecvFrom ns_rf;
-	[] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, 0,
-						  decmatch t_BVC_UNBLOCK(bvci))))
-								-> value ns_rf {
-		var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.msg.pDU_NS_Unitdata.nS_SDU);
-		var PDU_BSSGP bssgp_tx := valueof(t_BVC_UNBLOCK_ACK(bvci));
-		NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_UNITDATA(t_SduCtrlB, 0, enc_PDU_BSSGP(bssgp_tx))));
-		if (not oneshot) { repeat; }
-		}
-}
-
-/* Receive a BSSGP FLOW-CONTROL-BVC and ACK it */
-altstep as_rx_bvc_fc_tx_ack(BssgpBvci bvci, boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
-	var NS_RecvFrom ns_rf;
-	[] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, bvci,
-						  decmatch tr_BVC_FC_BVC)))
-								-> value ns_rf {
-		var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.msg.pDU_NS_Unitdata.nS_SDU);
-		var OCT1 tag := bssgp_rx.pDU_BSSGP_FLOW_CONTROL_BVC.tag.unstructured_Value;
-		var PDU_BSSGP bssgp_tx := valueof(t_BVC_FC_BVC_ACK(tag));
-		NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_UNITDATA(t_SduCtrlB, bvci, enc_PDU_BSSGP(bssgp_tx))));
-		if (not oneshot) { repeat; }
-		}
-}
-
-/**********************************************************************************
- * Classic Gb/IP bring-up test cases using NS-{RESET,BLOCK,UNBLOCK} and no IP-SNS *
- **********************************************************************************/
-
-/* Receive a NS-RESET and ACK it */
-private altstep as_rx_ns_reset_ack(boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
-	var NS_RecvFrom ns_rf;
-	[] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_RESET(NS_CAUSE_OM_INTERVENTION, g_nsconfig[idx].nsvci,
-						  g_nsconfig[idx].nsei))) -> value ns_rf {
-		NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_RESET_ACK(g_nsconfig[idx].nsvci,
-									    g_nsconfig[idx].nsei)));
-		if (not oneshot) { repeat; }
-		}
-}
-/* Receive a NS-UNBLOCK and ACK it */
-private altstep as_rx_ns_unblock_ack(boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
-	var NS_RecvFrom ns_rf;
-	[] NSCP[idx].receive(t_NS_RecvFrom(t_NS_UNBLOCK)) -> value ns_rf {
-		NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_UNBLOCK_ACK));
-		if (not oneshot) { repeat; }
-		}
-}
-
-/* test the NS-RESET procedure */
-testcase TC_ns_reset() runs on RAW_Test_CT {
-	f_init_ns_codec();
-	f_init_pcuif();
-
-
-	/* Expect inbound NS-RESET procedure */
-	as_rx_ns_reset_ack(oneshot := true);
-	setverdict(pass);
-}
-
-/* ensure NS-RESET are re-transmitted */
-testcase TC_ns_reset_retrans() runs on RAW_Test_CT {
-	f_init_ns_codec();
-	f_init_pcuif();
-
-	var integer i;
-	for (i := 0; i < 3; i := i+1) {
-		NSCP[0].receive(t_NS_RecvFrom(tr_NS_RESET(NS_CAUSE_OM_INTERVENTION,
-							g_nsconfig[0].nsvci, g_nsconfig[0].nsei)));
-	}
-
-	/* Expect inbound NS-RESET procedure */
-	as_rx_ns_reset_ack(oneshot := true);
-	setverdict(pass);
-}
-
-/* test the inbound NS-ALIVE procedure after NS-RESET */
-testcase TC_ns_alive() runs on RAW_Test_CT {
-	f_init_ns_codec();
-	f_init_pcuif();
-
-	/* Expect inbound NS-RESET procedure */
-	as_rx_ns_reset_ack(oneshot := true);
-
-	/* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
-	as_rx_alive_tx_ack(oneshot := true);
-	setverdict(pass);
-}
-
-/* Test for NS-RESET after NS-ALIVE timeout */
-testcase TC_ns_alive_timeout_reset() runs on RAW_Test_CT {
-	f_init_ns_codec(guard_secs := 100.0);
-	f_init_pcuif();
-
-	/* Expect inbound NS-RESET procedure */
-	as_rx_ns_reset_ack(oneshot := true);
-
-	/* wait for at least one NS-ALIVE */
-	NSCP[0].receive(t_NS_RecvFrom(t_NS_ALIVE));
-
-	/* wait for NS-RESET to re-appear, ignoring any NS-ALIVE until then */
-	alt {
-	[] as_rx_ns_reset_ack(oneshot := true) { setverdict(pass); }
-	[] NSCP[0].receive(t_NS_RecvFrom(t_NS_ALIVE)) { repeat; }
-	}
-}
-
-/* test for NS-RESET/NS-ALIVE/NS-UNBLOCK */
-testcase TC_ns_unblock() runs on RAW_Test_CT {
-	f_init_ns_codec();
-	f_init_pcuif();
-
-	/* Expect inbound NS-RESET procedure */
-	as_rx_ns_reset_ack(oneshot := true);
-
-	/* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
-	as_rx_alive_tx_ack(oneshot := true);
-	activate(as_rx_alive_tx_ack());
-
-	as_rx_ns_unblock_ack(oneshot := true);
-	setverdict(pass);
-}
-
-/* test for NS-UNBLOCK re-transmissions */
-testcase TC_ns_unblock_retrans() runs on RAW_Test_CT {
-	f_init_ns_codec();
-	f_init_pcuif();
-
-	/* Expect inbound NS-RESET procedure */
-	as_rx_ns_reset_ack(oneshot := true);
-
-	/* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
-	as_rx_alive_tx_ack(oneshot := true);
-	activate(as_rx_alive_tx_ack());
-
-	/* wait for first NS-UNBLOCK, don't respond */
-	NSCP[0].receive(t_NS_RecvFrom(t_NS_UNBLOCK));
-
-	/* wait for re-transmission of NS-UNBLOCK */
-	as_rx_ns_unblock_ack(oneshot := true);
-	setverdict(pass);
-}
-
-/* full bring-up of the Gb link for NS and BSSGP layer up to BVC-FC */
-testcase TC_ns_full_bringup() runs on RAW_Test_CT {
-	f_init_ns_codec();
-	f_init_pcuif();
-
-	/* Expect inbound NS-RESET procedure */
-	as_rx_ns_reset_ack(oneshot := true);
-
-	/* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
-	as_rx_alive_tx_ack(oneshot := true);
-	activate(as_rx_alive_tx_ack());
-
-	as_rx_ns_unblock_ack(oneshot := true);
-
-	f_outgoing_ns_alive();
-
-	/* Expect BVC-RESET for signaling (0) and ptp BVCI */
-	as_rx_bvc_reset_tx_ack(0, oneshot := true);
-	as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvci, oneshot := true);
-	as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvci, oneshot := true);
-
-	/* wait for one FLOW-CONTROL BVC and then ACK any further in the future */
-	as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, oneshot := true);
-	activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci));
-	setverdict(pass);
-}
-
-/* test outbound (SGSN-originated) NS-BLOCK procedure */
-testcase TC_ns_so_block() runs on RAW_Test_CT {
-	f_init_ns_codec();
-	f_init_pcuif();
-
-	/* Expect inbound NS-RESET procedure */
-	as_rx_ns_reset_ack(oneshot := true);
-
-	/* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
-	as_rx_alive_tx_ack(oneshot := true);
-	activate(as_rx_alive_tx_ack());
-
-	as_rx_ns_unblock_ack(oneshot := true);
-
-	f_outgoing_ns_alive();
-
-	f_outgoing_ns_block(NS_CAUSE_EQUIPMENT_FAILURE);
-	setverdict(pass);
-}
-
 type record lqual_range {
 	/* component reference to the IPA_Client component used for RSL */
 	uint8_t low,
@@ -1774,15 +1401,6 @@
 }
 
 control {
-	execute( TC_ns_reset() );
-	execute( TC_ns_reset_retrans() );
-	execute( TC_ns_alive() );
-	execute( TC_ns_alive_timeout_reset() );
-	execute( TC_ns_unblock() );
-	execute( TC_ns_unblock_retrans() );
-	execute( TC_ns_full_bringup() );
-	execute( TC_ns_so_block() );
-
 	execute( TC_pcuif_suspend() );
 	execute( TC_ta_ptcch_idle() );
 	execute( TC_ta_rach_imm_ass() );
diff --git a/pcu/PCU_Tests_RAW_NS.ttcn b/pcu/PCU_Tests_RAW_NS.ttcn
new file mode 100644
index 0000000..b1b19bb
--- /dev/null
+++ b/pcu/PCU_Tests_RAW_NS.ttcn
@@ -0,0 +1,453 @@
+module PCU_Tests_RAW_NS {
+
+/* Osmocom PCU test suite for IP Sub-Network-Service (SNS) in TTCN-3
+ * (C) 2018-2019 Harald Welte <laforge at gnumonks.org>
+ * All rights reserved.
+ *
+ * Released under the terms of GNU General Public License, Version 2 or
+ * (at your option) any later version.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+import from General_Types all;
+import from Osmocom_Types all;
+import from PCU_Tests all;
+import from PCU_Tests_RAW all;
+import from Osmocom_Gb_Types all;
+import from NS_CodecPort all;
+import from NS_Types all;
+import from BSSGP_Types all;
+import from UD_Types all;
+import from NS_CodecPort all;
+import from NS_CodecPort_CtrlFunct all;
+import from NS_Emulation all;
+import from Native_Functions all;
+import from IPL4asp_Types all;
+import from PCUIF_Types all;
+import from PCUIF_CodecPort all;
+
+type component RAW_NS_CT {
+	/* UDP port towards the bottom (IUT) */
+	port NS_CODEC_PT NSCP[4];
+	var ConnectionId g_ns_conn_id[4] := {-1, -1, -1, -1};
+	var NSConfiguration g_nsconfig[4];
+	timer g_T_guard;
+}
+
+type component RAW_PCU_CT {
+	/* PCUIF (we emulate the BTS part) */
+	port PCUIF_CODEC_PT PCU;
+	var ConnectionId g_pcu_conn_id := -1;
+}
+
+type component RAW_Test_CT extends RAW_NS_CT, RAW_PCU_CT {
+}
+
+private altstep as_Tguard() runs on RAW_NS_CT {
+	[] g_T_guard.timeout {
+		setverdict(fail, "Timeout of T_guard");
+		mtc.stop;
+		}
+}
+
+/* FIXME: make sure to use parameters from mp_gb_cfg.cell_id in the PCU INFO IND */
+private template (value) PCUIF_info_ind ts_PCUIF_INFO_default := {
+	version := PCU_IF_VERSION,
+	flags := c_PCUIF_Flags_default,
+	trx := valueof(ts_PCUIF_InfoTrxs_def),
+	bsic := 7,
+	mcc := 262,
+	mnc := 42,
+	mnc_3_digits := 0,
+	lac := 13135,
+	rac := 0,
+	nsei := mp_nsconfig.nsei,
+	nse_timer := { 3, 3, 3, 3, 30, 3, 10 },
+	cell_timer := { 3, 3, 3, 3, 3, 10, 3, 10, 3, 10, 3 },
+	cell_id := 20960,
+	repeat_time := 5 * 50,
+	repeat_count := 3,
+	bvci := mp_gb_cfg.bvci,
+	t3142 := 20,
+	t3169 := 5,
+	t3191 := 5,
+	t3193_10ms := 160,
+	t3195 := 5,
+	t3101 := 10,
+	t3103 := 4,
+	t3105 := 8,
+	cv_countdown := 15,
+	dl_tbf_ext := 250 * 10, /* ms */
+	ul_tbf_ext := 250 * 10, /* ms */
+	initial_cs := 2,
+	initial_mcs := 6,
+	nsvci := { mp_nsconfig.nsvci, 0 },
+	local_pprt := { mp_nsconfig.remote_udp_port, 0 },
+	remote_port := { mp_nsconfig.local_udp_port, 0 },
+	remote_ip := { f_inet_haddr(mp_nsconfig.local_ip) , '00000000'O }
+}
+
+function f_init_pcuif() runs on RAW_PCU_CT {
+	var PCUIF_info_ind info_ind;
+	map(self:PCU, system:PCU);
+
+
+	info_ind := valueof(ts_PCUIF_INFO_default);
+
+	/* Connect the Unix Domain Socket */
+	g_pcu_conn_id := f_pcuif_listen(PCU, mp_pcu_sock_path);
+	PCU.receive(UD_connected:?);
+
+	/* Wait for PCU_VERSION and return INFO_IND */
+	PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TXT_IND(0, PCU_VERSION, ?)));
+	/* FIXME: make sure to use parameters from mp_gb_cfg.cell_id in the PCU INFO IND */
+	var template PCUIF_Message info_ind_msg := ts_PCUIF_INFO_IND(0, info_ind);
+	PCU.send(t_SD_PCUIF(g_pcu_conn_id, info_ind_msg));
+}
+
+function f_pcuif_tx(template (value) PCUIF_Message msg) runs on RAW_PCU_CT {
+	PCU.send(t_SD_PCUIF(g_pcu_conn_id, msg));
+}
+
+function f_init_ns_codec(integer idx := 0, float guard_secs := 60.0) runs on RAW_NS_CT {
+	var Result res;
+
+	if (not g_T_guard.running) {
+		g_T_guard.start(guard_secs);
+		activate(as_Tguard());
+	}
+
+	if (not isbound(g_nsconfig) or not isbound(g_nsconfig[idx])) {
+		/* copy most parts from mp_nsconfig */
+		g_nsconfig[idx] := mp_nsconfig;
+		/* adjust those parts different for each NS-VC */
+		g_nsconfig[idx].nsvci := mp_nsconfig.nsvci + idx;
+		g_nsconfig[idx].local_udp_port := mp_nsconfig.local_udp_port + idx;
+	}
+
+	map(self:NSCP[idx], system:NSCP);
+	/* Connect the UDP socket */
+	log("connecting NSCP[", idx, "] to ", g_nsconfig[idx]);
+	res := f_IPL4_connect(NSCP[idx], g_nsconfig[idx].remote_ip, g_nsconfig[idx].remote_udp_port,
+				g_nsconfig[idx].local_ip, g_nsconfig[idx].local_udp_port, 0, { udp := {}});
+	if (not ispresent(res.connId)) {
+		setverdict(fail, "Could not connect NS UDP socket, check your configuration ", g_nsconfig[idx]);
+		mtc.stop;
+	}
+	g_ns_conn_id[idx] := res.connId;
+
+}
+
+function f_ns_exp(template PDU_NS exp_rx, integer idx := 0) runs on RAW_NS_CT return PDU_NS {
+	var NS_RecvFrom nrf;
+	log("f_ns_exp() expecting ", exp_rx);
+	alt {
+	[] NSCP[idx].receive(t_NS_RecvFrom(exp_rx)) -> value nrf { }
+	[] NSCP[idx].receive {
+		setverdict(fail, "Received unexpected NS: ", nrf);
+		mtc.stop;
+		}
+	}
+	return nrf.msg;
+}
+
+/* perform outbound NS-ALIVE procedure */
+function f_outgoing_ns_alive(integer idx := 0) runs on RAW_NS_CT {
+	NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_ALIVE));
+	alt {
+	[] NSCP[idx].receive(t_NS_RecvFrom(t_NS_ALIVE_ACK));
+	[] NSCP[idx].receive { repeat; }
+	}
+}
+
+/* perform outbound NS-ALIVE procedure */
+function f_outgoing_ns_alive_no_ack(integer idx := 0, float tout := 10.0) runs on RAW_NS_CT {
+	timer T := tout;
+	NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_ALIVE));
+	T.start;
+	alt {
+	[] NSCP[idx].receive(t_NS_RecvFrom(t_NS_ALIVE_ACK)) {
+		setverdict(fail, "Received unexpected NS-ALIVE ACK");
+		}
+	[] NSCP[idx].receive { repeat; }
+	[] T.timeout {
+		setverdict(pass);
+		}
+	}
+}
+
+/* ensure no matching message is received within 'tout' */
+function f_ensure_no_ns(template PDU_NS ns := ?, integer idx := 0, float tout := 3.0)
+runs on RAW_Test_CT {
+	timer T := tout;
+	T.start;
+	alt {
+	[] NSCP[idx].receive(t_NS_RecvFrom(ns)) {
+		setverdict(fail, "NS-ALIVE from unconfigured (possibly initial) endpoint");
+		}
+	[] T.timeout {
+		setverdict(pass);
+		}
+	}
+}
+
+/* perform outbound NS-BLOCK procedure */
+function f_outgoing_ns_block(NsCause cause, integer idx := 0) runs on RAW_NS_CT {
+	NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_BLOCK(cause, g_nsconfig[idx].nsvci)));
+	alt {
+	[] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_BLOCK_ACK(g_nsconfig[idx].nsvci)));
+	[] NSCP[idx].receive { repeat; }
+	}
+}
+
+/* receive NS-ALIVE and ACK it */
+altstep as_rx_alive_tx_ack(boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
+	[] NSCP[idx].receive(t_NS_RecvFrom(t_NS_ALIVE)) {
+		NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_ALIVE_ACK));
+		if (not oneshot) { repeat; }
+		}
+}
+
+/* Transmit BSSGP RESET for given BVCI and expect ACK */
+function f_tx_bvc_reset_rx_ack(BssgpBvci bvci, integer idx := 0, boolean exp_ack := true)
+runs on RAW_NS_CT {
+	var PDU_BSSGP bssgp_tx := valueof(ts_BVC_RESET(BSSGP_CAUSE_NET_SV_CAP_MOD_GT_ZERO_KBPS, bvci,
+							mp_gb_cfg.cell_id));
+	timer T := 5.0;
+	NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_UNITDATA(t_SduCtrlB, 0, enc_PDU_BSSGP(bssgp_tx))));
+	T.start;
+	alt {
+	[exp_ack] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, 0,
+						  decmatch tr_BVC_RESET_ACK(bvci, ?)))) {
+		setverdict(pass);
+		}
+	[exp_ack] T.timeout {
+		setverdict(fail, "No response to BVC-RESET");
+		}
+	[not exp_ack] T.timeout {
+		setverdict(pass);
+		}
+	[] NSCP[idx].receive { repeat; }
+	}
+}
+
+/* Receive a BSSGP RESET for given BVCI and ACK it */
+altstep as_rx_bvc_reset_tx_ack(BssgpBvci bvci, boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
+	var NS_RecvFrom ns_rf;
+	/* FIXME: nail down received cell_id in match */
+	[] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, 0,
+						  decmatch tr_BVC_RESET(?, bvci, ?))))
+								-> value ns_rf {
+		var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.msg.pDU_NS_Unitdata.nS_SDU);
+		var PDU_BSSGP bssgp_tx := valueof(ts_BVC_RESET_ACK(bvci, mp_gb_cfg.cell_id));
+		NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_UNITDATA(t_SduCtrlB, 0, enc_PDU_BSSGP(bssgp_tx))));
+		if (not oneshot) { repeat; }
+		}
+}
+
+
+/* Receive a BSSGP UNBLOCK for given BVCI and ACK it */
+altstep as_rx_bvc_unblock_tx_ack(BssgpBvci bvci, boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
+	var NS_RecvFrom ns_rf;
+	[] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, 0,
+						  decmatch t_BVC_UNBLOCK(bvci))))
+								-> value ns_rf {
+		var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.msg.pDU_NS_Unitdata.nS_SDU);
+		var PDU_BSSGP bssgp_tx := valueof(t_BVC_UNBLOCK_ACK(bvci));
+		NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_UNITDATA(t_SduCtrlB, 0, enc_PDU_BSSGP(bssgp_tx))));
+		if (not oneshot) { repeat; }
+		}
+}
+
+/* Receive a BSSGP FLOW-CONTROL-BVC and ACK it */
+altstep as_rx_bvc_fc_tx_ack(BssgpBvci bvci, boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
+	var NS_RecvFrom ns_rf;
+	[] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, bvci,
+						  decmatch tr_BVC_FC_BVC)))
+								-> value ns_rf {
+		var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.msg.pDU_NS_Unitdata.nS_SDU);
+		var OCT1 tag := bssgp_rx.pDU_BSSGP_FLOW_CONTROL_BVC.tag.unstructured_Value;
+		var PDU_BSSGP bssgp_tx := valueof(t_BVC_FC_BVC_ACK(tag));
+		NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_UNITDATA(t_SduCtrlB, bvci, enc_PDU_BSSGP(bssgp_tx))));
+		if (not oneshot) { repeat; }
+		}
+}
+
+/**********************************************************************************
+ * Classic Gb/IP bring-up test cases using NS-{RESET,BLOCK,UNBLOCK} and no IP-SNS *
+ **********************************************************************************/
+
+/* Receive a NS-RESET and ACK it */
+private altstep as_rx_ns_reset_ack(boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
+	var NS_RecvFrom ns_rf;
+	[] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_RESET(NS_CAUSE_OM_INTERVENTION, g_nsconfig[idx].nsvci,
+						  g_nsconfig[idx].nsei))) -> value ns_rf {
+		NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_RESET_ACK(g_nsconfig[idx].nsvci,
+									    g_nsconfig[idx].nsei)));
+		if (not oneshot) { repeat; }
+		}
+}
+/* Receive a NS-UNBLOCK and ACK it */
+private altstep as_rx_ns_unblock_ack(boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
+	var NS_RecvFrom ns_rf;
+	[] NSCP[idx].receive(t_NS_RecvFrom(t_NS_UNBLOCK)) -> value ns_rf {
+		NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_UNBLOCK_ACK));
+		if (not oneshot) { repeat; }
+		}
+}
+
+/* test the NS-RESET procedure */
+testcase TC_ns_reset() runs on RAW_Test_CT {
+	f_init_ns_codec();
+	f_init_pcuif();
+
+
+	/* Expect inbound NS-RESET procedure */
+	as_rx_ns_reset_ack(oneshot := true);
+	setverdict(pass);
+}
+
+/* ensure NS-RESET are re-transmitted */
+testcase TC_ns_reset_retrans() runs on RAW_Test_CT {
+	f_init_ns_codec();
+	f_init_pcuif();
+
+	var integer i;
+	for (i := 0; i < 3; i := i+1) {
+		NSCP[0].receive(t_NS_RecvFrom(tr_NS_RESET(NS_CAUSE_OM_INTERVENTION,
+							g_nsconfig[0].nsvci, g_nsconfig[0].nsei)));
+	}
+
+	/* Expect inbound NS-RESET procedure */
+	as_rx_ns_reset_ack(oneshot := true);
+	setverdict(pass);
+}
+
+/* test the inbound NS-ALIVE procedure after NS-RESET */
+testcase TC_ns_alive() runs on RAW_Test_CT {
+	f_init_ns_codec();
+	f_init_pcuif();
+
+	/* Expect inbound NS-RESET procedure */
+	as_rx_ns_reset_ack(oneshot := true);
+
+	/* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
+	as_rx_alive_tx_ack(oneshot := true);
+	setverdict(pass);
+}
+
+/* Test for NS-RESET after NS-ALIVE timeout */
+testcase TC_ns_alive_timeout_reset() runs on RAW_Test_CT {
+	f_init_ns_codec(guard_secs := 100.0);
+	f_init_pcuif();
+
+	/* Expect inbound NS-RESET procedure */
+	as_rx_ns_reset_ack(oneshot := true);
+
+	/* wait for at least one NS-ALIVE */
+	NSCP[0].receive(t_NS_RecvFrom(t_NS_ALIVE));
+
+	/* wait for NS-RESET to re-appear, ignoring any NS-ALIVE until then */
+	alt {
+	[] as_rx_ns_reset_ack(oneshot := true) { setverdict(pass); }
+	[] NSCP[0].receive(t_NS_RecvFrom(t_NS_ALIVE)) { repeat; }
+	}
+}
+
+/* test for NS-RESET/NS-ALIVE/NS-UNBLOCK */
+testcase TC_ns_unblock() runs on RAW_Test_CT {
+	f_init_ns_codec();
+	f_init_pcuif();
+
+	/* Expect inbound NS-RESET procedure */
+	as_rx_ns_reset_ack(oneshot := true);
+
+	/* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
+	as_rx_alive_tx_ack(oneshot := true);
+	activate(as_rx_alive_tx_ack());
+
+	as_rx_ns_unblock_ack(oneshot := true);
+	setverdict(pass);
+}
+
+/* test for NS-UNBLOCK re-transmissions */
+testcase TC_ns_unblock_retrans() runs on RAW_Test_CT {
+	f_init_ns_codec();
+	f_init_pcuif();
+
+	/* Expect inbound NS-RESET procedure */
+	as_rx_ns_reset_ack(oneshot := true);
+
+	/* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
+	as_rx_alive_tx_ack(oneshot := true);
+	activate(as_rx_alive_tx_ack());
+
+	/* wait for first NS-UNBLOCK, don't respond */
+	NSCP[0].receive(t_NS_RecvFrom(t_NS_UNBLOCK));
+
+	/* wait for re-transmission of NS-UNBLOCK */
+	as_rx_ns_unblock_ack(oneshot := true);
+	setverdict(pass);
+}
+
+/* full bring-up of the Gb link for NS and BSSGP layer up to BVC-FC */
+testcase TC_ns_full_bringup() runs on RAW_Test_CT {
+	f_init_ns_codec();
+	f_init_pcuif();
+
+	/* Expect inbound NS-RESET procedure */
+	as_rx_ns_reset_ack(oneshot := true);
+
+	/* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
+	as_rx_alive_tx_ack(oneshot := true);
+	activate(as_rx_alive_tx_ack());
+
+	as_rx_ns_unblock_ack(oneshot := true);
+
+	f_outgoing_ns_alive();
+
+	/* Expect BVC-RESET for signaling (0) and ptp BVCI */
+	as_rx_bvc_reset_tx_ack(0, oneshot := true);
+	as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvci, oneshot := true);
+	as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvci, oneshot := true);
+
+	/* wait for one FLOW-CONTROL BVC and then ACK any further in the future */
+	as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, oneshot := true);
+	activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci));
+	setverdict(pass);
+}
+
+/* test outbound (SGSN-originated) NS-BLOCK procedure */
+testcase TC_ns_so_block() runs on RAW_Test_CT {
+	f_init_ns_codec();
+	f_init_pcuif();
+
+	/* Expect inbound NS-RESET procedure */
+	as_rx_ns_reset_ack(oneshot := true);
+
+	/* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
+	as_rx_alive_tx_ack(oneshot := true);
+	activate(as_rx_alive_tx_ack());
+
+	as_rx_ns_unblock_ack(oneshot := true);
+
+	f_outgoing_ns_alive();
+
+	f_outgoing_ns_block(NS_CAUSE_EQUIPMENT_FAILURE);
+	setverdict(pass);
+}
+
+
+control {
+	execute( TC_ns_reset() );
+	execute( TC_ns_reset_retrans() );
+	execute( TC_ns_alive() );
+	execute( TC_ns_alive_timeout_reset() );
+	execute( TC_ns_unblock() );
+	execute( TC_ns_unblock_retrans() );
+	execute( TC_ns_full_bringup() );
+	execute( TC_ns_so_block() );
+}
+
+}
diff --git a/pcu/PCU_Tests_RAW_SNS.ttcn b/pcu/PCU_Tests_RAW_SNS.ttcn
index c8520e7..1a8c30f 100644
--- a/pcu/PCU_Tests_RAW_SNS.ttcn
+++ b/pcu/PCU_Tests_RAW_SNS.ttcn
@@ -12,7 +12,7 @@
 
 import from Osmocom_Types all;
 import from PCU_Tests all;
-import from PCU_Tests_RAW all;
+import from PCU_Tests_RAW_NS all;
 import from Osmocom_Gb_Types all;
 import from NS_CodecPort all;
 import from NS_Types all;

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/16685
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: If680d1bd7dbfe98829f330c33705e0f13bedf3c7
Gerrit-Change-Number: 16685
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191230/bef6acee/attachment.htm>


More information about the gerrit-log mailing list