aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2016-08-15 11:54:24 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2016-08-15 13:36:25 +0200
commit368e549a92258052840be2ce5e08b925bb7781cb (patch)
tree70821a723f0ec7e717264b6eca5f840fc85c4f6c
parentb1d46b4488d5e08f5d75b0cfa09ae43d5fc997d7 (diff)
tests/vty: Add VTY tests to the osmo-stp
There seems to be issues with the write handling of the osmo-stp and so far we did not enable vty tests here. Make it possible to enable the tests, fix the VTY strings, change string to OsmoSTP. Change-Id: I547fd4840d86ce16e8589fb63802dd7099781194
-rw-r--r--.gitignore1
-rw-r--r--configure.ac15
-rwxr-xr-xcontrib/jenkins.sh2
-rw-r--r--doc/examples/osmo-stp.cfg41
-rw-r--r--osmoappdesc.py27
-rw-r--r--src/sctp_m3ua_client.c4
-rw-r--r--src/vty_interface.c39
-rw-r--r--src/vty_interface_cmds.c4
-rw-r--r--tests/Makefile.am10
9 files changed, 121 insertions, 22 deletions
diff --git a/.gitignore b/.gitignore
index 5056481..6435a26 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,6 +23,7 @@ stamp-h1
*.gcda
*.gcno
*.info
+*.pyc
# binaries
cellmgr_ng
diff --git a/configure.ac b/configure.ac
index f0a50e6..47176ac 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,6 +28,21 @@ PKG_CHECK_MODULES([LIBOSMOSCCP], [libosmo-sccp])
PKG_CHECK_MODULES([LIBOSMOVTY], [libosmovty >= 0.3.2])
#PKG_CHECK_MODULES([NEXUSWARE_C7], [nexusware-c7])
+AC_ARG_ENABLE([external_tests],
+ AC_HELP_STRING([--enable-external-tests],
+ [Include the VTY tests in make check [default=no]]),
+ [enable_ext_tests="$enableval"],[enable_ext_tests="no"])
+if test "x$enable_ext_tests" = "xyes" ; then
+ AM_PATH_PYTHON
+ AC_CHECK_PROG(OSMOTESTEXT_CHECK,osmotestvty.py,yes)
+ if test "x$OSMOTESTEXT_CHECK" != "xyes" ; then
+ AC_MSG_ERROR([Please install osmocom-python to run the VTY tests.])
+ fi
+fi
+AC_MSG_CHECKING([whether to enable VTY tests])
+AC_MSG_RESULT([$enable_ext_tests])
+AM_CONDITIONAL(ENABLE_EXT_TESTS, test "x$enable_ext_tests" = "xyes")
+
old_libs=$LIBS
AC_CHECK_LIB([sctp], sctp_sendmsg, [], [AC_MSG_ERROR([The sctp library is required.])])
LIBS=$old_libs
diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index f27f1da..4aa644c 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -36,6 +36,6 @@ PKG_CONFIG_PATH=$PWD/..//install/lib/pkgconfig $MAKE $PARALLEL_MAKE install
cd ../../
autoreconf --install --force
-PKG_CONFIG_PATH=$PWD/deps/install/lib/pkgconfig ./configure
+PKG_CONFIG_PATH=$PWD/deps/install/lib/pkgconfig ./configure --enable-external-tests
PKG_CONFIG_PATH=$PWD/deps/install/lib/pkgconfig $MAKE $PARALLEL_MAKE
PKG_CONFIG_PATH=$PWD/deps/install/lib/pkgconfig LD_LIBRARY_PATH=$PWD/deps/install/lib $MAKE distcheck
diff --git a/doc/examples/osmo-stp.cfg b/doc/examples/osmo-stp.cfg
new file mode 100644
index 0000000..6997bf2
--- /dev/null
+++ b/doc/examples/osmo-stp.cfg
@@ -0,0 +1,41 @@
+ss7
+ udp src-port 4444
+ m2ua src-port 5555
+ linkset 0
+ description My first linkset
+ mtp3 dpc 1
+ mtp3 opc 2
+ mtp3 ni 3
+ link 0
+ description A m2ua link
+ ss7-transport m2ua
+ linkset 1
+ description My m3ua linkset
+ mtp3 dpc 1
+ mtp3 opc 2
+ mtp3 ni 3
+ mtp3 spare 0
+ link 0
+ description A m3ua client
+ ss7-transport m3ua-client
+ msc 0
+ mode server
+ port 5000
+ token atoken
+ msc 1
+ mode server
+ port 5001
+ token atoken
+ timeout ping 20
+ timeout pong 5
+ timeout restart 3
+ application 0
+ description Relay TCP/IPA to M2UA linkset
+ type relay
+ route linkset 0 msc 0
+ forward-only
+ application 1
+ description Relay TCP/IPA to M3UA linkset
+ type relay
+ route linkset 1 msc 1
+ forward-only
diff --git a/osmoappdesc.py b/osmoappdesc.py
new file mode 100644
index 0000000..9ad5188
--- /dev/null
+++ b/osmoappdesc.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+
+# (C) 2016 by Holger Hans Peter Freyther
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+app_configs = {
+ "osmo-stp": ["doc/examples/osmo-stp.cfg"]
+}
+
+apps = [(4242, "src/osmo-stp", "OsmoSTP", "osmo-stp"),
+ ]
+
+vty_command = ["src/osmo-stp", "-c", "doc/examples/osmo-stp.cfg"]
+
+vty_app = apps[0]
+
diff --git a/src/sctp_m3ua_client.c b/src/sctp_m3ua_client.c
index 3726dab..bf9204a 100644
--- a/src/sctp_m3ua_client.c
+++ b/src/sctp_m3ua_client.c
@@ -388,6 +388,10 @@ struct mtp_m3ua_client_link *mtp_m3ua_client_link_init(struct mtp_link *blnk)
lnk->queue.bfd.fd = -1;
lnk->traffic_mode = 2;
lnk->aspac_ack_timeout = 10;
+
+ /* default ports */
+ lnk->local.sin_port = lnk->remote.sin_port = htons(2905);
+
return lnk;
}
diff --git a/src/vty_interface.c b/src/vty_interface.c
index 6c6d30f..3a654c0 100644
--- a/src/vty_interface.c
+++ b/src/vty_interface.c
@@ -103,7 +103,7 @@ DEFUN(node_end, node_end_cmd,
}
static struct vty_app_info vty_info = {
- .name = "Cellmgr-ng",
+ .name = "OsmoSTP",
.version = VERSION,
.go_parent_cb = ss7_go_parent,
};
@@ -155,13 +155,13 @@ static int config_write_ss7(struct vty *vty)
static void write_link(struct vty *vty, struct mtp_link *link)
{
- const char *name = link->name ? link->name : "";
struct mtp_udp_link *ulnk;
struct mtp_m2ua_link *m2ua;
struct mtp_m3ua_client_link *m3ua_client;
vty_out(vty, " link %d%s", link->nr, VTY_NEWLINE);
- vty_out(vty, " description %s%s", name, VTY_NEWLINE);
+ if (link->name && strlen(link->name) > 0)
+ vty_out(vty, " description %s%s", link->name, VTY_NEWLINE);
switch (link->type) {
case SS7_LTYPE_UDP:
@@ -214,12 +214,12 @@ static void write_link(struct vty *vty, struct mtp_link *link)
static void write_linkset(struct vty *vty, struct mtp_link_set *set)
{
- const char *name = set->name ? set->name : "";
struct mtp_link *link;
int i;
vty_out(vty, " linkset %d%s", set->nr, VTY_NEWLINE);
- vty_out(vty, " description %s%s", name, VTY_NEWLINE);
+ if (set->name && strlen(set->name) > 0)
+ vty_out(vty, " description %s%s", set->name, VTY_NEWLINE);
vty_out(vty, " mtp3 dpc %d%s", set->dpc, VTY_NEWLINE);
vty_out(vty, " mtp3 opc %d%s", set->opc, VTY_NEWLINE);
vty_out(vty, " mtp3 ni %d%s", set->ni, VTY_NEWLINE);
@@ -260,18 +260,20 @@ static int config_write_linkset(struct vty *vty)
static void write_msc(struct vty *vty, struct msc_connection *msc)
{
- const char *name = msc->name ? msc->name : "";
vty_out(vty, " msc %d%s", msc->nr, VTY_NEWLINE);
- vty_out(vty, " description %s%s", name, VTY_NEWLINE);
+ if (msc->name && strlen(msc->name) > 0)
+ vty_out(vty, " description %s%s", msc->name, VTY_NEWLINE);
vty_out(vty, " mode %s%s", msc_mode(msc), VTY_NEWLINE);
if (msc->ip)
vty_out(vty, " ip %s%s", msc->ip, VTY_NEWLINE);
vty_out(vty, " port %d%s", msc->port, VTY_NEWLINE);
vty_out(vty, " token %s%s", msc->token, VTY_NEWLINE);
vty_out(vty, " dscp %d%s", msc->dscp, VTY_NEWLINE);
- vty_out(vty, " timeout ping %d%s", msc->ping_time, VTY_NEWLINE);
- vty_out(vty, " timeout pong %d%s", msc->pong_time, VTY_NEWLINE);
+ if (msc->ping_time > 0) {
+ vty_out(vty, " timeout ping %d%s", msc->ping_time, VTY_NEWLINE);
+ vty_out(vty, " timeout pong %d%s", msc->pong_time, VTY_NEWLINE);
+ }
vty_out(vty, " timeout restart %d%s", msc->msc_time, VTY_NEWLINE);
}
@@ -316,10 +318,9 @@ static const char *link_type(enum ss7_set_type type)
static void write_application(struct vty *vty, struct ss7_application *app)
{
- const char *name = app->name ? app->name : "";
-
vty_out(vty, " application %d%s", app->nr, VTY_NEWLINE);
- vty_out(vty, " description %s%s", name, VTY_NEWLINE);
+ if (app->name && strlen(app->name) > 0)
+ vty_out(vty, " description %s%s", app->name, VTY_NEWLINE);
vty_out(vty, " type %s%s", app_type(app->type), VTY_NEWLINE);
if (app->fixed_ass_cmpl_reply)
@@ -463,7 +464,7 @@ DEFUN(cfg_linkset_mtp3_ssn, cfg_linkset_mtp3_ssn_cmd,
DEFUN(cfg_linkset_no_mtp3_ssn, cfg_linkset_no_mtp3_ssn_cmd,
"no mtp3 ssn <0-255>",
- "MTP Level3\n" "SSN supported\n" "SSN\n")
+ NO_STR "MTP Level3\n" "SSN supported\n" "SSN\n")
{
struct mtp_link_set *set = vty->index;
set->supported_ssn[atoi(argv[0])] = 0;
@@ -604,7 +605,7 @@ DEFUN(cfg_linkset_link, cfg_linkset_link_cmd,
DEFUN(cfg_link_ss7_transport, cfg_link_ss7_transport_cmd,
"ss7-transport (none|udp|m2ua|m3ua-client)",
"SS7 transport for the link\n"
- "No transport\n" "MTP over UDP\n" "SCTP M2UA\n")
+ "No transport\n" "MTP over UDP\n" "SCTP M2UA server\n" "SCTP M3UA client\n")
{
int wanted = SS7_LTYPE_NONE;
struct mtp_link *link;
@@ -648,7 +649,7 @@ DEFUN(cfg_link_ss7_transport, cfg_link_ss7_transport_cmd,
DEFUN(cfg_link_udp_dest_ip, cfg_link_udp_dest_ip_cmd,
"udp dest ip HOST_NAME",
- "UDP Transport\n" "IP\n" "Hostname\n")
+ "UDP Transport\n" "Destination\n" "IP\n" "Hostname\n")
{
struct hostent *hosts;
@@ -684,7 +685,7 @@ DEFUN(cfg_link_udp_dest_ip, cfg_link_udp_dest_ip_cmd,
DEFUN(cfg_link_udp_dest_port, cfg_link_udp_dest_port_cmd,
"udp dest port <1-65535>",
- "UDP Transport\n" "Set the port number\n" "Port\n")
+ "UDP Transport\n" "Destination\n" "Set the port number\n" "Port\n")
{
struct mtp_link *link = vty->index;
struct mtp_udp_link *ulnk;
@@ -896,7 +897,7 @@ DEFUN(cfg_link_m3ua_client_routing_ctx, cfg_link_m3ua_client_routing_ctx_cmd,
DEFUN(cfg_link_m3ua_client_traffic_mode, cfg_link_m3ua_client_traffic_mode_cmd,
"m3ua-client traffic-mode (override|loadshare|broadcast)",
- "M3UA Client\n" "Traffic Mode\n" "Override" "Loadshare\n" "Broadcast\n")
+ "M3UA Client\n" "Traffic Mode\n" "Override\n" "Loadshare\n" "Broadcast\n")
{
struct mtp_link *link = vty->index;
struct mtp_m3ua_client_link *m3ua_link;
@@ -1047,7 +1048,7 @@ DEFUN(cfg_msc_timeout_pong, cfg_msc_timeout_pong_cmd,
}
DEFUN(cfg_msc_timeout_restart, cfg_msc_timeout_restart_cmd,
- "timeout restart <1-65535>",
+ "timeout restart <0-65535>",
"Timeout commands\n" "Time between restarts\n" "Seconds\n")
{
struct msc_connection *msc = vty->index;
@@ -1306,7 +1307,7 @@ DEFUN(cfg_app_hardcode_ass, cfg_app_hardcode_ass_cmd,
DEFUN(cfg_app_no_hardcode_ass, cfg_app_no_hardcode_ass_cmd,
"no hardcode-assignment-complete",
- "Hardcode the assignment complete message to HR3\n")
+ NO_STR "Hardcode the assignment complete message to HR3\n")
{
struct ss7_application *app = vty->index;
app->fixed_ass_cmpl_reply = 0;
diff --git a/src/vty_interface_cmds.c b/src/vty_interface_cmds.c
index 78e67c0..7c634c0 100644
--- a/src/vty_interface_cmds.c
+++ b/src/vty_interface_cmds.c
@@ -280,7 +280,7 @@ DEFUN(allow_inject, allow_inject_cmd,
DEFUN(show_sctp_count, show_sctp_count_cmd,
"show sctp-connections count",
- SHOW_STR "Number of SCTP connections\n")
+ SHOW_STR "SCTP connections\n" "Number of connections\n")
{
int count = sctp_m2ua_conn_count(bsc->m2ua_trans);
vty_out(vty, "Active SCTP connections are: %d.%s", count, VTY_NEWLINE);
@@ -289,7 +289,7 @@ DEFUN(show_sctp_count, show_sctp_count_cmd,
DEFUN(show_sctp_details, show_sctp_details_cmd,
"show sctp-connections details",
- SHOW_STR "Details of SCTP connections\n")
+ SHOW_STR "SCTP connections\n" "Details\n")
{
struct sctp_m2ua_conn *conn;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5c9cdd5..6276980 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -20,9 +20,19 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac
EXTRA_DIST = testsuite.at $(srcdir)/package.m4 $(TESTSUITE)
TESTSUITE = $(srcdir)/testsuite
+
+if ENABLE_EXT_TESTS
+python-tests: $(BUILT_SOURCES)
+ osmotestvty.py -p $(abs_top_srcdir) -w $(abs_top_builddir) -v
+ osmotestconfig.py -p $(abs_top_srcdir) -w $(abs_top_builddir) -v
+else
+python-tests: $(BUILT_SOURCES)
+ echo "Not running python-based tests (determined at configure-time)"
+endif
check-local: atconfig $(TESTSUITE)
$(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS)
+ $(MAKE) $(AM_MAKEFLAGS) python-tests
installcheck-local: atconfig $(TESTSUITE)
$(SHELL) '$(TESTSUITE)' AUTOTEST_PATH='$(bindir)' \