]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-tests: Enhance timeout stub
authorMartin Schwenke <mschwenke@ddn.com>
Fri, 17 Mar 2023 00:05:19 +0000 (11:05 +1100)
committerAmitay Isaacs <amitay@samba.org>
Thu, 9 Jul 2026 16:02:43 +0000 (16:02 +0000)
Allow it to trigger on a particular command instead of
unconditionally.  Wrap setting and clearing the variable.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/UNIT/eventscripts/50.samba.monitor.112.sh
ctdb/tests/UNIT/eventscripts/50.samba.monitor.113.sh
ctdb/tests/UNIT/eventscripts/scripts/local.sh
ctdb/tests/UNIT/eventscripts/stubs/timeout

index f71447206f262fb1e879e677ece8ecbc3a3211f1..0e240a376153169a6d571858ff4afc59006faa08 100755 (executable)
@@ -6,7 +6,7 @@ define_test "testparm times out"
 
 setup
 
-export FAKE_TIMEOUT="yes"
+timeout_trigger "yes"
 required_result 1 <<EOF
 ERROR: smb.conf cache create failed - testparm command timed out
 EOF
index faadda1a0b154b4f8e8eb388c170e3797c8cc255..c5f741932ffc07a246e525ea5c4384607e93db9e 100755 (executable)
@@ -9,7 +9,7 @@ setup
 ok_null
 simple_test
 
-export FAKE_TIMEOUT="yes"
+timeout_trigger "yes"
 ok <<EOF
 WARNING: smb.conf cache update timed out - using old cache file
 EOF
index 3f335ac1d16d924cef04f7e293e6dba85c65a3a2..e713d432c6027f488f062e7f53dc43b2e0d7f00a 100644 (file)
@@ -253,6 +253,17 @@ ipv4_host_addr_to_net()
        echo "${_net}/${_maskbits}"
 }
 
+# Cause the timeout stub to fail.
+timeout_trigger()
+{
+       export FAKE_TIMEOUT="$*"
+}
+
+timeout_clear()
+{
+       unset FAKE_TIMEOUT
+}
+
 ######################################################################
 
 # CTDB fakery
index 26132eebd7cd728ff1b7fa74fce28cbf301776a1..077c23ecd3c0d7ca159fc69fa352e11bb765c48d 100755 (executable)
@@ -1,8 +1,10 @@
 #!/bin/sh
 
-if [ -n "$FAKE_TIMEOUT" ]; then
+# Throw away the timeout argument
+shift
+
+if [ "$FAKE_TIMEOUT" = "yes" ] || [ "$FAKE_TIMEOUT" = "$*" ]; then
        exit 124
 else
-       shift 1
        exec "$@"
 fi