sccp: Add Tests for SCMG SST procedure

The SST procedure can be used by any SCCP node to test the availability
of a remote SSN.  If the specified remote SSN is available at the
specified PC, a SCMG SSA is returned.  If not, there's a timeout.

Test for SSN=1 (SCMG), another non-SCMG SSN that exists, and for one
SSN that doesn't exist.

Change-Id: If3f5f3144c0ed83d0bda5953522a9d73287c8ba2
diff --git a/sccp/SCCP_Tests_RAW.ttcn b/sccp/SCCP_Tests_RAW.ttcn
index 7d44eb4..356fbb2 100644
--- a/sccp/SCCP_Tests_RAW.ttcn
+++ b/sccp/SCCP_Tests_RAW.ttcn
@@ -310,11 +310,109 @@
 	}
 }
 
+function f_scmg_xceive(SCCP_PAR_Address calling, SCCP_PAR_Address called,
+		       template (value) PDU_SCMG_message tx,
+		       template (omit) PDU_SCMG_message rx_exp) runs on SCCP_Test_RAW_CT
+{
+	var boolean exp_something := true;
+	timer T := 5.0;
+
+	if (istemplatekind(rx_exp, "omit")) {
+		exp_something := false;
+	}
+
+	MTP3.clear;
+	f_send_sccp(ts_SCCP_UDT(calling, called, enc_PDU_SCMG_message(valueof(tx))));
+	T.start;
+	alt {
+	[exp_something] MTP3.receive(tr_SCCP_MTP3_TRANSFERind(tr_SCCP_UDT(called, calling, decmatch rx_exp))) {
+		setverdict(pass);
+		}
+	[] MTP3.receive(tr_SCCP_MTP3_TRANSFERind(tr_SCCP_UDT(called, calling, ?))) {
+		setverdict(fail, "Received unexpected SCCP waiting for ", rx_exp);
+		}
+	[] MTP3.receive {
+		setverdict(fail, "Received unexpected waiting for ", rx_exp);
+		}
+	[exp_something] T.timeout {
+		setverdict(fail, "Timeout waiting for ", rx_exp);
+		}
+	[not exp_something] T.timeout {
+		setverdict(pass);
+		}
+	}
+
+}
+
+/* Test is SST(SSN=1) returns SSA */
+testcase TC_scmg_sst_ssn1() runs on SCCP_Test_RAW_CT {
+	var SCCP_PAR_Address calling, called;
+	var template (value) PDU_SCMG_message tx;
+	var template (present) PDU_SCMG_message rx_exp;
+
+	f_init_raw(mp_sccp_cfg[0]);
+	f_sleep(1.0);
+
+	called := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].peer_pc, 1,
+					     mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type));
+	calling := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].own_pc, 1,
+					     mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type));
+
+	tx := ts_SCMG_SST(1, mp_sccp_cfg[0].peer_pc);
+	rx_exp := ts_SCMG_SSA(1, mp_sccp_cfg[0].peer_pc);
+	f_scmg_xceive(calling, called, tx, rx_exp);
+}
+
+/* Test is SST(SSN=valid) returns SSA */
+testcase TC_scmg_sst_ssn_valid() runs on SCCP_Test_RAW_CT {
+	var SCCP_PAR_Address calling, called;
+	var template (value) PDU_SCMG_message tx;
+	var template (present) PDU_SCMG_message rx_exp;
+
+	f_init_raw(mp_sccp_cfg[0]);
+	f_sleep(1.0);
+
+	called := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].peer_pc, 1,
+					     mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type));
+	calling := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].own_pc, 1,
+					     mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type));
+
+	tx := ts_SCMG_SST(mp_sccp_cfg[0].peer_ssn, mp_sccp_cfg[0].peer_pc);
+	rx_exp := ts_SCMG_SSA(mp_sccp_cfg[0].peer_ssn, mp_sccp_cfg[0].peer_pc);
+	f_scmg_xceive(calling, called, tx, rx_exp);
+}
+
+
+/* Test is SST(SSN=invalid) returns nothing */
+testcase TC_scmg_sst_ssn_invalid() runs on SCCP_Test_RAW_CT {
+	var SCCP_PAR_Address calling, called;
+	var template (value) PDU_SCMG_message tx;
+	var template (omit) PDU_SCMG_message rx_exp;
+
+	f_init_raw(mp_sccp_cfg[0]);
+	f_sleep(1.0);
+
+	called := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].peer_pc, 1,
+					     mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type));
+	calling := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].own_pc, 1,
+					     mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type));
+
+	tx := ts_SCMG_SST(123, mp_sccp_cfg[0].peer_pc);
+	rx_exp := omit;
+	f_scmg_xceive(calling, called, tx, rx_exp);
+}
+
+
+
 control {
 	execute( TC_cr_cc() );
 	execute( TC_udt_without_cr_cc() );
 	execute( TC_tiar_timeout() );
 	execute( TC_it_avoids_tiar() );
+
+	execute( TC_scmg_sst_ssn1() );
+	execute( TC_scmg_sst_ssn_valid() );
+	execute( TC_scmg_sst_ssn_invalid() );
 }