Change in osmo-ttcn3-hacks[master]: introduce a TTCN3 test suite for SCCP

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

Stefan Sperling gerrit-no-reply at lists.osmocom.org
Sat Jun 16 09:43:30 UTC 2018


Stefan Sperling has uploaded this change for review. ( https://gerrit.osmocom.org/9653


Change subject: introduce a TTCN3 test suite for SCCP
......................................................................

introduce a TTCN3 test suite for SCCP

This test suite acts as an SCCP server on top of M3UA.

SCCP tests are run against the sccp_demo_user program which
can be found in libosmo-sccp/examples. This program must be
started in client mode: sccp_demo_user -c
The SCCP test suite should then work out of the box with
the provided SCCP_Tests.cfg file and this additional change
to sccp_demo_user default point codes:
https://gerrit.osmocom.org/#/c/libosmo-sccp/+/9652/

There is currently only one test, for the libosmo-sccp crash
reported as issue OS#2666. The implementation of this test
is currently using an ugly workaround due to shortcomings of
the M3UA Emulation layer (see source code comments). Whether
a better solution is feasible is still to be determined.

The test requires a patch to the SCCP Protocol Emulation which
has been submitted upstream: https://git.eclipse.org/r/#/c/124552/

I did attempt to cut down the number of dependencies on other
TTCN3 modules. It seems the current dependency set is the minimal
possible one, mostly due to use of the BSSAP_Adapter module.

Change-Id: I03f5e8b282a7396b45417495c88d8fb81b26cda8
Related: OS#2666
---
M Makefile
M library/BSSAP_Adapter.ttcn
A sccp/SCCP_Tests.cfg
A sccp/SCCP_Tests.default
A sccp/SCCP_Tests.ttcn
A sccp/gen_links.sh
A sccp/regen_makefile.sh
7 files changed, 330 insertions(+), 1 deletion(-)



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

diff --git a/Makefile b/Makefile
index fcd6601..c23521f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-SUBDIRS=bsc bsc-nat bts ggsn_tests hlr lapdm mgw msc pcu selftest sgsn sip sysinfo
+SUBDIRS=bsc bsc-nat bts ggsn_tests hlr lapdm mgw msc pcu sccp selftest sgsn sip sysinfo
 
 PARALLEL_MAKE ?= -j8
 
diff --git a/library/BSSAP_Adapter.ttcn b/library/BSSAP_Adapter.ttcn
index e50487d..0517890 100644
--- a/library/BSSAP_Adapter.ttcn
+++ b/library/BSSAP_Adapter.ttcn
@@ -73,6 +73,25 @@
 	globalTitle := omit
 }
 
