[Openvpn-devel,v5] t_client.sh.in: Add utility function needs_openvpn()

Message ID 20260828095300.9652-1-gert@greenie.muc.de
State New
Headers
Series [Openvpn-devel,v5] t_client.sh.in: Add utility function needs_openvpn() |

Commit Message

Gert Doering Aug. 28, 2026, 9:52 a.m. UTC
  From: Frank Lichtenheld <frank@lichtenheld.com>

This allows to skip tests on old versions of openvpn.
Makes it much easier to maintain a t_client.rc across
multiple versions.

Change-Id: I1905d9494336da4e91f1946d2ffd875720605b41
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Razvan Cojocaru <razvanc@mailbox.org>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1763
---

This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1763
This mail reflects revision 5 of this Change.

Acked-by according to Gerrit (reflected above):
Razvan Cojocaru <razvanc@mailbox.org>
  

Comments

Gert Doering Aug. 30, 2026, 5:17 p.m. UTC | #1
This actually adds two things - "passing in $t_client_rc from the caller"
and "needs_openvpn()", but it fails to provide some sort of "okay, and
how do I use that now?" cheat sheet...  I guess something along the
lines of 
  CHECK_SKIP_$x="needs_openvpn 2.7"
or so?

Your patch has been applied to the master branch.

commit 8b392d642eb4c9b9135dc6a442d943159467e058
Author: Frank Lichtenheld
Date:   Fri Aug 28 11:52:52 2026 +0200

     t_client.sh.in: Add utility function needs_openvpn()

     Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
     Acked-by: Razvan Cojocaru <razvanc@mailbox.org>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1763
     Message-Id: <20260828095300.9652-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg38760.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering
  

Patch

diff --git a/tests/t_client.sh.in b/tests/t_client.sh.in
index 7c23020..c3a9655 100755
--- a/tests/t_client.sh.in
+++ b/tests/t_client.sh.in
@@ -22,14 +22,16 @@ 
 t_client_ips_rc="${t_client_ips_rc:-${top_builddir}/t_client_ips.rc}"
 update_t_client_ips="${update_t_client_ips:-${srcdir}/update_t_client_ips.sh}"
 
-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 "${TCLIENT_SKIP_RC}"
+if [ -z "${t_client_rc}" ]; then
+    if [ -r "${top_builddir}"/t_client.rc ]; then
+        t_client_rc="${top_builddir}"/t_client.rc
+    elif [ -r "${srcdir}"/t_client.rc ]; then
+        t_client_rc="${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 "${TCLIENT_SKIP_RC}"
+    fi
 fi
 
 # Check for external dependencies
@@ -63,6 +65,18 @@ 
     exit 1
 fi
 
+openvpn_version=$(${openvpn} --version | head -n 1 | cut -f2 -d" " | sed -E 's/^2\.([0123456789]+).*$/2\1/')
+
+needs_openvpn()
+{
+    needs_version=$1
+
+    [ "$openvpn_version" -ge "$needs_version" ]
+    return $?
+}
+
+. "${t_client_rc}"
+
 if [ -z "$TEST_RUN_LIST" ]; then
     echo "TEST_RUN_LIST empty, no tests defined.  SKIP test." >&2
     exit "${TCLIENT_SKIP_RC}"