[S] Change in openvpn[master]: t_client.sh.in: Add utility function needs_openvpn()

"flichtenheld \(Code Review\) via Openvpn-devel" <[email protected]>
Newsgroups gmane.network.openvpn.devel
Message-ID <[email protected]>
Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1763?usp=email

to review the following change.


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

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

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 <[email protected]>
---
M tests/t_client.sh.in
1 file changed, 21 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/63/1763/1

diff --git a/tests/t_client.sh.in b/tests/t_client.sh.in
index 2459c08..78c8bca 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
@@ -65,6 +67,17 @@
     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}"

-- 
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1763?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I1905d9494336da4e91f1946d2ffd875720605b41
Gerrit-Change-Number: 1763
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.