ctdb-tests: Switch TEST_VAR_DIR to a local script variable
authorMartin Schwenke <martin@meltin.net>
Mon, 9 Sep 2019 07:59:15 +0000 (17:59 +1000)
committerAmitay Isaacs <amitay@samba.org>
Tue, 24 Sep 2019 03:46:59 +0000 (03:46 +0000)
This is now local to run_tests.sh.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Tue Sep 24 03:46:59 UTC 2019 on sn-devel-184

ctdb/tests/README
ctdb/tests/run_tests.sh

index bbda3313850ed41dff2bbb4abdcb6b01b85af406..1ab96a89b41ea931cd649050eb871b0963097412 100644 (file)
@@ -62,7 +62,7 @@ Some of the more useful options include:
 
   -e  Exit on the first test failure
 
-  -C  Clean up - kill daemons and remove $TEST_VAR_DIR when done
+  -C  Clean up when done by removing test state directory
 
       Tests uses a temporary/var directory for test state.  By default,
       this directory is not removed when tests are complete, so you
@@ -70,9 +70,7 @@ Some of the more useful options include:
       have failed against the same directory (with the same local
       daemons setup).  So this option cleans things up.
 
-      Also kills local daemons associated with directory.
-
-  -V  Use <dir> as $TEST_VAR_DIR
+  -V  Use <dir> as test state directory
 
       Use the specified temporary temporary/var directory.
 
index 367f9388c41bd709306b78d53f6905eb753706fd..48a272664c0a1f54480b75e3f7fc4615c470f0fa 100755 (executable)
@@ -7,7 +7,7 @@ Usage: $0 [OPTIONS] [TESTS]
 Options:
   -A           Use "cat -A" to print test output (only some tests)
   -c           Run integration tests on a cluster
-  -C           Remove TEST_VAR_DIR when done
+  -C           Clean up when done by removing test state directory (see -V)
   -D           Show diff between failed/expected test output (some tests only)
   -e           Exit on the first test failure
   -H           No headers - for running single test with other wrapper
@@ -16,7 +16,7 @@ Options:
   -q           Quiet - don't show tests being run (still displays summary)
   -S <lib>      Use socket wrapper library <lib> for local integration tests
   -v           Verbose - print test output for non-failures (only some tests)
-  -V <dir>     Use <dir> as TEST_VAR_DIR
+  -V <dir>     Use <dir> as test state directory
   -x           Trace this script with the -x option
   -X           Trace certain scripts run by tests using -x (only some tests)
 EOF
@@ -36,6 +36,7 @@ quiet=false
 exit_on_fail=false
 max_iterations=1
 no_header=false
+test_state_dir=""
 
 export TEST_VERBOSE=false
 export TEST_COMMAND_TRACE=false
@@ -43,7 +44,6 @@ export TEST_CAT_RESULTS_OPTS=""
 export TEST_DIFF_RESULTS=false
 export TEST_LOCAL_DAEMONS
 [ -n "$TEST_LOCAL_DAEMONS" ] || TEST_LOCAL_DAEMONS=3
-export TEST_VAR_DIR=""
 export TEST_CLEANUP=false
 export TEST_TIMEOUT=3600
 export TEST_SOCKET_WRAPPER_SO_PATH=""
@@ -62,7 +62,7 @@ while getopts "AcCDehHI:NqS:T:vV:xX?" opt ; do
        S) TEST_SOCKET_WRAPPER_SO_PATH="$OPTARG" ;;
        T) TEST_TIMEOUT="$OPTARG" ;;
        v) TEST_VERBOSE=true ;;
-       V) TEST_VAR_DIR="$OPTARG" ;;
+       V) test_state_dir="$OPTARG" ;;
        x) set -x ;;
        X) TEST_COMMAND_TRACE=true ;;
        \?|h) usage ;;
@@ -198,7 +198,7 @@ run_one_test ()
     test_suite_dir=$(cd "$CTDB_TEST_SUITE_DIR" && pwd)
     reldir="${test_suite_dir#${test_dir}/}"
 
-    export CTDB_TEST_TMP_DIR="${TEST_VAR_DIR}/${reldir}"
+    export CTDB_TEST_TMP_DIR="${test_state_dir}/${reldir}"
     rm -rf "$CTDB_TEST_TMP_DIR"
     mkdir -p "$CTDB_TEST_TMP_DIR"
 
@@ -288,16 +288,16 @@ CTDB_TESTS_ARE_INSTALLED=false
 CTDB_TEST_DIR=$(dirname "$0")
 export CTDB_TESTS_ARE_INSTALLED CTDB_TEST_DIR
 
-if [ -z "$TEST_VAR_DIR" ] ; then
+if [ -z "$test_state_dir" ] ; then
     if $CTDB_TESTS_ARE_INSTALLED ; then
-       TEST_VAR_DIR=$(mktemp -d)
+       test_state_dir=$(mktemp -d)
     else
-       TEST_VAR_DIR="${CTDB_TEST_DIR}/var"
+       test_state_dir="${CTDB_TEST_DIR}/var"
     fi
 fi
-mkdir -p "$TEST_VAR_DIR"
+mkdir -p "$test_state_dir"
 
-summary_file="${TEST_VAR_DIR}/.summary"
+summary_file="${test_state_dir}/.summary"
 : >"$summary_file"
 
 export TEST_SCRIPTS_DIR="${CTDB_TEST_DIR}/scripts"
@@ -325,10 +325,10 @@ fi
 do_cleanup ()
 {
     if $TEST_CLEANUP ; then
-       echo "Removing TEST_VAR_DIR=$TEST_VAR_DIR"
-       rm -rf "$TEST_VAR_DIR"
+       echo "Removing test state directory: ${test_state_dir}"
+       rm -rf "$test_state_dir"
     else
-       echo "Not cleaning up TEST_VAR_DIR=$TEST_VAR_DIR"
+       echo "Not cleaning up test state directory: ${test_state_dir}"
     fi
 }