diff --git a/tools/tracing/rtla/tests/engine.sh b/tools/tracing/rtla/tests/engine.sh index ed261e07c6d9..27d92f19a322 100644 --- a/tools/tracing/rtla/tests/engine.sh +++ b/tools/tracing/rtla/tests/engine.sh @@ -112,6 +112,21 @@ check_with_osnoise_options() { NO_RESET_OSNOISE=1 check "$arg1" "$arg2" "$arg3" } +check_top_hist() { + # Test one command with both "top" and "hist" tools, replacing "TOOL" in + # command with either "top" or "hist" respectively, and prefixing the test + # names with "top " and "hist ". + check "top $1" "$(echo "$2" | sed 's/TOOL/top/g')" "${@:3}" + check "hist $1" "$(echo "$2" | sed 's/TOOL/hist/g')" "${@:3}" +} + +check_top_q_hist() { + # Same as above, but pass "-q" to top so that strings printed in main + # loop are on their own line for top too, not only for hist. + check "top $1" "$(echo "$2" | sed 's/TOOL/top -q/g')" "${@:3}" + check "hist $1" "$(echo "$2" | sed 's/TOOL/hist/g')" "${@:3}" +} + set_timeout() { TIMEOUT="timeout -v -k 15s $1" } diff --git a/tools/tracing/rtla/tests/osnoise.t b/tools/tracing/rtla/tests/osnoise.t index 396334608920..ce3a448b1f87 100644 --- a/tools/tracing/rtla/tests/osnoise.t +++ b/tools/tracing/rtla/tests/osnoise.t @@ -7,13 +7,15 @@ 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 -S 1 --on-threshold shell,command=\"tests/scripts/check-priority.sh osnoise/ SCHED_FIFO 1\"" \ +check_top_hist "verify help page" \ + "osnoise TOOL --help" 0 "rtla osnoise" +check_top_q_hist "verify the --priority/-P param" \ + "osnoise TOOL -P F:1 -c 0 -r 900000 -d 10s -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" \ - "osnoise hist -s 30 -T 1 -t" 2 "Saving trace to osnoise_trace.txt" +check_top_q_hist "verify the --stop/-s param" \ + "osnoise TOOL -s 30 -T 1" 2 "osnoise hit stop tracing" +check_top_q_hist "verify the --trace param" \ + "osnoise TOOL -s 30 -T 1 -t" 2 "Saving trace to osnoise_trace.txt" check "verify the --entries/-E param" \ "osnoise hist -P F:1 -c 0 -r 900000 -d 10s -b 10 -E 25" @@ -24,27 +26,23 @@ 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_top_q_hist "trace output through -t with custom filename" \ + "osnoise TOOL -S 2 -t custom_filename.txt" 2 "^ Saving trace to custom_filename.txt$" +check_top_q_hist "trace output through --on-threshold trace" \ + "osnoise TOOL -S 2 --on-threshold trace" 2 "^ Saving trace to osnoise_trace.txt$" +check_top_q_hist "trace output through --on-threshold trace with custom filename" \ + "osnoise TOOL -S 2 --on-threshold trace,file=custom_filename.txt" 2 "^ Saving trace to custom_filename.txt$" +check_top_q_hist "exec command" \ + "osnoise TOOL -S 2 --on-threshold shell,command='echo TestOutput'" 2 "^TestOutput$" +check_top_q_hist "multiple actions" \ + "osnoise TOOL -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" \ "osnoise top -S 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 5s --on-threshold shell,command='echo TestOutput' --on-threshold continue" 0 "^TestOutput$" -check "top with continue" \ - "osnoise top -q -S 2 -d 5s --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$" +check_top_q_hist "with continue" \ + "osnoise TOOL -S 2 -d 5s --on-threshold shell,command='echo TestOutput' --on-threshold continue" 0 "^TestOutput$" +check_top_hist "with trace output at end" \ + "osnoise TOOL -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 fd4935fd7b49..d7944710a859 100644 --- a/tools/tracing/rtla/tests/timerlat.t +++ b/tools/tracing/rtla/tests/timerlat.t @@ -22,64 +22,60 @@ export RTLA_NO_BPF=$option # Basic tests check "verify help page" \ "timerlat --help" 0 "timerlat version" -check "verify -s/--stack" \ - "timerlat top -s 3 -T 10 -t" 2 "Blocking thread stack trace" -check "verify -P/--priority" \ - "timerlat top -P F:1 -c 0 -d 10s -q -T 1 --on-threshold shell,command=\"tests/scripts/check-priority.sh timerlatu/ SCHED_FIFO 1\"" \ +check_top_hist "verify help page" \ + "timerlat TOOL --help" 0 "rtla timerlat" +check_top_hist "verify -s/--stack" \ + "timerlat TOOL -s 3 -T 10 -t" 2 "Blocking thread stack trace" +check_top_hist "verify -P/--priority" \ + "timerlat TOOL -P F:1 -c 0 -d 10s -T 1 --on-threshold shell,command=\"tests/scripts/check-priority.sh timerlatu/ SCHED_FIFO 1\"" \ 2 "Priorities are set correctly" -check "test in nanoseconds" \ - "timerlat top -i 2 -c 0 -n -d 10s" 2 "ns" -check "set the automatic trace mode" \ - "timerlat top -a 5" 2 "analyzing it" -check "dump tasks" \ - "timerlat top -a 5 --dump-tasks" 2 "Printing CPU tasks" +check_top_hist "test in nanoseconds" \ + "timerlat TOOL -i 2 -c 0 -n -d 10s" 2 "ns" +check_top_hist "set the automatic trace mode" \ + "timerlat TOOL -a 5" 2 "analyzing it" +check_top_hist "dump tasks" \ + "timerlat TOOL -a 5 --dump-tasks" 2 "Printing CPU tasks" check "print the auto-analysis if hits the stop tracing condition" \ "timerlat top --aa-only 5" 2 -check "disable auto-analysis" \ - "timerlat top -s 3 -T 10 -t --no-aa" 2 -check "verify -c/--cpus" \ - "timerlat hist -c 0 -d 10s" -check "hist test in nanoseconds" \ - "timerlat hist -i 2 -c 0 -n -d 10s" 2 "ns" +check_top_hist "disable auto-analysis" \ + "timerlat TOOL -s 3 -T 10 -t --no-aa" 2 +check_top_hist "verify -c/--cpus" \ + "timerlat TOOL -c 0 -d 10s" # Actions tests -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 --on-threshold trace" \ - "timerlat hist -T 2 --on-threshold trace" 2 "^ Saving trace to timerlat_trace.txt$" -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$" -check "multiple actions" \ - "timerlat hist -T 2 --on-threshold shell,command='echo -n 1' --on-threshold shell,command='echo 2'" 2 "^12$" +check_top_q_hist "trace output through -t" \ + "timerlat TOOL -T 2 -t" 2 "^ Saving trace to timerlat_trace.txt$" +check_top_q_hist "trace output through -t with custom filename" \ + "timerlat TOOL -T 2 -t custom_filename.txt" 2 "^ Saving trace to custom_filename.txt$" +check_top_q_hist "trace output through --on-threshold trace" \ + "timerlat TOOL -T 2 --on-threshold trace" 2 "^ Saving trace to timerlat_trace.txt$" +check_top_q_hist "trace output through --on-threshold trace with custom filename" \ + "timerlat TOOL -T 2 --on-threshold trace,file=custom_filename.txt" 2 "^ Saving trace to custom_filename.txt$" +check_top_q_hist "exec command" \ + "timerlat TOOL -T 2 --on-threshold shell,command='echo TestOutput'" 2 "^TestOutput$" +check_top_q_hist "multiple actions" \ + "timerlat TOOL -T 2 --on-threshold shell,command='echo -n 1' --on-threshold shell,command='echo 2'" 2 "^12$" check "hist stop at failed action" \ "timerlat hist -T 2 --on-threshold shell,command='echo -n 1; false' --on-threshold shell,command='echo -n 2'" 2 "^1# RTLA timerlat 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" \ - "timerlat hist -T 2 -d 5s --on-threshold shell,command='echo TestOutput' --on-threshold continue" 0 "^TestOutput$" -check "top with continue" \ - "timerlat top -q -T 2 -d 5s --on-threshold shell,command='echo TestOutput' --on-threshold continue" 0 "^TestOutput$" -check "hist with trace output at end" \ - "timerlat hist -d 1s --on-end trace" 0 "^ Saving trace to timerlat_trace.txt$" -check "top with trace output at end" \ - "timerlat top -d 1s --on-end trace" 0 "^ Saving trace to timerlat_trace.txt$" +check_top_q_hist "with continue" \ + "timerlat TOOL -T 2 -d 5s --on-threshold shell,command='echo TestOutput' --on-threshold continue" 0 "^TestOutput$" +check_top_hist "with trace output at end" \ + "timerlat TOOL -d 1s --on-end trace" 0 "^ Saving trace to timerlat_trace.txt$" # BPF action program tests if [ "$option" -eq 0 ] then # Test BPF action program properly in BPF mode [ -z "$BPFTOOL" ] && BPFTOOL=bpftool - check "hist with BPF action program (BPF mode)" \ - "timerlat hist -T 2 --bpf-action tests/bpf/bpf_action_map.o --on-threshold shell,command='$BPFTOOL map dump name rtla_test_map'" \ + check_top_q_hist "with BPF action program (BPF mode)" \ + "timerlat TOOL -T 2 --bpf-action tests/bpf/bpf_action_map.o --on-threshold shell,command='$BPFTOOL map dump name rtla_test_map'" \ 2 '"value": 42' else # Test BPF action program failure in non-BPF mode - check "hist with BPF action program (non-BPF mode)" \ - "timerlat hist -T 2 --bpf-action tests/bpf/bpf_action_map.o" \ + check_top_q_hist "with BPF action program (non-BPF mode)" \ + "timerlat TOOL -T 2 --bpf-action tests/bpf/bpf_action_map.o" \ 1 "BPF actions are not supported in tracefs-only mode" fi done