diff --git a/ctdb/tests/eventscripts/scripts/local.sh b/ctdb/tests/eventscripts/scripts/local.sh index 6d7de894651..4c2d8fe6dd2 100644 --- a/ctdb/tests/eventscripts/scripts/local.sh +++ b/ctdb/tests/eventscripts/scripts/local.sh @@ -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" } diff --git a/ctdb/tests/onnode/README b/ctdb/tests/onnode/README index 162faae0211..5bb69524df2 100644 --- a/ctdb/tests/onnode/README +++ b/ctdb/tests/onnode/README @@ -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... diff --git a/ctdb/tests/onnode/scripts/local.sh b/ctdb/tests/onnode/scripts/local.sh index d6dd41c293a..35fd013540f 100644 --- a/ctdb/tests/onnode/scripts/local.sh +++ b/ctdb/tests/onnode/scripts/local.sh @@ -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 ) diff --git a/ctdb/tests/scripts/run_tests b/ctdb/tests/scripts/run_tests index 7a86301c951..d4eab4d847e 100755 --- a/ctdb/tests/scripts/run_tests +++ b/ctdb/tests/scripts/run_tests @@ -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 ;;