[Openvpn-devel] t_client: Allow to force FAIL on prerequisite fails

Message ID 20220722134902.22092-1-frank@lichtenheld.com
State Accepted
Headers show
Series [Openvpn-devel] t_client: Allow to force FAIL on prerequisite fails | expand

Commit Message

Frank Lichtenheld July 22, 2022, 3:49 a.m. UTC
In automated tests we want the build to fail if the
worker node is configured incorrectly.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
---
 tests/t_client.sh.in | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

Comments

Gert Doering July 22, 2022, 5:09 a.m. UTC | #1
Acked-by: Gert Doering <gert@greenie.muc.de>

"makes sense" - in a buildbot (or any other CI) environment, do not 
silently skip missing prereqs, but fail hard.

Tested with "make check" ;-) - with and without TCLIENT_SKIP_RC=1
and RUN_SUDO=doas / RUN_SUDO=false, etc.

Your patch has been applied to the master branch.

commit 79932b94513303567fdd5d1c4e0abb79e6642b6e
Author: Frank Lichtenheld
Date:   Fri Jul 22 15:49:02 2022 +0200

     t_client: Allow to force FAIL on prerequisite fails

     Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     Message-Id: <20220722134902.22092-1-frank@lichtenheld.com>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24723.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering
Gert Doering Aug. 25, 2022, 10:33 a.m. UTC | #2
Hi,

On Fri, Jul 22, 2022 at 05:09:08PM +0200, Gert Doering wrote:
> Acked-by: Gert Doering <gert@greenie.muc.de>
> 
> "makes sense" - in a buildbot (or any other CI) environment, do not 
> silently skip missing prereqs, but fail hard.
> 
> Tested with "make check" ;-) - with and without TCLIENT_SKIP_RC=1
> and RUN_SUDO=doas / RUN_SUDO=false, etc.
> 
> Your patch has been applied to the master branch.
> 
> commit 79932b94513303567fdd5d1c4e0abb79e6642b6e
> Author: Frank Lichtenheld
> Date:   Fri Jul 22 15:49:02 2022 +0200
> 
>      t_client: Allow to force FAIL on prerequisite fails

Because it makes sense, applied to release/2.5 as well now...

commit 26b04fce5a17f8a8670c005d66e9260dbdc88cfe
Author: Frank Lichtenheld <frank@lichtenheld.com>
Date:   Fri Jul 22 15:49:02 2022 +0200

    t_client: Allow to force FAIL on prerequisite fails
    
    (cherry picked from commit 79932b94513303567fdd5d1c4e0abb79e6642b6e)

Patch

diff --git a/tests/t_client.sh.in b/tests/t_client.sh.in
index 294546be..465c3a33 100755
--- a/tests/t_client.sh.in
+++ b/tests/t_client.sh.in
@@ -12,6 +12,10 @@ 
 # - for "ping6" checks: fping6 binary in $PATH
 #
 
+# by changing this to 1 we can force automated builds to fail
+# that are expected to have all the prerequisites
+TCLIENT_SKIP_RC="${TCLIENT_SKIP_RC:-77}"
+
 srcdir="${srcdir:-.}"
 top_builddir="${top_builddir:-..}"
 if [ -r "${top_builddir}"/t_client.rc ] ; then
@@ -21,25 +25,25 @@  elif [ -r "${srcdir}"/t_client.rc ] ; then
 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
+    exit "${TCLIENT_SKIP_RC}"
 fi
 
 # Check for external dependencies
 which fping > /dev/null
 if [ $? -ne 0 ]; then
     echo "$0: fping is not available in \$PATH" >&2
-    exit 77
+    exit "${TCLIENT_SKIP_RC}"
 fi
 which fping6 > /dev/null
 if [ $? -ne 0 ]; then
     echo "$0: fping6 is not available in \$PATH" >&2
-    exit 77
+    exit "${TCLIENT_SKIP_RC}"
 fi
 
 KILL_EXEC=`which kill`
 if [ $? -ne 0 ]; then
     echo "$0: kill not found in \$PATH" >&2
-    exit 77
+    exit "${TCLIENT_SKIP_RC}"
 fi
 
 if [ ! -x "${top_builddir}/src/openvpn/openvpn" ]
@@ -56,12 +60,12 @@  fi
 
 if [ -z "$CA_CERT" ] ; then
     echo "CA_CERT not defined in 't_client.rc'. SKIP test." >&2
-    exit 77
+    exit "${TCLIENT_SKIP_RC}"
 fi
 
 if [ -z "$TEST_RUN_LIST" ] ; then
     echo "TEST_RUN_LIST empty, no tests defined.  SKIP test." >&2
-    exit 77
+    exit "${TCLIENT_SKIP_RC}"
 fi
 
 # Ensure PREFER_KSU is in a known state
@@ -91,7 +95,7 @@  else
     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
+        exit "${TCLIENT_SKIP_RC}"
     else
         # We have to use sudo. Make sure that we (hopefully) do not have
         # to ask the users password during the test. This is done to
@@ -101,7 +105,7 @@  else
 	    echo "$0: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
 	else
 	    echo "$0: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
-	    exit 77
+	    exit "${TCLIENT_SKIP_RC}"
 	fi
     fi
 fi