+/* construct a SCCP_PAR_Address with only GT */
+template (value) SCCP_PAR_Address ts_SccpAddr_GT(hexstring global_address) := {
+	addressIndicator := {
+		pointCodeIndic := '0'B,
+		ssnIndicator := '0'B,
+		globalTitleIndic := '0001'B, // NAI only
+		routingIndicator := cg_route_on_GT // route on GT
+	},
+	signPointCode := omit,
+	subsystemNumber := omit,
+	globalTitle := {
+		gti0001 := {
+			natureOfAddress := '0000011'B,
+			oddeven := '0'B,
+			globalTitleAddress := global_address
+		}
+	}
+}
+
 private function init_pars(inout BSSAP_Adapter ba, in BSSAP_Configuration cfg) {
 	ba.sccp_pars := {
 		sio := {
diff --git a/sccp/SCCP_Tests.cfg b/sccp/SCCP_Tests.cfg
new file mode 100644
index 0000000..4b7e742
--- /dev/null
+++ b/sccp/SCCP_Tests.cfg
@@ -0,0 +1,19 @@
+[ORDERED_INCLUDE]
+# Common configuration, shared between test suites
+"../Common.cfg"
+# testsuite specific configuration, not expected to change
+"./SCCP_Tests.default"
+
+# Local configuration below
+
+[LOGGING]
+
+[TESTPORT_PARAMETERS]
+
+[MODULE_PARAMETERS]
+
+[MAIN_CONTROLLER]
+
+[EXECUTE]
+SCCP_Tests.control
+#SCCP_Tests.TC_routing_global_title_crash
diff --git a/sccp/SCCP_Tests.default b/sccp/SCCP_Tests.default
new file mode 100644
index 0000000..4ed9862
--- /dev/null
+++ b/sccp/SCCP_Tests.default
@@ -0,0 +1,42 @@
+[LOGGING]
+FileMask := LOG_ALL | TTCN_MATCHING | DEBUG_ENCDEC;
+
+BSSAP.FileMask := LOG_NOTHING;
+"SCCP_Test_M3UA".FileMask := ERROR | WARNING;
+"SCCP_Test_SCCP".FileMask := ERROR | WARNING;
+"IPA-CTRL-IPA".FileMask := ERROR | WARNING;
+mtc.FileMask := ERROR | WARNING;
+
+[TESTPORT_PARAMETERS]
+*.SCCP_DEMO_USER_VTY.CTRL_MODE := "client"
+*.SCCP_DEMO_USER_VTY.CTRL_HOSTNAME := "127.0.0.1"
+*.SCCP_DEMO_USER_VTY.CTRL_PORTNUM := "2325"
+*.SCCP_DEMO_USER_VTY.CTRL_LOGIN_SKIPPED := "yes"
+*.SCCP_DEMO_USER_VTY.CTRL_DETECT_SERVER_DISCONNECTED := "yes"
+*.SCCP_DEMO_USER_VTY.CTRL_READMODE := "buffered"
+*.SCCP_DEMO_USER_VTY.CTRL_CLIENT_CLEANUP_LINEFEED := "yes"
+*.SCCP_DEMO_USER_VTY.PROMPT1 := "sccp-demo-user> "
+
+[MODULE_PARAMETERS]
+M3UA_Emulation.tsp_logVerbose := true;
+M3UA_Emulation.tsp_SCTP_Server_Mode := true;
+M3UA_Emulation.tsp_M3UA_Server_Mode := true;
+SCCP_Tests.mp_bssap_cfg := {
+	{
+			transport := BSSAP_TRANSPORT_AoIP,
+			sccp_service_type := "mtp3_itu",
+			sctp_addr := { 2905, "127.0.0.1", 2905, "127.0.0.2" },
+			own_pc := 185,
+			own_ssn := 254,
+			peer_pc := 23,
+			peer_ssn := 254,
+			sio := '83'O,
+			rctx := 0
+	}
+};
+
+Osmocom_VTY_Functions.mp_prompt_prefix := "sccp-demo-user";
+
+[MAIN_CONTROLLER]
+
+[EXECUTE]
diff --git a/sccp/SCCP_Tests.ttcn b/sccp/SCCP_Tests.ttcn
new file mode 100644
index 0000000..5b6748f
--- /dev/null
+++ b/sccp/SCCP_Tests.ttcn
@@ -0,0 +1,157 @@
+/* (C) 2018 by sysmocom s.f.m.c. GmbH <info at sysmocom.de>
+ *
+ * Author: Stefan Sperling <ssperling at sysmocom.de>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+module SCCP_Tests {
+
+import from M3UA_Emulation all;
+
+import from SCCPasp_Types all;
+import from SCCP_Types all;
+import from SCCP_Emulation all;
+
+import from SCTPasp_PortType all;
+
+import from Osmocom_CTRL_Adapter all;
+
+import from TELNETasp_PortType all;
+import from Osmocom_VTY_Functions all;
+
+import from BSSAP_Adapter all;
+
+
+type component system_CT {
+     port SCTPasp_PT sctp;
+};
+
+type component MTC_CT extends CTRL_Adapter_CT {
+	/* VTY to sccp_demo_user (not used yet) */
+	port TELNETasp_PT SCCP_DEMO_USER_VTY;
+
+	/* SCCP protocol runs on top of M3UA Emulation.
+	 * "System Under Test" is libosmo-sccp's sccp_demo_user example program. */
+	var SCCP_CT vc_SCCP_A;
+	var M3UA_CT vc_M3UA;
+	port SCCPasp_PT A_PORT;
+}
+
+type record of BSSAP_Configuration BSSAP_Configurations;
+modulepar {
+	BSSAP_Configurations mp_bssap_cfg;
+}
+
+function f_init(BSSAP_Configuration cfg) runs on MTC_CT {
+	var MSC_SCCP_MTP3_parameters v_param := {
+		sio := {
+			ni := substr(oct2bit(cfg.sio),0,2),
+			prio := substr(oct2bit(cfg.sio),2,2),
+			si := substr(oct2bit(cfg.sio),4,4)
+		},
+		opc := cfg.own_pc,
+		dpc := cfg.peer_pc,
+		sls := 0,
+		sccp_serviceType := cfg.sccp_service_type,
+		ssn := cfg.own_ssn
+	};
+
+	map(self:SCCP_DEMO_USER_VTY, system:SCCP_DEMO_USER_VTY);
+	f_vty_set_prompts(SCCP_DEMO_USER_VTY);
+	f_vty_transceive(SCCP_DEMO_USER_VTY, "enable");
+
+	/* Create and connect test components for an SCCP connection with M3UA beneath. */
+	vc_SCCP_A := SCCP_CT.create;
+	vc_M3UA := M3UA_CT.create;
+	connect(self:A_PORT, vc_SCCP_A:SCCP_SP_PORT);
+	connect(vc_M3UA:MTP3_SP_PORT, vc_SCCP_A:MTP3_SCCP_PORT);
+	map(vc_M3UA:SCTP_PORT, system:sctp);
+
+	vc_M3UA.start(f_M3UA_Emulation(cfg.sctp_addr));
+	vc_SCCP_A.start(SCCPStart(v_param));
+}
+
+function f_cleanup() runs on MTC_CT {
+	all component.stop;
+	unmap(vc_M3UA:SCTP_PORT, system:sctp);
+	disconnect(vc_M3UA:MTP3_SP_PORT, vc_SCCP_A:MTP3_SCCP_PORT);
+	disconnect(self:A_PORT, vc_SCCP_A:SCCP_SP_PORT);
+	self.stop
+}
+
+/*
+ * libosmo-sccp does not support Global Title address as a routing indicator.
+ * But sccp_demo_user should not crash if such a message is received (see OS#2666).
+ */
+testcase TC_routing_global_title_crash() runs on MTC_CT system system_CT {
+	timer TL_timer:= 10.0; /* twice the sccp_demo_user connection attempt interval */
+	var SCCP_PAR_Address v_CallingAddress;
+	var SCCP_PAR_Address v_CalledAddress;
+	var octetstring vl_userdata :='12345678901234567890'O;
+	var ASP_SCCP_N_UNITDATA_ind vl_N_UNITDATA_ind;
+
+	f_init(mp_bssap_cfg[0]);
+
+	/* Called address with routing indicator set to Global Title Address. This used to trigger the crash. */
+	v_CalledAddress := valueof(ts_SccpAddr_GT('012345'H));
+
+	v_CallingAddress := valueof(ts_SccpAddr_PC_SSN(mp_bssap_cfg[0].own_pc, mp_bssap_cfg[0].own_ssn,
+						       mp_bssap_cfg[0].sio, mp_bssap_cfg[0].sccp_service_type));
+	A_PORT.send(t_ASP_N_UNITDATA_req(v_CalledAddress, v_CallingAddress, '00000001'B /* sequence control */,
+					 '00000001'B /* return option */, vl_userdata, omit));
+
+	/*
+	 * Start a timeout within which our DATA packet will be sent out.
+	 * The M3UA Emulation layer has buffered the packet and is going
+	 * to send it when the sccp_demo_user SCCP client connects.
+	 *
+	 * libosmo-sccp will echo the packet back at us in an SCCP UDTS packet.
+	 * However, the current M3UA Emulation implementation will discard this
+	 * response because it arrives on a separate SCTP association and the
+	 * emulation only supports one association at a time.
+	 *
+	 * As a workaround, we wait for a fixed amount of time and then issue
+	 * another command to the VTY of sccp_demo_user. If sccp_demo_user
+	 * has crashed, this will result in a test failure.
+	 */
+	TL_timer.start;
+	alt {
+		[] A_PORT.receive(tr_ASP_N_UNITDATA_ind) -> value vl_N_UNITDATA_ind {
+			log("Received data from SCCP client.");
+			repeat;
+		}
+
+		[] TL_timer.timeout {
+			log("Timeout....");
+		}
+	}
+	TL_timer.stop;
+
+	/* Check that the VTY is still active (implying that the process hasn't crashed). */
+	f_vty_transceive_ret(SCCP_DEMO_USER_VTY, "?");
+	setverdict(pass);
+
+	f_cleanup();
+}
+
+control {
+	execute( TC_routing_global_title_crash() );
+}
+
+
+}
diff --git a/sccp/gen_links.sh b/sccp/gen_links.sh
new file mode 100755
index 0000000..49a57a8
--- /dev/null
+++ b/sccp/gen_links.sh
@@ -0,0 +1,85 @@
+#!/bin/bash
+
+BASEDIR=../deps
+
+. ../gen_links.sh.inc
+
+DIR=$BASEDIR/titan.TestPorts.UNIX_DOMAIN_SOCKETasp/src
+FILES="UD_PT.cc  UD_PT.hh  UD_PortType.ttcn  UD_Types.ttcn"
+gen_links $DIR $FILES
+
+DIR=$BASEDIR/titan.Libraries.TCCUsefulFunctions/src
+FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn TCCConversion.cc TCCInterface.cc TCCInterface_ip.h"
+FILES+=" TCCEncoding_Functions.ttcn TCCEncoding.cc " # GSM 7-bit coding
+gen_links $DIR $FILES
+
+DIR=$BASEDIR/titan.TestPorts.Common_Components.Socket-API/src
+FILES="Socket_API_Definitions.ttcn"
+gen_links $DIR $FILES
+
+# Required by MGCP and IPA
+DIR=$BASEDIR/titan.TestPorts.IPL4asp/src
+FILES="IPL4asp_Functions.ttcn  IPL4asp_PT.cc  IPL4asp_PT.hh IPL4asp_PortType.ttcn  IPL4asp_Types.ttcn  IPL4asp_discovery.cc IPL4asp_protocol_L234.hh"
+gen_links $DIR $FILES
+
+# required by M3UA_Emulation
+DIR=$BASEDIR/titan.ProtocolModules.M3UA/src
+FILES="M3UA_Types.ttcn"
+gen_links $DIR $FILES
+
+# required by M3UA_Emulation
+DIR=$BASEDIR/titan.TestPorts.SCTPasp/src
+FILES="SCTPasp_PT.cc  SCTPasp_PT.hh  SCTPasp_PortType.ttcn  SCTPasp_Types.ttcn"
+gen_links $DIR $FILES
+
+# required by M3UA Emulation
+DIR=$BASEDIR/titan.TestPorts.MTP3asp/src
+FILES="MTP3asp_PortType.ttcn  MTP3asp_Types.ttcn"
+gen_links $DIR $FILES
+
+# required by SCCP Emulation
+DIR=$BASEDIR/titan.ProtocolEmulations.M3UA/src
+FILES="M3UA_Emulation.ttcn"
+gen_links $DIR $FILES
+
+DIR=$BASEDIR/titan.ProtocolEmulations.SCCP/src
+FILES="SCCP_Emulation.ttcn  SCCP_EncDec.cc  SCCP_Mapping.ttcnpp  SCCP_Types.ttcn  SCCPasp_Types.ttcn"
+gen_links $DIR $FILES
+
+DIR=$BASEDIR/titan.ProtocolModules.BSSMAP_v11.2.0/src
+FILES="BSSAP_Types.ttcn"
+gen_links $DIR $FILES
+
+DIR=$BASEDIR/titan.ProtocolModules.ROSE/src
+FILES="Remote_Operations_Generic_ROS_PDUs.asn  Remote_Operations_Information_Objects.asn"
+gen_links $DIR $FILES
+
+DIR=$BASEDIR/titan.ProtocolModules.MAP/src
+FILES="MAP_ApplicationContexts.asn MAP_CH_DataTypes.asn MAP_CallHandlingOperations.asn MAP_CommonDataTypes.asn MAP_DialogueInformation.asn MAP_ER_DataTypes.asn MAP_EncDec.cc MAP_Errors.asn MAP_GR_DataTypes.asn MAP_Group_Call_Operations.asn MAP_LCS_DataTypes.asn MAP_LocationServiceOperations.asn MAP_MS_DataTypes.asn MAP_MobileServiceOperations.asn MAP_OM_DataTypes.asn MAP_OperationAndMaintenanceOperations.asn MAP_PDU_Defs.asn MAP_Protocol.asn MAP_SM_DataTypes.asn MAP_SS_Code.asn MAP_SS_DataTypes.asn MAP_ShortMessageServiceOperations.asn MAP_SupplementaryServiceOperations.asn MAP_TS_Code.asn MAP_Types.ttcn "
+FILES+="MAP_BS_Code.asn MAP_ExtensionDataTypes.asn MobileDomainDefinitions.asn"
+gen_links $DIR $FILES
+
+DIR=$BASEDIR/titan.ProtocolModules.MobileL3_v13.4.0/src
+FILES="MobileL3_CC_Types.ttcn MobileL3_CommonIE_Types.ttcn MobileL3_GMM_SM_Types.ttcn MobileL3_MM_Types.ttcn MobileL3_RRM_Types.ttcn MobileL3_SMS_Types.ttcn MobileL3_SS_Types.ttcn MobileL3_Types.ttcn "
+FILES+="SS_DataTypes.asn SS_Errors.asn SS_Operations.asn SS_PDU_Defs.asn SS_Protocol.asn SS_Types.ttcn SS_EncDec.cc"
+gen_links $DIR $FILES
+
+DIR=$BASEDIR/titan.ProtocolModules.SDP/src
+FILES="SDP_EncDec.cc SDP_Types.ttcn SDP_parse_.tab.c SDP_parse_.tab.h SDP_parse_parser.h SDP_parser.l
+SDP_parser.y lex.SDP_parse_.c"
+gen_links $DIR $FILES
+
+DIR=$BASEDIR/titan.TestPorts.TELNETasp/src
+FILES="TELNETasp_PT.cc  TELNETasp_PT.hh  TELNETasp_PortType.ttcn"
+gen_links $DIR $FILES
+
+
+DIR=../library
+FILES="General_Types.ttcn GSM_Types.ttcn Osmocom_Types.ttcn MNCC_Types.ttcn MNCC_EncDec.cc MNCC_CodecPort.ttcn mncc.h MNCC_Emulation.ttcn Osmocom_VTY_Functions.ttcn Native_Functions.ttcn Native_FunctionDefs.cc "
+FILES+="IPA_Types.ttcn IPA_Emulation.ttcnpp IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn IPA_CodecPort_CtrlFunctDef.cc GSUP_Types.ttcn GSUP_Emulation.ttcn "
+FILES+="Osmocom_CTRL_Types.ttcn Osmocom_CTRL_Functions.ttcn Osmocom_CTRL_Adapter.ttcn L3_Templates.ttcn L3_Common.ttcn "
+FILES+="BSSMAP_Emulation.ttcn BSSAP_CodecPort.ttcn BSSMAP_Templates.ttcn BSSAP_Adapter.ttcn MGCP_Types.ttcn MGCP_Templates.ttcn MGCP_CodecPort_CtrlFunct.ttcn MGCP_Emulation.ttcn "
+FILES+="MGCP_CodecPort.ttcn MGCP_CodecPort_CtrlFunctDef.cc "
+gen_links $DIR $FILES
+
+ignore_pp_results
diff --git a/sccp/regen_makefile.sh b/sccp/regen_makefile.sh
new file mode 100755
index 0000000..ddb7ace
--- /dev/null
+++ b/sccp/regen_makefile.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+FILES="*.ttcn *.ttcnpp SCCP_EncDec.cc  SCTPasp_PT.cc  TCCConversion.cc TCCInterface.cc UD_PT.cc MNCC_EncDec.cc IPL4asp_PT.cc IPL4asp_discovery.cc SDP_EncDec.cc IPA_CodecPort_CtrlFunctDef.cc MGCP_CodecPort_CtrlFunctDef.cc TELNETasp_PT.cc Native_FunctionDefs.cc MAP_EncDec.cc SS_EncDec.cc TCCEncoding.cc *.c *.asn"
+
+export CPPFLAGS_TTCN3="-DIPA_EMULATION_MGCP -DIPA_EMULATION_GSUP -DIPA_EMULATION_SCCP -DUSE_MTP3_DISTRIBUTOR"
+
+../regen-makefile.sh SCCP_Tests.ttcn $FILES

-- 
To view, visit https://gerrit.osmocom.org/9653
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I03f5e8b282a7396b45417495c88d8fb81b26cda8
Gerrit-Change-Number: 9653
Gerrit-PatchSet: 1
Gerrit-Owner: Stefan Sperling <ssperling at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180616/2acef114/attachment.htm>


More information about the gerrit-log mailing list