]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
t_net.sh: drop hard dependency on t_client.rc
authorAntonio Quartulli <a@unstable.cc>
Tue, 21 Jul 2020 19:55:18 +0000 (21:55 +0200)
committerGert Doering <gert@greenie.muc.de>
Wed, 22 Jul 2020 06:56:07 +0000 (08:56 +0200)
Right now t_net.sh depends on t_client.rc in order to source the
RUN_SUDO variable only.
However, t_client.rc is something that a few people only have configured
and thus this would result in t_net.sh almost never executed even if it
just could.

Drop dependency on t_client.rc by falling back to RUN_SUDO=sudo when the
file is missing and no RUN_SUDO is passed via env.

While at it, reword the error message to better match the current logic
flow.

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

index c67c3df2dbacee40eaf637a1acda43ec28e4a512..246ee07bd67249d0670940493824fe6c5297d975 100755 (executable)
@@ -76,10 +76,6 @@ if [ -r "${top_builddir}"/t_client.rc ]; then
     . "${top_builddir}"/t_client.rc
 elif [ -r "${srcdir}"/t_client.rc ]; then
     . "${srcdir}"/t_client.rc
-else
-    echo "$0: cannot find 't_client.rc' in build dir ('${top_builddir}')" >&2
-    echo "$0: or source directory ('${srcdir}'). SKIPPING TEST." >&2
-    exit 77
 fi
 
 if [ ! -x "$openvpn" ]; then
@@ -117,18 +113,18 @@ else
 
     if [ -z "$RUN_SUDO" ]
     then
-        echo "$0: this test must run be as root, or RUN_SUDO=... " >&2
-        echo "      must be set correctly in 't_client.rc'. SKIP." >&2
-        exit 77
+        echo "$0: no RUN_SUDO=... in t_client.rc or environment, defaulting to 'sudo'." >&2
+        echo "      if that does not work, set RUN_SUDO= correctly for your system." >&2
+        RUN_SUDO="sudo"
+    fi
+
+    # check that we can run the unit-test binary with sudo
+    if $RUN_SUDO $UNIT_TEST test
+    then
+        echo "$0: $RUN_SUDO $UNIT_TEST succeeded, good."
     else
-        # check that we can run the unit-test binary with sudo
-           if $RUN_SUDO $UNIT_TEST test
-        then
-               echo "$0: $RUN_SUDO $UNIT_TEST succeeded, good."
-        else
-               echo "$0: $RUN_SUDO $UNIT_TEST failed, cannot go on. SKIP." >&2
-               exit 77
-        fi
+        echo "$0: $RUN_SUDO $UNIT_TEST failed, cannot go on. SKIP." >&2
+        exit 77
     fi
 fi