summaryrefslogtreecommitdiff
path: root/debian/tests
diff options
context:
space:
mode:
authorChristian Ehrhardt <christian.ehrhardt@canonical.com>2016-11-03 15:03:59 +0100
committerYves-Alexis Perez <corsac@corsac.net>2016-12-21 11:43:17 +0100
commit58adc44ebf6bd30dabd5f61299be79e4270d3b1a (patch)
tree0e2cf02db9fb8735d253c33f9cb6209047e2706b /debian/tests
parent702c958006aca6bf34881cdcb1ece02d86278177 (diff)
downloadvyos-strongswan-58adc44ebf6bd30dabd5f61299be79e4270d3b1a.tar.gz
vyos-strongswan-58adc44ebf6bd30dabd5f61299be79e4270d3b1a.zip
* Add basic DEP8 tests
- d/tests/* add DEP8 tests - d/control enable autotestpkg Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Diffstat (limited to 'debian/tests')
-rwxr-xr-xdebian/tests/admin-strongswan-charon17
-rwxr-xr-xdebian/tests/admin-strongswan-starter21
-rw-r--r--debian/tests/control3
-rwxr-xr-xdebian/tests/daemon14
-rw-r--r--debian/tests/plugins28
5 files changed, 83 insertions, 0 deletions
diff --git a/debian/tests/admin-strongswan-charon b/debian/tests/admin-strongswan-charon
new file mode 100755
index 000000000..e9b57bd57
--- /dev/null
+++ b/debian/tests/admin-strongswan-charon
@@ -0,0 +1,17 @@
+#!/bin/sh
+#--------------------------
+# Testing strongswan-charon
+#--------------------------
+CMDS="
+/usr/lib/ipsec/charon
+"
+
+for cmd in $CMDS; do
+ $cmd --help > /dev/null 2>&1
+ RET=$?
+
+ if [ $RET -ne 0 ]; then
+ echo "ERROR, failed to run ${cmd}" >&2
+ exit $RET
+ fi
+done
diff --git a/debian/tests/admin-strongswan-starter b/debian/tests/admin-strongswan-starter
new file mode 100755
index 000000000..7b32e00fd
--- /dev/null
+++ b/debian/tests/admin-strongswan-starter
@@ -0,0 +1,21 @@
+#!/bin/sh
+#---------------------------
+# Testing strongswan-starter
+#---------------------------
+CMDS="
+/usr/bin/pki
+/usr/lib/ipsec/_copyright
+/usr/lib/ipsec/scepclient
+/usr/lib/ipsec/stroke
+/usr/sbin/ipsec
+"
+
+for cmd in $CMDS; do
+ $cmd --help > /dev/null 2>&1
+ RET=$?
+
+ if [ $RET -ne 0 ]; then
+ echo "ERROR, failed to run ${cmd}" >&2
+ exit $RET
+ fi
+done
diff --git a/debian/tests/control b/debian/tests/control
new file mode 100644
index 000000000..eb9e20463
--- /dev/null
+++ b/debian/tests/control
@@ -0,0 +1,3 @@
+Tests: daemon admin-strongswan-charon admin-strongswan-starter plugins
+Depends: strongswan, libstrongswan-standard-plugins, libstrongswan-extra-plugins, libcharon-extra-plugins, strongswan-pki, strongswan-scepclient
+Restrictions: needs-root isolation-container allow-stderr
diff --git a/debian/tests/daemon b/debian/tests/daemon
new file mode 100755
index 000000000..2a8b5e688
--- /dev/null
+++ b/debian/tests/daemon
@@ -0,0 +1,14 @@
+#!/bin/sh
+#------------------------
+# Testing starter, charon
+#------------------------
+DAEMONS="starter charon"
+
+for daemon in $DAEMONS; do
+ if pidof -x $daemon > /dev/null; then
+ echo "$daemon OK"
+ else
+ echo "ERROR: ${daemon} IS NOT RUNNING"
+ exit 1
+ fi
+done
diff --git a/debian/tests/plugins b/debian/tests/plugins
new file mode 100644
index 000000000..24825c83d
--- /dev/null
+++ b/debian/tests/plugins
@@ -0,0 +1,28 @@
+#!/bin/bash
+# find the set of plugins from default installed libraries
+# and compare that with what ipsec has loaded.
+
+# restart strongswan to get current list of loaded modules
+invoke-rc.d strongswan restart
+invoke-rc.d strongswan status
+
+STRONGSWAN_PKGS="$(dpkg --list | awk '/(strongswan|charon)/ {print $2}')"
+PLUGIN_PATH="/usr/lib/ipsec/plugins/"
+EXPECTED_MODULES="charon"
+for pkg in $STRONGSWAN_PKGS; do
+ P=$(dpkg -L $pkg | grep "^${PLUGIN_PATH}" |
+ sed -e "s,${PLUGIN_PATH}libstrongswan-,,g" -e 's,.so$,,')
+ EXPECTED_MODULES="${EXPECTED_MODULES} ${P}"
+done
+# expected to not load; they require configuration
+# NB: keep leading/trailing space for regex generation
+NOLOAD=" attr-sql coupling eap-simaka-sql eap-sim-file kernel-libipsec load-tester medcli medsrv sql systime-fix "
+# rdrand is dynamically detected
+MAYBELOAD="rdrand "
+NOLOADR="(`echo "${NOLOAD}${MAYBELOAD}" | sed 's, ,$|^,g'`)"
+MAYBELOADR="(`echo " ${MAYBELOAD}" | sed 's, ,$|^,g'`)"
+EXPECTED=( `echo $EXPECTED_MODULES | fmt -w1 | egrep -v "$NOLOADR"` )
+LOADED=( `ipsec listplugins | grep :$ | grep -v "Plugin" | egrep -v "$MAYBELOADR" | sed 's,:,,g'` )
+
+diff <(printf "%s\n" "${EXPECTED[@]}"|sort) <(printf "%s\n" "${LOADED[@]}"|sort)
+exit $?