tests: Make run_tests -X more flexible - it now works with onnode
authorMartin Schwenke <martin@meltin.net>
Fri, 20 Apr 2012 06:43:17 +0000 (16:43 +1000)
committerMartin Schwenke <martin@meltin.net>
Fri, 27 Apr 2012 05:40:43 +0000 (15:40 +1000)
Hardcoding "sh -x" is suboptimal because some scripts, like onnode,
require bash.

Signed-off-by: Martin Schwenke <martin@meltin.net>
tests/eventscripts/scripts/local.sh
tests/onnode/README
tests/onnode/scripts/local.sh
tests/scripts/run_tests

index 6d7de894651515e3eb8516af795ecd19d469be14..4c2d8fe6dd2c1ba33bcc96e96c42d7d94f29133a 100644 (file)
@@ -698,7 +698,11 @@ simple_test ()
     _extra_header=$(_extra_header)
 
     echo "Running eventscript \"$script $event${1:+ }$*\""
-    _out=$($TEST_COMMAND_TRACE "${CTDB_BASE}/events.d/$script" "$event" "$@" 2>&1)
+    _trace=""
+    if $TEST_COMMAND_TRACE ; then
+       _trace="sh -x"
+    fi
+    _out=$($_trace "${CTDB_BASE}/events.d/$script" "$event" "$@" 2>&1)
 
     result_check "$_extra_header"
 }
index 162faae02110a74e5c145d89dfccb16353aa66cb..5bb69524df205dc7c0728be0dbc004cc687f6431 100644 (file)
@@ -26,13 +26,11 @@ Examples:
 
   Run only the specified tests.
 
-* ONNODE="bash -x stubs/onnode-buggy-001" ../run_tests.sh ./0090.sh
-  ONNODE="bash -x ../../tools/onnode" ../run_tests.sh ./0090.sh
+* ONNODE="stubs/onnode-buggy-001" ../run_tests.sh -X ./0090.sh
+  ../run_tests.sh -X ./0090.sh
 
-  Debug the specified test or test failure.  The test will fail
-  because the bash trace output will be included in the test output.
-  However, this at least makes it easy to trace onnode while running
-  the test...
+  Debug the specified test or test failure by tracing onnode with
+  "bash -x".  The test will fail because the bash trace output will be
+  included in the test output.
 
-  To see if the test pases, the -x can be dropped... so command-line
-  editing can be kept to a minimum.
+  To see if the test pases, the -X can be dropped...
index d6dd41c293a7df3fffc1748ce5829e1fe5be0130..35fd013540f3ed1321aa91877f982b29c0fdd9e7 100644 (file)
@@ -67,7 +67,12 @@ simple_test ()
        _sort="sort"
     fi
 
-    _out=$("$@" 2>&1)
+    if $TEST_COMMAND_TRACE ; then
+       _onnode=$(which "$1") ; shift
+       _out=$(bash -x "$_onnode" "$@" 2>&1)
+    else
+       _out=$("$@" 2>&1)
+    fi
     _rc=$?
     _out=$(echo "$_out" | $_sort )
 
index 7a86301c9515168c60964af3e2d439b7144d1e1a..d4eab4d847e916e7425c86db786826d261019f7e 100755 (executable)
@@ -35,7 +35,7 @@ exit_on_fail=false
 no_header=false
 
 export TEST_VERBOSE=false
-export TEST_COMMAND_TRACE=""
+export TEST_COMMAND_TRACE=false
 export TEST_CAT_RESULTS_OPTS=""
 export TEST_DIFF_RESULTS=false
 export TEST_LOCAL_DAEMONS  # No default, developer can "override"!
@@ -55,7 +55,7 @@ while true ; do
        -q) quiet=true ; shift ;;
        -s) with_summary=true ; shift ;;
        -v) TEST_VERBOSE=true ; shift ;;
-       -X) TEST_COMMAND_TRACE="sh -x" ; shift ;;
+       -X) TEST_COMMAND_TRACE=true ; shift ;;
        -A) TEST_CAT_RESULTS_OPTS="-A" ; shift ;;
        -D) TEST_DIFF_RESULTS=true ; shift ;;
        -H) no_header=true ; shift ;;