pcu: Add SNS tests for SGSN-originated BVC-RESET handling

Change-Id: Ib6b80acf98711f4749da4faf549b02ff2b82425f
diff --git a/pcu/PCU_Tests_RAW_SNS.ttcn b/pcu/PCU_Tests_RAW_SNS.ttcn
index 7f71744..7513196 100644
--- a/pcu/PCU_Tests_RAW_SNS.ttcn
+++ b/pcu/PCU_Tests_RAW_SNS.ttcn
@@ -186,7 +186,7 @@
 	setverdict(pass);
 }
 
-private function f_sns_bringup_1c1u() runs on RAW_Test_CT {
+private function f_sns_bringup_1c1u(boolean sgsn_originated_reset := false) runs on RAW_Test_CT {
 	/* Activate two NS codec ports */
 	f_init_ns_codec();
 	f_init_ns_codec(1);
@@ -208,9 +208,14 @@
 	f_outgoing_ns_alive(0);
 	f_outgoing_ns_alive(1);
 
-	/* 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);
+	if (sgsn_originated_reset) {
+		f_tx_bvc_reset_rx_ack(0);
+		f_tx_bvc_reset_rx_ack(mp_gb_cfg.bvci);
+	} else {
+		/* 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);
+	}
 	/* Expect UNBLOCK for ptp BVCI on signaling NS-VC (idx==0) */
 	as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvci, oneshot := true);
 
@@ -226,7 +231,7 @@
 	setverdict(pass);
 }
 
-private function f_sns_bringup_1c1u_separate() runs on RAW_Test_CT {
+private function f_sns_bringup_1c1u_separate(boolean sgsn_originated_reset := false) runs on RAW_Test_CT {
 	/* Activate two NS codec ports */
 	f_init_ns_codec();
 	f_init_ns_codec(1);
@@ -253,9 +258,14 @@
 	/* ensure there's no response to NS-ALIVE sent on idx==0 */
 	f_outgoing_ns_alive_no_ack(idx := 0);
 
-	/* Expect BVC-RESET for signaling BVCI=0 and ptp BVCI */
-	as_rx_bvc_reset_tx_ack(0, oneshot := true, idx := 1);
-	as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvci, oneshot := true, idx := 1);
+	if (sgsn_originated_reset) {
+		f_tx_bvc_reset_rx_ack(0, idx := 1);
+		f_tx_bvc_reset_rx_ack(mp_gb_cfg.bvci, idx := 1);
+	} else {
+		/* Expect BVC-RESET for signaling BVCI=0 and ptp BVCI */
+		as_rx_bvc_reset_tx_ack(0, oneshot := true, idx := 1);
+		as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvci, oneshot := true, idx := 1);
+	}
 	/* Expect UNBLOCK for ptp BVCI on signaling NS-VC (idx==1) */
 	as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvci, oneshot := true, idx := 1);
 
@@ -272,6 +282,39 @@
 	setverdict(pass);
 }
 
+/* Test full IP-SNS bring-up with two NS-VCs, one sig-only and one user-only and use
+ * SGSN-originated BVC-RESET rather than BSS-originated */
+testcase TC_sns_1c1u_so_bvc_reset() runs on RAW_Test_CT {
+	f_sns_bringup_1c1u_separate(sgsn_originated_reset := true);
+	setverdict(pass);
+}
+
+/* Transmit BVC-RESET before NS-ALIVE of PCU was ACKed: expect no response */
+testcase TC_sns_1c1u_so_bvc_reset_too_early() runs on RAW_Test_CT {
+	/* Activate two NS codec ports */
+	f_init_ns_codec();
+	f_init_ns_codec(1);
+	f_init_ns_codec(2);
+	f_init_pcuif();
+	/* Perform Size + BSS-originated config */
+	f_incoming_sns_size();
+	f_incoming_sns_config();
+	/* perform SGSN-originated config using idx==0 for signalling and idx==1 for user traffic */
+	f_outgoing_sns_config_1c1u_separate();
+
+	/* DON'T ACK ANY INBOUND NS-ALIVE HERE! */
+
+	/* perform outgoing ALIVE procedure for both NS-VCs */
+	f_outgoing_ns_alive(1);
+	f_outgoing_ns_alive(2);
+	/* ensure there's no response to NS-ALIVE sent on idx==0 */
+	f_outgoing_ns_alive_no_ack(idx := 0);
+
+	/* Transmit BVC-RESET and expect no ACK*/
+	f_tx_bvc_reset_rx_ack(0, idx := 1, exp_ack := false);
+	f_tx_bvc_reset_rx_ack(mp_gb_cfg.bvci, idx := 1, exp_ack := false);
+}
+
 /* Test adding new IP endpoints at runtime */
 testcase TC_sns_add() runs on RAW_Test_CT {
 	f_sns_bringup_1c1u();
@@ -343,6 +386,8 @@
 	execute( TC_sns_so_config_success() );
 	execute( TC_sns_1c1u() );
 	execute( TC_sns_1c1u_separate() );
+	execute( TC_sns_1c1u_so_bvc_reset() );
+	execute( TC_sns_1c1u_so_bvc_reset_too_early() );
 	execute( TC_sns_add() );
 	execute( TC_sns_del() );
 	execute( TC_sns_chg_weight() );