| 1 | |
| 2 | |
| 3 | source tests/engine.sh
|
| 4 | test_begin
|
| 5 |
|
| 6 | set_timeout 2m
|
| 7 | timerlat_sample_event='/sys/kernel/tracing/events/osnoise/timerlat_sample'
|
| 8 |
|
| 9 | if ldd $RTLA | grep libbpf >/dev/null && [ -d "$timerlat_sample_event" ]
|
| 10 | then
|
| 11 | |
| 12 | no_bpf_options='0 1'
|
| 13 | else
|
| 14 | no_bpf_options='1'
|
| 15 | fi
|
| 16 |
|
| 17 | |
| 18 | for option in $no_bpf_options
|
| 19 | do
|
| 20 | export RTLA_NO_BPF=$option
|
| 21 |
|
| 22 | |
| 23 | check "verify help page" \
|
| 24 | "timerlat --help" 129 "timerlat version"
|
| 25 | check_top_hist "verify help page" \
|
| 26 | "timerlat TOOL --help" 129 "rtla timerlat"
|
| 27 | check_top_hist "verify -s/--stack" \
|
| 28 | "timerlat TOOL -s 3 -T 10 -t" 2 "Blocking thread stack trace"
|
| 29 | check_top_hist "test in nanoseconds" \
|
| 30 | "timerlat TOOL -i 2 -c 0 -n -d 10s" 2 "ns"
|
| 31 | check_top_hist "set the automatic trace mode" \
|
| 32 | "timerlat TOOL -a 5" 2 "analyzing it"
|
| 33 | check_top_hist "dump tasks" \
|
| 34 | "timerlat TOOL -a 5 --dump-tasks" 2 "Printing CPU tasks"
|
| 35 | check "verify --aa-only stop on threshold" \
|
| 36 | "timerlat top --aa-only 5" 2 "analyzing it" "Timer Latency"
|
| 37 | check "verify --aa-only max latency" \
|
| 38 | "timerlat top --aa-only 2000000 -d 1s" 0 "^ Max latency was" "Timer Latency"
|
| 39 | check_top_hist "disable auto-analysis" \
|
| 40 | "timerlat TOOL -s 3 -T 10 -t --no-aa" 2 "" "analyzing it"
|
| 41 |
|
| 42 | |
| 43 | check_top_hist "verify -P/--priority" \
|
| 44 | "timerlat TOOL -P F:1 -c 0 -d 10s -T 1 --on-threshold shell,command=\"$testdir/scripts/check-priority.sh SCHED_FIFO 1\"" \
|
| 45 | 2 "Priorities are set correctly"
|
| 46 | check_top_hist "verify -C/--cgroup" \
|
| 47 | "timerlat TOOL -k -C -c 0 -d 10s -T 1 --on-threshold shell,command=\"$testdir/scripts/check-cgroup-match.sh\"" \
|
| 48 | 2 "cgroup matches for all workload PIDs"
|
| 49 | check_top_q_hist "verify -c/--cpus" \
|
| 50 | "timerlat TOOL -c 0 -d 10s -T 1 --on-threshold shell,command=$testdir/scripts/check-cpus.sh" 2 "^Affinity of threads: 0$"
|
| 51 | check_top_q_hist "verify -H/--house-keeping" \
|
| 52 | "timerlat TOOL -H 0 -d 10s -T 1 --on-threshold shell,command=$testdir/scripts/check-housekeeping-cpus.sh" 2 "^Affinity of threads: 0$"
|
| 53 | check_top_q_hist "verify -k/--kernel-threads" \
|
| 54 | "timerlat TOOL -k -c 0 -d 10s -T 1 --on-threshold shell,command=$testdir/scripts/check-user-kernel-threads.sh" 2 "1 kernel threads, 0 user threads"
|
| 55 | check_top_q_hist "verify -u/--user-threads" \
|
| 56 | "timerlat TOOL -u -c 0 -d 10s -T 1 --on-threshold shell,command=$testdir/scripts/check-user-kernel-threads.sh" 2 "0 kernel threads, 1 user threads"
|
| 57 |
|
| 58 | |
| 59 | |
| 60 | check_with_osnoise_options "apply default timerlat_period_us" \
|
| 61 | "timerlat top -q -T 1 --on-threshold shell,command=\"$testdir/scripts/check-tracefs-value.sh osnoise/timerlat_period_us\"" \
|
| 62 | 2 "^osnoise/timerlat_period_us=1000$" osnoise/timerlat_period_us=999999
|
| 63 | check_with_osnoise_options "apply default print_stack" \
|
| 64 | "timerlat top -q -T 1 --on-threshold shell,command=\"$testdir/scripts/check-tracefs-value.sh osnoise/print_stack\"" \
|
| 65 | 2 "^osnoise/print_stack=0$" osnoise/print_stack=999999
|
| 66 | check_with_osnoise_options "apply default stop_tracing_us" \
|
| 67 | "timerlat top -q -T 1 --on-threshold shell,command=\"$testdir/scripts/check-tracefs-value.sh osnoise/stop_tracing_us\"" \
|
| 68 | 2 "^osnoise/stop_tracing_us=0$" osnoise/stop_tracing_us=999999
|
| 69 | check_with_osnoise_options "apply default stop_tracing_total_us" \
|
| 70 | "timerlat top -q -i 1 --on-threshold shell,command=\"$testdir/scripts/check-tracefs-value.sh osnoise/stop_tracing_total_us\"" \
|
| 71 | 2 "^osnoise/stop_tracing_total_us=0$" osnoise/stop_tracing_total_us=999999
|
| 72 |
|
| 73 | # Non-default tracer option tests: verify CLI options correctly set tracefs values
|
| 74 | check_top_q_hist "verify -p sets timerlat_period_us" \
|
| 75 | "timerlat TOOL -p 2000 -T 1 --on-threshold shell,command=\"$testdir/scripts/check-tracefs-value.sh osnoise/timerlat_period_us\"" \
|
| 76 | 2 "^osnoise/timerlat_period_us=2000$"
|
| 77 | check_top_q_hist "verify -s sets print_stack" \
|
| 78 | "timerlat TOOL -s 5 -T 1 --on-threshold shell,command=\"$testdir/scripts/check-tracefs-value.sh osnoise/print_stack\"" \
|
| 79 | 2 "^osnoise/print_stack=5$"
|
| 80 | check_top_q_hist "verify -i sets stop_tracing_us" \
|
| 81 | "timerlat TOOL -i 2 --on-threshold shell,command=\"$testdir/scripts/check-tracefs-value.sh osnoise/stop_tracing_us\"" \
|
| 82 | 2 "^osnoise/stop_tracing_us=2$"
|
| 83 | check_top_q_hist "verify -T sets stop_tracing_total_us" \
|
| 84 | "timerlat TOOL -T 2 --on-threshold shell,command=\"$testdir/scripts/check-tracefs-value.sh osnoise/stop_tracing_total_us\"" \
|
| 85 | 2 "^osnoise/stop_tracing_total_us=2$"
|
| 86 | check_with_osnoise_options "apply default TIMERLAT_ALIGN" \
|
| 87 | "timerlat top -q -T 1 --on-threshold shell,command=\"$testdir/scripts/check-osnoise-option.sh TIMERLAT_ALIGN\"" \
|
| 88 | 2 "^TIMERLAT_ALIGN=disabled$" osnoise/options=TIMERLAT_ALIGN
|
| 89 | check_top_q_hist "verify -A sets TIMERLAT_ALIGN" \
|
| 90 | "timerlat TOOL -A 100 -T 1 --on-threshold shell,command=\"$testdir/scripts/check-osnoise-option.sh TIMERLAT_ALIGN\"" \
|
| 91 | 2 "^TIMERLAT_ALIGN=enabled$"
|
| 92 | check_top_q_hist "verify -A sets timerlat_align_us" \
|
| 93 | "timerlat TOOL -A 100 -T 1 --on-threshold shell,command=\"$testdir/scripts/check-tracefs-value.sh osnoise/timerlat_align_us\"" \
|
| 94 | 2 "^osnoise/timerlat_align_us=100$"
|
| 95 |
|
| 96 | # Histogram tests
|
| 97 | check "hist with -b/--bucket-size" \
|
| 98 | "timerlat hist -b 1 -d 1s"
|
| 99 | check "hist with -E/--entries" \
|
| 100 | "timerlat hist -E 10 -d 1s"
|
| 101 | check "hist with -E/--entries out of range" \
|
| 102 | "timerlat hist -E 1 -d 1s" 129 "out of range \[10, 9999999\]"
|
| 103 | check "hist with --no-header" \
|
| 104 | "timerlat hist --no-header -d 1s" 0 "" "RTLA timerlat histogram"
|
| 105 | check "hist with --with-zeros" \
|
| 106 | "timerlat hist --with-zeros -b 100000 -E 21 -d 1s" 0 '^2000000\s+0\s+'
|
| 107 | check "hist with --no-index" \
|
| 108 | "timerlat hist --no-index --with-zeros -d 1s" 0 "" "^count:"
|
| 109 | check "hist with --no-summary" \
|
| 110 | "timerlat hist --no-summary -d 1s" 0 "" "^ALL:"
|
| 111 | check "hist with --no-irq" \
|
| 112 | "timerlat hist --no-irq -d 1s" 0 "" "IRQ-"
|
| 113 | check "hist with --no-thread" \
|
| 114 | "timerlat hist --no-thread -d 1s" 0 "" "Thr-"
|
| 115 |
|
| 116 | # Actions tests
|
| 117 | check_top_q_hist "trace output through -t" \
|
| 118 | "timerlat TOOL -T 2 -t" 2 "^ Saving trace to timerlat_trace.txt$"
|
| 119 | check_top_q_hist "trace output through -t with custom filename" \
|
| 120 | "timerlat TOOL -T 2 -t custom_filename.txt" 2 "^ Saving trace to custom_filename.txt$"
|
| 121 | check_top_q_hist "trace output through --on-threshold trace" \
|
| 122 | "timerlat TOOL -T 2 --on-threshold trace" 2 "^ Saving trace to timerlat_trace.txt$"
|
| 123 | check_top_q_hist "trace output through --on-threshold trace with custom filename" \
|
| 124 | "timerlat TOOL -T 2 --on-threshold trace,file=custom_filename.txt" 2 "^ Saving trace to custom_filename.txt$"
|
| 125 | check_top_q_hist "exec command" \
|
| 126 | "timerlat TOOL -T 2 --on-threshold shell,command='echo TestOutput'" 2 "^TestOutput$"
|
| 127 | check_top_q_hist "multiple actions" \
|
| 128 | "timerlat TOOL -T 2 --on-threshold shell,command='echo -n 1' --on-threshold shell,command='echo 2'" 2 "^12$"
|
| 129 | check "hist stop at failed action" \
|
| 130 | "timerlat hist -T 2 --on-threshold shell,command='echo -n 1; false' --on-threshold shell,command='echo -n 2'" 2 "^1 |
| 131 | check "top stop at failed action" \
|
| 132 | "timerlat top -T 2 --on-threshold shell,command='echo -n abc; false' --on-threshold shell,command='echo -n defgh'" 2 "^abc" "defgh"
|
| 133 | check_top_q_hist "with continue" \
|
| 134 | "timerlat TOOL -T 2 -d 5s --on-threshold shell,command='echo TestOutput' --on-threshold continue" 0 "^TestOutput$"
|
| 135 | check_top_q_hist "with conditional continue" \
|
| 136 | "timerlat TOOL -T 2 --on-threshold shell,command='if [ -f a ]; then echo 2; exit 1; else echo -n 1; touch a; fi' --on-threshold continue" 2 "^12$" "^2$"
|
| 137 | check_top_hist "with trace output at end" \
|
| 138 | "timerlat TOOL -d 1s --on-end trace" 0 "^ Saving trace to timerlat_trace.txt$"
|
| 139 |
|
| 140 | |
| 141 | if [ "$option" -eq 0 ]
|
| 142 | then
|
| 143 | |
| 144 | [ -z "$BPFTOOL" ] && BPFTOOL=bpftool
|
| 145 | check_top_q_hist "with BPF action program (BPF mode)" \
|
| 146 | "timerlat TOOL -T 2 --bpf-action $testdir/bpf/bpf_action_map.o --on-threshold shell,command='$BPFTOOL map dump name rtla_test_map'" \
|
| 147 | 2 '"value": 42'
|
| 148 | else
|
| 149 | |
| 150 | check_top_q_hist "with BPF action program (non-BPF mode)" \
|
| 151 | "timerlat TOOL -T 2 --bpf-action $testdir/bpf/bpf_action_map.o" \
|
| 152 | 1 "BPF actions are not supported in tracefs-only mode"
|
| 153 | fi
|
| 154 | done
|
| 155 |
|
| 156 | test_end
|