ns: add TC_sns_bss_remove_bind_fail_sns to check SNS fails correct when removing a bind

This TC produces an abort of the ns2 dummy by the memory sanitizer.
Test if SNS fails when removing a bind which has the last valid connection.
The ns2 has 2 binds, ttcn3 1 bind. There are 2 NSVCs.

Bind -- NSVCs -- Bind.

(ns2)      (ttcn3)
1*-----------*1
            /
2*-broken--/

Remove the 1st ns2 bind after the other NSVC has failed.

Change-Id: I8f7daee7a3bcadf64e8ae607619425adbefe3c4b
diff --git a/ns/NS_Tests.ttcn b/ns/NS_Tests.ttcn
index c08f877..51a30ab 100644
--- a/ns/NS_Tests.ttcn
+++ b/ns/NS_Tests.ttcn
@@ -78,6 +78,7 @@
 	f_vty_set_prompts(NSVTY);
 	f_vty_transceive(NSVTY, "enable");
 	f_vty_transceive(NSVTY, "nsvc nsei " & int2str(mp_nsconfig.nsei) & " force-unconfigured");
+	f_vty_config2(NSVTY, {"ns", "nse " & int2str(mp_nsconfig.nsei)}, "ip-sns-bind local");
 	f_vty_config2(NSVTY, {"ns", "nse " & int2str(mp_nsconfig.nsei)}, "no ip-sns-bind local2");
 	f_vty_config2(NSVTY, {"ns", "bind udp local"}, "ip-sns signalling-weight 1 data-weight 1");
 	f_vty_config2(NSVTY, {"ns", "bind udp local2"}, "ip-sns signalling-weight 1 data-weight 1");
@@ -686,6 +687,43 @@
 	f_clean_ns_codec();
 }
 
+/* Test if SNS fails when removing a bind which has the last valid connection
+ *
+ * ns2 has 2 binds, ttcn3 1 bind.
+ *
+ * nsvcs:
+ * ns2      ttcn3
+ * 1*-----------*1
+ *             /
+ * 2*-broken--/
+ *
+ * remove the 1st ns2 bind.
+ */
+testcase TC_sns_bss_remove_bind_fail_sns() runs on RAW_Test_CT {
+	g_handle_rx_alive := true;
+	f_init_vty();
+	f_init_ns_codec(mp_nsconfig);
+	f_init_ns_codec(mp_nsconfig, 1);
+	f_incoming_sns_size();
+	f_incoming_sns_config();
+	f_outgoing_sns_config();
+	var default d := activate(as_rx_alive_tx_ack());
+
+	f_vty_config2(NSVTY, {"ns", "bind udp local2"}, "ip-sns signalling-weight 1 data-weight 1");
+	f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "ip-sns-bind local2");
+	f_incoming_sns_add(idx_add := 1, w_sig := 1, w_user := 1);
+	/* 2nd bind won't have a valid connection to the ttcn3 */
+	NSCP[1].receive(t_NS_ALIVE);
+	NSCP[1].receive(t_NS_ALIVE);
+	NSCP[1].receive(t_NS_ALIVE);
+	NSCP[1].receive(t_NS_ALIVE);
+	NSCP[1].receive(t_NS_ALIVE);
+	f_sleep(1.0);
+	f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "no ip-sns-bind local");
+	setverdict(pass);
+	f_clean_ns_codec();
+}
+
 testcase TC_idle() runs on RAW_Test_CT {
 	f_init_vty();
 	f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
@@ -852,6 +890,7 @@
 			execute( TC_sns_bss_add_change_del() );
 			/* execute( TC_sns_bss_all_signalling_nsvcs_failed() ); */
 			execute( TC_sns_rx_size_force_unconf() );
+			execute( TC_sns_bss_remove_bind_fail_sns() );
 		}
 
 		if (mp_sns_role == SNS_ROLE_SGSN) {