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>
... | ... |
@@ -1226,11 +1226,14 @@ else |
1226 | 1226 |
enable_plugin_down_root="no" |
1227 | 1227 |
fi |
1228 | 1228 |
|
1229 |
+AM_CONDITIONAL([HAVE_SITNL], [false]) |
|
1230 |
+ |
|
1229 | 1231 |
if test "${enable_iproute2}" = "yes"; then |
1230 | 1232 |
test -z "${IPROUTE}" && AC_MSG_ERROR([ip utility is required but missing]) |
1231 | 1233 |
AC_DEFINE([ENABLE_IPROUTE], [1], [enable iproute2 support]) |
1232 | 1234 |
else if test "${have_sitnl}" = "yes"; then |
1233 | 1235 |
AC_DEFINE([ENABLE_SITNL], [1], [enable sitnl support]) |
1236 |
+ AM_CONDITIONAL([HAVE_SITNL], [true]) |
|
1234 | 1237 |
else if test "${WIN32}" != "yes" -a "${have_sitnl}" != "yes"; then |
1235 | 1238 |
test -z "${ROUTE}" && AC_MSG_ERROR([route utility is required but missing]) |
1236 | 1239 |
test -z "${IFCONFIG}" && AC_MSG_ERROR([ifconfig utility is required but missing]) |
... | ... |
@@ -14,9 +14,10 @@ MAINTAINERCLEANFILES = \ |
14 | 14 |
|
15 | 15 |
SUBDIRS = unit_tests |
16 | 16 |
|
17 |
-test_scripts = t_net.sh |
|
18 |
-test_scripts += t_client.sh |
|
19 |
-test_scripts += t_lpback.sh t_cltsrv.sh |
|
17 |
+test_scripts = t_client.sh t_lpback.sh t_cltsrv.sh |
|
18 |
+if HAVE_SITNL |
|
19 |
+test_scripts += t_net.sh |
|
20 |
+endif |
|
20 | 21 |
|
21 | 22 |
TESTS_ENVIRONMENT = top_srcdir="$(top_srcdir)" |
22 | 23 |
TESTS = $(test_scripts) |
... | ... |
@@ -1,4 +1,4 @@ |
1 |
-#!/bin/sh |
|
1 |
+#!/usr/bin/env bash |
|
2 | 2 |
|
3 | 3 |
IFACE="dummy0" |
4 | 4 |
UNIT_TEST="./unit_tests/openvpn/networking_testdriver" |
... | ... |
@@ -74,6 +74,7 @@ run_test() |
74 | 74 |
|
75 | 75 |
## execution starts here |
76 | 76 |
|
77 |
+# t_client.rc required only for RUN_SUDO definition |
|
77 | 78 |
if [ -r "${top_builddir}"/t_client.rc ]; then |
78 | 79 |
. "${top_builddir}"/t_client.rc |
79 | 80 |
elif [ -r "${srcdir}"/t_client.rc ]; then |