diff options
Diffstat (limited to 'tools/tracing/rtla/tests')
-rw-r--r-- | tools/tracing/rtla/tests/engine.sh | 26 | ||||
-rw-r--r-- | tools/tracing/rtla/tests/osnoise.t | 27 | ||||
-rw-r--r-- | tools/tracing/rtla/tests/timerlat.t | 4 |
3 files changed, 46 insertions, 11 deletions
diff --git a/tools/tracing/rtla/tests/engine.sh b/tools/tracing/rtla/tests/engine.sh index a97d644ead99..c7de3d6ed6a8 100644 --- a/tools/tracing/rtla/tests/engine.sh +++ b/tools/tracing/rtla/tests/engine.sh @@ -43,6 +43,7 @@ check() { tested_command=$1 expected_exitcode=${3:-0} expected_output=$4 + unexpected_output=$5 # 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)) @@ -53,24 +54,33 @@ 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=$? + failbuf='' + fail=0 + # Test if the results matches if requested - if [ -n "$expected_output" ] + if [ -n "$expected_output" ] && ! grep -qE "$expected_output" <<< "$result" then - grep -E "$expected_output" <<< "$result" > /dev/null; grep_result=$? - else - grep_result=0 + fail=1 + failbuf+=$(printf "# Output match failed: \"%s\"" "$expected_output") + failbuf+=$'\n' fi - if [ $exitcode -eq $expected_exitcode ] && [ $grep_result -eq 0 ] + if [ -n "$unexpected_output" ] && grep -qE "$unexpected_output" <<< "$result" + then + fail=1 + failbuf+=$(printf "# Output non-match failed: \"%s\"" "$unexpected_output") + failbuf+=$'\n' + fi + + if [ $exitcode -eq $expected_exitcode ] && [ $fail -eq 0 ] then echo "ok $ctr - $1" else - echo "not ok $ctr - $1" # Add rtla output and exit code as comments in case of failure + echo "not ok $ctr - $1" + echo -n "$failbuf" echo "$result" | col -b | while read line; do echo "# $line"; done printf "#\n# exit code %s\n" $exitcode - [ -n "$expected_output" ] && [ $grep_result -ne 0 ] && \ - printf "# Output match failed: \"%s\"\n" "$expected_output" fi fi } diff --git a/tools/tracing/rtla/tests/osnoise.t b/tools/tracing/rtla/tests/osnoise.t index 7574ec6a5a53..e3c89d45a6bb 100644 --- a/tools/tracing/rtla/tests/osnoise.t +++ b/tools/tracing/rtla/tests/osnoise.t @@ -8,7 +8,8 @@ set_timeout 2m check "verify help page" \ "osnoise --help" 0 "osnoise version" check "verify the --priority/-P param" \ - "osnoise top -P F:1 -c 0 -r 900000 -d 10s -q" + "osnoise top -P F:1 -c 0 -r 900000 -d 10s -q -S 1 --on-threshold shell,command=\"tests/scripts/check-priority.sh osnoise/ SCHED_FIFO 1\"" \ + 2 "Priorities are set correctly" check "verify the --stop/-s param" \ "osnoise top -s 30 -T 1" 2 "osnoise hit stop tracing" check "verify the --trace param" \ @@ -22,4 +23,28 @@ check "verify the --entries/-E param" \ check_with_osnoise_options "apply default period" \ "osnoise hist -s 1" 2 period_us=600000000 +# Actions tests +check "trace output through -t with custom filename" \ + "osnoise hist -S 2 -t custom_filename.txt" 2 "^ Saving trace to custom_filename.txt$" +check "trace output through --on-threshold trace" \ + "osnoise hist -S 2 --on-threshold trace" 2 "^ Saving trace to osnoise_trace.txt$" +check "trace output through --on-threshold trace with custom filename" \ + "osnoise hist -S 2 --on-threshold trace,file=custom_filename.txt" 2 "^ Saving trace to custom_filename.txt$" +check "exec command" \ + "osnoise hist -S 2 --on-threshold shell,command='echo TestOutput'" 2 "^TestOutput$" +check "multiple actions" \ + "osnoise hist -S 2 --on-threshold shell,command='echo -n 1' --on-threshold shell,command='echo 2'" 2 "^12$" +check "hist stop at failed action" \ + "osnoise hist -S 2 --on-threshold shell,command='echo -n 1; false' --on-threshold shell,command='echo -n 2'" 2 "^1# RTLA osnoise histogram$" +check "top stop at failed action" \ + "timerlat top -T 2 --on-threshold shell,command='echo -n abc; false' --on-threshold shell,command='echo -n defgh'" 2 "^abc" "defgh" +check "hist with continue" \ + "osnoise hist -S 2 -d 1s --on-threshold shell,command='echo TestOutput' --on-threshold continue" 0 "^TestOutput$" +check "top with continue" \ + "osnoise top -q -S 2 -d 1s --on-threshold shell,command='echo TestOutput' --on-threshold continue" 0 "^TestOutput$" +check "hist with trace output at end" \ + "osnoise hist -d 1s --on-end trace" 0 "^ Saving trace to osnoise_trace.txt$" +check "top with trace output at end" \ + "osnoise top -d 1s --on-end trace" 0 "^ Saving trace to osnoise_trace.txt$" + test_end diff --git a/tools/tracing/rtla/tests/timerlat.t b/tools/tracing/rtla/tests/timerlat.t index c71aed5534bf..b5d1e7260a9b 100644 --- a/tools/tracing/rtla/tests/timerlat.t +++ b/tools/tracing/rtla/tests/timerlat.t @@ -47,9 +47,9 @@ check "trace output through -t" \ "timerlat hist -T 2 -t" 2 "^ Saving trace to timerlat_trace.txt$" check "trace output through -t with custom filename" \ "timerlat hist -T 2 -t custom_filename.txt" 2 "^ Saving trace to custom_filename.txt$" -check "trace output through -A trace" \ +check "trace output through --on-threshold trace" \ "timerlat hist -T 2 --on-threshold trace" 2 "^ Saving trace to timerlat_trace.txt$" -check "trace output through -A trace with custom filename" \ +check "trace output through --on-threshold trace with custom filename" \ "timerlat hist -T 2 --on-threshold trace,file=custom_filename.txt" 2 "^ Saving trace to custom_filename.txt$" check "exec command" \ "timerlat hist -T 2 --on-threshold shell,command='echo TestOutput'" 2 "^TestOutput$" |