]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
t_net.sh: make bash dep explicit and run only if SITNL is compiled
authorAntonio Quartulli <antonio@openvpn.net>
Sat, 15 Jun 2019 23:02:12 +0000 (01:02 +0200)
committerGert Doering <gert@greenie.muc.de>
Sun, 16 Jun 2019 08:16:49 +0000 (10:16 +0200)
The t_net script currently has #!/bin/sh but it implicitly assume to
be using bash.
This is fine on most distros, but some do not have sh pointing to bash
by default, thus breaking the script.
Explicitly use bash to avoid failures.

On the other hand, run this unit-test only if SITNL was enabled at
compile time. This test was designed with SITNL in mind and it is
not yet ready for other backends.

Running only when SITNL is enabled implies running on Linux only
therefore we are guaranteed that bash will always work.

While at it, also add a comment as of why the t_client.rc file is
sourced.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20190615230213.14888-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg18547.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
configure.ac
tests/Makefile.am
tests/t_net.sh
tests/unit_tests/openvpn/Makefile.am

index 2d78098e6bd1ce226f843b06bdcec9fbc83ea9ab..8c95e31093b3cd17096d098beee3c2bec443d01a 100644 (file)
@@ -1226,11 +1226,14 @@ else
        enable_plugin_down_root="no"
 fi
 
+AM_CONDITIONAL([HAVE_SITNL], [false])
+
 if test "${enable_iproute2}" = "yes"; then
        test -z "${IPROUTE}" && AC_MSG_ERROR([ip utility is required but missing])
        AC_DEFINE([ENABLE_IPROUTE], [1], [enable iproute2 support])
 else if test "${have_sitnl}" = "yes"; then
        AC_DEFINE([ENABLE_SITNL], [1], [enable sitnl support])
+       AM_CONDITIONAL([HAVE_SITNL], [true])
 else if test "${WIN32}" != "yes" -a "${have_sitnl}" != "yes"; then
        test -z "${ROUTE}" && AC_MSG_ERROR([route utility is required but missing])
        test -z "${IFCONFIG}" && AC_MSG_ERROR([ifconfig utility is required but missing])
index 67acf7e352072aaea313cb545c702af3677d14c7..801192ed0911bcb8bd575884bd13694cba1e2228 100644 (file)
@@ -14,9 +14,10 @@ MAINTAINERCLEANFILES = \
 
 SUBDIRS = unit_tests
 
-test_scripts = t_net.sh
-test_scripts += t_client.sh
-test_scripts += t_lpback.sh t_cltsrv.sh
+test_scripts = t_client.sh t_lpback.sh t_cltsrv.sh
+if HAVE_SITNL
+test_scripts += t_net.sh
+endif
 
 TESTS_ENVIRONMENT = top_srcdir="$(top_srcdir)"
 TESTS = $(test_scripts)
index 0be5bb42f42d54bd0bd78507c8f9c3559f0cff2b..1940ec92439eadf8d91ec31105f87a6beec1bfed 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env bash
 
 IFACE="dummy0"
 UNIT_TEST="./unit_tests/openvpn/networking_testdriver"
@@ -74,6 +74,7 @@ run_test()
 
 ## execution starts here
 
+# t_client.rc required only for RUN_SUDO definition
 if [ -r "${top_builddir}"/t_client.rc ]; then
     . "${top_builddir}"/t_client.rc
 elif [ -r "${srcdir}"/t_client.rc ]; then
index c6da91a826c69fff13457cee983cca967135a3dd..e61c57c42d46269de140ea8fd1506c6f0c014854 100644 (file)
@@ -14,7 +14,7 @@ endif
 TESTS = $(test_binaries)
 check_PROGRAMS = $(test_binaries)
 
-if TARGET_LINUX
+if HAVE_SITNL
 check_PROGRAMS += networking_testdriver
 endif