From 4c9041b9d34bc20b716838e3cb3c5642677abbc9 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 14 May 2017 22:59:33 +0200 Subject: stp: Add test scripts for executing m3ua-testtool and sua-testtool You will need to have * GNU/Linux with support for [network] namespaces * the 'unshare' command line tool * m3ua-testtool and sua-testtool repositories from git.osmocom.org/nplab installed adjacent to libosmo-sccp * their requirements, i.e. ** guile ** guile-sctp from https://github.com/nplab/guile-sctp When those are installed, you can do things like (cd contrib/test && ./run-in-ns.sh test-m3ua.sh) (cd contrib/test && ./run-in-ns.sh test-sua.sh) to execute the test suite. Change-Id: Ic36eafbb9868b2ec9ae2173f8d1b651b976ccf88 --- contrib/test/osmo-stp.cfg | 48 +++++++++++++++++++++++++++++++++++++++++++++++ contrib/test/run-in-ns.sh | 13 +++++++++++++ contrib/test/test-m3ua.sh | 31 ++++++++++++++++++++++++++++++ contrib/test/test-sua.sh | 31 ++++++++++++++++++++++++++++++ 4 files changed, 123 insertions(+) create mode 100644 contrib/test/osmo-stp.cfg create mode 100755 contrib/test/run-in-ns.sh create mode 100755 contrib/test/test-m3ua.sh create mode 100755 contrib/test/test-sua.sh diff --git a/contrib/test/osmo-stp.cfg b/contrib/test/osmo-stp.cfg new file mode 100644 index 0000000..bf059a9 --- /dev/null +++ b/contrib/test/osmo-stp.cfg @@ -0,0 +1,48 @@ +! +! osmo-stp (0.0.6.3.179-b248) configuration saved from vty +!! +! +log stderr + logging filter all 1 + logging color 1 + logging print category 1 + logging timestamp 0 + logging level all everything + logging level lglobal notice + logging level llapd notice + logging level linp info + logging level lmux notice + logging level lmi notice + logging level lmib notice + logging level lsms notice + logging level lctrl notice + logging level lgtp notice + logging level lstats notice + logging level lgsup notice + logging level loap notice + logging level lss7 debug + logging level lsccp debug + logging level lsua debug + logging level lm3ua debug +! +line vty + no login +! +cs7 instance 0 + asp asp0 0 2905 m3ua + remote-ip 172.18.0.2 + asp asp-s-0 0 14001 sua + remote-ip 172.18.0.3 + as as0 m3ua + asp asp0 + routing-key 23 0.2.7 + as as-s-0 sua + asp asp-s-0 + routing-key 24 0.3.0 + route-table system + update route 0.2.7 0.2.7 linkset as0 + update route 0.3.0 0.3.0 linkset as-s-0 + listen m3ua 2905 + local-ip 172.18.0.200 + listen sua 14001 + local-ip 172.18.0.200 diff --git a/contrib/test/run-in-ns.sh b/contrib/test/run-in-ns.sh new file mode 100755 index 0000000..a961f78 --- /dev/null +++ b/contrib/test/run-in-ns.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# small helper script to run the specified command inside a network +# namespace while remapping the real PID to root inside the namespace, +# so the program inside the namespace can do things like setting +# interface addresses + +if [ $# -eq 0 ]; then + echo "You have to specify the command you want to execute in the new namespace" + exit 1 +fi + +unshare --map-root-user --user -i -m -p -f -u -U -n $1 diff --git a/contrib/test/test-m3ua.sh b/contrib/test/test-m3ua.sh new file mode 100755 index 0000000..0f81fe8 --- /dev/null +++ b/contrib/test/test-m3ua.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +# this script executes m3ua-testtool against osmo-stp. It assumes that +# it is called from within libosmo-sccp/contrib/test and also assumes +# that adjacent to the libosmo-sccp, there's a check-out of +# git://git.osmocom.org/nplab/m3ua-testtool + +# the top of the libosmo-sccp git repository +TOPDIR=../../ + +# the directory in which we can find the osmo-stp binary +STP_DIR=$TOPDIR/stp + +# the directory in which we can find the m3ua-testtool.git +M3UA_DIR=$TOPDIR/../m3ua-testtool + +# osmo-stp config file, used from CWD +STP_CONFIG=./osmo-stp.cfg + +# we're pesudo-root but inherit the path from a non-root user +PATH=/sbin:/usr/sbin:$PATH + +# set up the ip addresses +ip link set lo up +ip addr add 172.18.0.2/32 dev lo +ip addr add 172.18.0.200/32 dev lo + +$STP_DIR/osmo-stp -c $STP_CONFIG & +STP_PID=$! +(cd $M3UA_DIR && ./run-all-sgp-tests) +kill $! diff --git a/contrib/test/test-sua.sh b/contrib/test/test-sua.sh new file mode 100755 index 0000000..0cb4e35 --- /dev/null +++ b/contrib/test/test-sua.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +# this script executes m3ua-testtool against osmo-stp. It assumes that +# it is called from within libosmo-sccp/contrib/test and also assumes +# that adjacent to the libosmo-sccp, there's a check-out of +# git://git.osmocom.org/nplab/m3ua-testtool + +# the top of the libosmo-sccp git repository +TOPDIR=../../ + +# the directory in which we can find the osmo-stp binary +STP_DIR=$TOPDIR/stp + +# the directory in which we can find the sua-testtool.git +SUA_DIR=$TOPDIR/../sua-testtool + +# osmo-stp config file, used from CWD +STP_CONFIG=./osmo-stp.cfg + +# we're pesudo-root but inherit the path from a non-root user +PATH=/sbin:/usr/sbin:$PATH + +# set up the ip addresses +ip link set lo up +ip addr add 172.18.0.3/32 dev lo +ip addr add 172.18.0.200/32 dev lo + +$STP_DIR/osmo-stp -c $STP_CONFIG & +STP_PID=$! +(cd $SUA_DIR && ./run-some-sua-sgp-tests) +kill $! -- cgit v1.2.3