sip: Add SIP_Emulation and first osmo-sip-connector test case
Change-Id: Ifd47b0d48c609b4a678ea47aa7f89f5c12e6c0d2
diff --git a/sip/SIP_Tests.cfg b/sip/SIP_Tests.cfg
new file mode 100644
index 0000000..db435af
--- /dev/null
+++ b/sip/SIP_Tests.cfg
@@ -0,0 +1,18 @@
+[ORDERED_INCLUDE]
+# Common configuration, shared between test suites
+"../Common.cfg"
+# testsuite specific configuration, not expected to change
+"./SIP_Tests.default"
+
+# Local configuration below
+
+[LOGGING]
+
+[TESTPORT_PARAMETERS]
+
+[MODULE_PARAMETERS]
+
+[MAIN_CONTROLLER]
+
+[EXECUTE]
+SIP_Tests.control
diff --git a/sip/SIP_Tests.default b/sip/SIP_Tests.default
new file mode 100644
index 0000000..b0abf18
--- /dev/null
+++ b/sip/SIP_Tests.default
@@ -0,0 +1,30 @@
+[LOGGING]
+FileMask := LOG_ALL | TTCN_MATCHING;
+
+"IPA-CTRL-IPA".FileMask := ERROR | WARNING;
+mtc.FileMask := ERROR | WARNING;
+
+[TESTPORT_PARAMETERS]
+"SIP_Test-MNCC".MNCC.socket_type := "SEQPACKET";
+*.SIPVTY.CTRL_MODE := "client"
+*.SIPVTY.CTRL_HOSTNAME := "127.0.0.1"
+*.SIPVTY.CTRL_PORTNUM := "4256"
+*.SIPVTY.CTRL_LOGIN_SKIPPED := "yes"
+*.SIPVTY.CTRL_DETECT_SERVER_DISCONNECTED := "yes"
+*.SIPVTY.CTRL_READMODE := "buffered"
+*.SIPVTY.CTRL_CLIENT_CLEANUP_LINEFEED := "yes"
+*.SIPVTY.PROMPT1 := "OsmoMNCC> "
+
+*.SIP.local_sip_port := "5060"
+*.SIP.default_local_address := "127.0.0.2"
+*.SIP.default_sip_protocol := "UDP"
+*.SIP.default_dest_port := "5060"
+*.SIP.default_dest_address := "127.0.0.1"
+
+
+[MODULE_PARAMETERS]
+Osmocom_VTY_Functions.mp_prompt_prefix := "OsmoMNCC";
+
+[MAIN_CONTROLLER]
+
+[EXECUTE]
diff --git a/sip/SIP_Tests.ttcn b/sip/SIP_Tests.ttcn
new file mode 100644
index 0000000..de2f498
--- /dev/null
+++ b/sip/SIP_Tests.ttcn
@@ -0,0 +1,173 @@
+module SIP_Tests {
+
+import from General_Types all;
+import from Osmocom_Types all;
+
+import from Osmocom_CTRL_Functions all;
+import from Osmocom_CTRL_Types all;
+import from Osmocom_CTRL_Adapter all;
+
+import from TELNETasp_PortType all;
+import from Osmocom_VTY_Functions all;
+
+import from MNCC_Emulation all;
+import from MNCC_Types all;
+
+import from SDP_Types all;
+
+import from SIP_Emulation all;
+import from SIPmsg_Types all;
+
+modulepar {
+ //charstring mp_local_host := "127.0.0.2;
+ charstring mp_osmosip_host := "127.0.0.1";
+ integer mp_osmosip_port_ctrl := -1; /* RFU */
+ charstring mp_mncc := "/tmp/mncc";
+}
+
+type component test_CT extends CTRL_Adapter_CT {
+ var MNCC_Emulation_CT vc_MNCC;
+ var SIP_Emulation_CT vc_SIP;
+
+ port TELNETasp_PT SIPVTY;
+}
+
+type component ConnHdlr extends SIP_ConnHdlr, MNCC_ConnHdlr {
+ var ConnHdlrPars g_pars;
+ timer g_Tguard;
+}
+
+type record ConnHdlrPars {
+ float t_guard
+}
+
+
+function f_init_mncc(charstring id) runs on test_CT {
+ id := id & "-MNCC";
+ var MnccOps ops := {
+ create_cb := refers(MNCC_Emulation.ExpectedCreateCallback),
+ unitdata_cb := refers(MNCC_Emulation.DummyUnitdataCallback)
+ };
+
+ vc_MNCC := MNCC_Emulation_CT.create(id);
+ map(vc_MNCC:MNCC, system:MNCC_CODEC_PT);
+ vc_MNCC.start(MNCC_Emulation.main(ops, id, mp_mncc, true));
+}
+
+function f_init() runs on test_CT {
+ //f_ipa_ctrl_start(mp_osmosip_host, mp_osmosip_port_ctrl);
+ f_init_mncc("SIP_Test");
+ log("end of f_init_mncc");
+ f_init_sip(vc_SIP, "SIP_Test");
+ log("end of f_init_sip");
+
+ map(self:SIPVTY, system:SIPVTY);
+ f_vty_set_prompts(SIPVTY);
+ f_vty_transceive(SIPVTY, "enable");
+ log("end of f_init");
+}
+
+type function void_fn(charstring id) runs on ConnHdlr;
+
+function f_start_handler(void_fn fn, ConnHdlrPars pars)
+runs on test_CT return ConnHdlr {
+ var ConnHdlr vc_conn;
+ var charstring id := testcasename();
+
+ vc_conn := ConnHdlr.create(id);
+
+ connect(vc_conn:SIP, vc_SIP:CLIENT);
+ connect(vc_conn:SIP_PROC, vc_SIP:CLIENT_PROC);
+
+ connect(vc_conn:MNCC, vc_MNCC:MNCC_CLIENT);
+ connect(vc_conn:MNCC_PROC, vc_MNCC:MNCC_PROC);
+
+ vc_conn.start(f_handler_init(fn, id, pars));
+ return vc_conn;
+}
+
+private altstep as_Tguard() runs on ConnHdlr {
+ [] g_Tguard.timeout {
+ setverdict(fail, "Tguard timeout");
+ self.stop;
+ }
+}
+
+private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars)
+runs on ConnHdlr {
+ g_pars := pars;
+ g_Tguard.start(pars.t_guard);
+ activate(as_Tguard());
+
+ /* call the user-supied test case function */
+ fn.apply(id);
+}
+
+
+template (value) ConnHdlrPars t_Pars := {
+ t_guard := 30.0
+}
+
+private function f_TC_mo_setup(charstring id) runs on ConnHdlr {
+ var PDU_SIP_Request sip_req;
+
+ var MNCC_number dst := valueof(ts_MNCC_number("01234567"));
+ var MNCC_number src := valueof(ts_MNCC_number("112"));
+
+ f_create_sip_expect(valueof(ts_SIP_Url("+01234567")));
+
+ log("sending mncc setup");
+ MNCC.send(ts_MNCC_SETUP_ind(2342, dst, src, "262420123456789"));
+
+ MNCC.receive(tr_MNCC_RTP_CREATE(2342));
+ MNCC.send(ts_MNCC_RTP_CREATE(2342));
+
+ SIP.receive(PDU_SIP_Request:?) -> value sip_req {
+ log(sip_req);
+ }
+}
+
+testcase TC_mo_setup() runs on test_CT {
+ var ConnHdlrPars pars;
+ var ConnHdlr vc_conn;
+
+ f_init();
+
+ pars := valueof(t_Pars);
+ vc_conn := f_start_handler(refers(f_TC_mo_setup), pars);
+ vc_conn.done;
+}
+
+
+
+
+
+/* SIP specifics */
+
+const integer c_SIP_PORT := 5060;
+
+template (value) SIP_comm_adress ts_SipAddr(charstring rhost,
+ template (omit) charstring lhost := omit,
+ integer rport := c_SIP_PORT,
+ integer lport := c_SIP_PORT,
+ SIP_com_prot prot := UDP_E) := {
+ remote_host := rhost,
+ remote_port := rport,
+ local_host := lhost,
+ local_port := lport,
+ protocol := prot
+}
+
+template (value) ASP_SIP_open ts_SIP_open(SIP_comm_adress addr) := {
+ addr := addr
+}
+
+
+
+control {
+ execute( TC_mo_setup() );
+}
+
+
+
+}
diff --git a/sip/gen_links.sh b/sip/gen_links.sh
new file mode 100755
index 0000000..ff64056
--- /dev/null
+++ b/sip/gen_links.sh
@@ -0,0 +1,49 @@
+#!/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"
+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
+
+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.ProtocolModules.RTP/src
+FILES="RTP_EncDec.cc RTP_Types.ttcn"
+gen_links $DIR $FILES
+
+DIR=$BASEDIR/titan.TestPorts.SIPmsg/src
+FILES="SIP_parse.h SIP_parse.y SIP_parse_.tab.h SIPmsg_PT.hh SIPmsg_Types.ttcn SIP_parse.l SIP_parse_.tab.c SIPmsg_PT.cc SIPmsg_PortType.ttcn lex.SIP_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 "
+FILES+="Osmocom_CTRL_Types.ttcn Osmocom_CTRL_Functions.ttcn Osmocom_CTRL_Adapter.ttcn "
+FILES+="RTP_CodecPort.ttcn RTP_CodecPort_CtrlFunctDef.cc "
+FILES+="SIP_Emulation.ttcn "
+gen_links $DIR $FILES
+
+ignore_pp_results
diff --git a/sip/regen_makefile.sh b/sip/regen_makefile.sh
new file mode 100755
index 0000000..86f71b8
--- /dev/null
+++ b/sip/regen_makefile.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+FILES="*.ttcn *.ttcnpp TCCConversion.cc TCCInterface.cc UD_PT.cc MNCC_EncDec.cc IPL4asp_PT.cc
+IPL4asp_discovery.cc SDP_EncDec.cc RTP_EncDec.cc IPA_CodecPort_CtrlFunctDef.cc RTP_CodecPort_CtrlFunctDef.cc TELNETasp_PT.cc Native_FunctionDefs.cc SIPmsg_PT.cc *.c "
+
+export CPPFLAGS_TTCN3=""
+
+../regen-makefile.sh SIP_Tests.ttcn $FILES