rtla/tests: Debugging improvements
Subsystems (2)
cover rtla/tests: Debugging improvements
Make life easier when debugging failing tests.
Crystal Wood (3):
rtla/tests: Use absolute path for $RTLA rtla/tests: Show the command line for failing tests rtla/tests: Add $SUBTESTS and $STOPONFAIL
tools/tracing/rtla/tests/engine.sh | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
Signature · 1 line
2.54.0
PATCH 1/3 rtla/tests: Use absolute path for $RTLA
When running the tests directly instead of from the makefile, RTLA is likely to be unset. The default "./rtla" no longer works, due to having changed the current diretory.
--- tools/tracing/rtla/tests/engine.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/tracing/rtla/tests/engine.sh +1 -1
@@ -7,7 +7,7 @@ test_begin() { # Set test directory to the directory of the script scriptfile=$(realpath "$0") testdir=$(dirname "$scriptfile") - [ -z "$RTLA" ] && RTLA="./rtla" + [ -z "$RTLA" ] && RTLA="$(pwd)/rtla" [ -n "$TEST_COUNT" ] && echo "1..$TEST_COUNT" }
Signature · 1 line
2.54.0
PATCH 2/3 rtla/tests: Show the command line for failing tests
In reply to Crystal WoodMake investigating test failures a little bit easier by not having to recreate the command line by looking in the test script.
Unfortunately, this doesn't capture variables set outside of the command line, but it's better than nothing.
--- tools/tracing/rtla/tests/engine.sh | 1 + 1 file changed, 1 insertion(+)
tools/tracing/rtla/tests/engine.sh +1 -0
@@ -86,6 +86,7 @@ check() { else # Add rtla output and exit code as comments in case of failure echo "not ok $ctr - $1" + echo "# command: $RTLA" $2 echo -n "$failbuf" echo "$result" | col -b | while read line; do echo "# $line"; done printf "#\n# exit code %s\n" $exitcode
Signature · 1 line
2.54.0
PATCH 3/3 rtla/tests: Add $SUBTESTS and $STOPONFAIL
In reply to Crystal WoodGive the user more control over the test execution when the test scripts are run directly (not through prove), in order to do things like run a particular test repeatedly to diagnose an intermittent failure.
If $SUBTESTS is provided, then only tests whose number is on the list will run. For example:
# SUBTESTS="14 133 4 $(seq 98 103) 9" bash ./tests/timerlat.t 1..150
ok 4 - top verify -s/--stack
ok 9 - hist set the automatic trace mode
ok 14 - top disable auto-analysis
ok 98 - hist verify -H/--house-keeping
ok 99 - top verify -k/--kernel-threads
ok 100 - hist verify -k/--kernel-threads
ok 101 - top verify -u/--user-threads
ok 102 - hist verify -u/--user-threads
ok 103 - apply default timerlat_period_us
ok 133 - top trace output through --on-threshold trace
If $STOPONFAIL is set, then the script will exit with a non-zero exit code on the first failure. If the output directory is non-empty, it will be preserved, and the location shown.
--- tools/tracing/rtla/tests/engine.sh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
tools/tracing/rtla/tests/engine.sh +17 -3
@@ -9,6 +9,12 @@ test_begin() { testdir=$(dirname "$scriptfile") [ -z "$RTLA" ] && RTLA="$(pwd)/rtla" [ -n "$TEST_COUNT" ] && echo "1..$TEST_COUNT" + + # Convert newlines to spaces so that seq can be used + unset subtests + if [ -n "$SUBTESTS" ]; then + subtests=$(echo "$SUBTESTS"|tr '\n' ' ') + fi } reset_osnoise() {
@@ -50,8 +56,7 @@ check() { # Simple check: run rtla with given arguments and test exit code. # If TEST_COUNT is set, run the test. Otherwise, just count. ctr=$(($ctr + 1)) - if [ -n "$TEST_COUNT" ] - then + if [[ -n "$TEST_COUNT" && ( -z "$subtests" || " $subtests " == *" $ctr "* ) ]]; then # Reset osnoise options before running test. [ "$NO_RESET_OSNOISE" == 1 ] || reset_osnoise
@@ -62,6 +67,7 @@ check() { # Run rtla; in case of failure, include its output as comment # in the test results. result=$(eval stdbuf -oL $TIMEOUT "$RTLA" $2 2>&1); exitcode=$? + popd >/dev/null failbuf='' fail=0
@@ -90,10 +96,18 @@ check() { echo -n "$failbuf" echo "$result" | col -b | while read line; do echo "# $line"; done printf "#\n# exit code %s\n" $exitcode + + if [ -n "$STOPONFAIL" ]; then + # If the directory is not empty, tell the user where + # to find the output + if ! rmdir $tmpdir; then + echo "# output dir: $tmpdir" + fi + exit 1 + fi fi # Remove temporary directory - popd >/dev/null rm -r $tmpdir fi }
Signature · 1 line
2.54.0