[Openvpn-devel,v7] t_client.sh.in: Add ability to filter by test group

Message ID 20260827170326.13161-1-gert@greenie.muc.de
State New
Headers
Series [Openvpn-devel,v7] t_client.sh.in: Add ability to filter by test group |

Commit Message

Gert Doering Aug. 27, 2026, 5:03 p.m. UTC
  From: Frank Lichtenheld <frank@lichtenheld.com>

Since we generally set this up in a way that one test
group corresponds to one server, it can be useful to
filter by the group. E.g. this allows one to potentially
parallelize test runs against different servers.

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

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/+/1777
This mail reflects revision 7 of this Change.

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

Patch

diff --git a/tests/t_client.rc-sample b/tests/t_client.rc-sample
index 4c87436..defa4aa 100644
--- a/tests/t_client.rc-sample
+++ b/tests/t_client.rc-sample
@@ -31,6 +31,21 @@ 
 #
 # tests to run (list suffixes for config stanzas below)
 #
+# The general idea is to use one number per server, so
+# e.g. use 1 for all tests talking to a UDP server, use
+# 2 for tests talking to a TCP server, and 3 for tests
+# talking to a P2P server.
+#
+# The indivdiual tests should then be indexed by using
+# letters.
+#
+# If you set TEST_RUN_GROUP=<number> then t_client.sh
+# will only run tests starting with that number. So
+# e.g. setting TEST_RUN_GROUP=1 will run 1 and 1a, but
+# not 2. This can be used to excercise only a specific
+# server, or to run tests against separate servers in
+# parallel.
+#
 TEST_RUN_LIST="1 2 2n"
 
 #
diff --git a/tests/t_client.sh.in b/tests/t_client.sh.in
index c3a9655..0568007 100755
--- a/tests/t_client.sh.in
+++ b/tests/t_client.sh.in
@@ -82,6 +82,21 @@ 
     exit "${TCLIENT_SKIP_RC}"
 fi
 
+if [ -n "$TEST_RUN_GROUP" ]; then
+    FILTERED_LIST=
+    for test in $TEST_RUN_LIST; do
+        group=$(echo $test | sed -E 's/^([0123456789]+).*/\1/')
+        if [ "$group" = "$TEST_RUN_GROUP" ]; then
+            FILTERED_LIST="$FILTERED_LIST $test"
+        fi
+    done
+    if [ -z "$FILTERED_LIST" ]; then
+        echo "Filtered TEST_RUN_LIST empty (group=$TEST_RUN_GROUP), no tests defined.  SKIP test." >&2
+        exit "${TCLIENT_SKIP_RC}"
+    fi
+    TEST_RUN_LIST=$FILTERED_LIST
+fi
+
 # Ensure PREFER_KSU is in a known state
 PREFER_KSU="${PREFER_KSU:-0}"
 
@@ -121,6 +136,9 @@ 
 fi
 
 LOGDIR=t_client-$(hostname)-$(date +%Y%m%d-%H%M%S)
+if [ -n "$TEST_RUN_GROUP" ]; then
+    LOGDIR="${LOGDIR}-${TEST_RUN_GROUP}"
+fi
 LOGDIR_ABS="$PWD/$LOGDIR"
 if mkdir $LOGDIR; then
     :