diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-10-28 15:58:42 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-10-28 15:58:42 -0400 |
commit | f8cab69be0a8a756a7409f6d2bd1e6e96ce46482 (patch) | |
tree | 8186251e5d4a0d8b8afe9a398c2dc9eb85eccf45 | |
parent | dad4f140edaa3f6bb452b6913d41af1ffd672e45 (diff) | |
parent | f73581f8d9a367459f36e6a4ef0065997ab14c75 (diff) |
Merge tag 'linux-kselftest-4.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
Pull kselftest updates from Shuah Khan:
"This Kselftest update for Linux 4.20-rc1 consists of:
- Improvements to ftrace test suite from Masami Hiramatsu.
- Color coded ftrace PASS / FAIL results from Steven Rostedt (VMware)
to improve readability of reports.
- watchdog Fixes and enhancement to add gettimeout and get|set
pretimeout options from Jerry Hoemann.
- Several fixes to warnings and spelling etc"
* tag 'linux-kselftest-4.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: (40 commits)
selftests/ftrace: Strip escape sequences for log file
selftests/ftrace: Use colored output when available
selftests: fix warning: "_GNU_SOURCE" redefined
selftests: kvm: Fix -Wformat warnings
selftests/ftrace: Add color to the PASS / FAIL results
kvm: selftests: fix spelling mistake "Insufficent" -> "Insufficient"
selftests: gpio: Fix OUTPUT directory in Makefile
selftests: gpio: restructure Makefile
selftests: watchdog: Fix ioctl SET* error paths to take oneshot exit path
selftests: watchdog: Add gettimeout and get|set pretimeout
selftests: watchdog: Fix error message.
selftests: watchdog: fix message when /dev/watchdog open fails
selftests/ftrace: Add ftrace cpumask testcase
selftests/ftrace: Add wakeup_rt tracer testcase
selftests/ftrace: Add wakeup tracer testcase
selftests/ftrace: Add stacktrace ftrace filter command testcase
selftests/ftrace: Add trace_pipe testcase
selftests/ftrace: Add function filter on module testcase
selftests/ftrace: Add max stack tracer testcase
selftests/ftrace: Add function profiling stat testcase
...
67 files changed, 564 insertions, 466 deletions
diff --git a/tools/testing/selftests/ftrace/config b/tools/testing/selftests/ftrace/config index 07db5ab09cc7..c2c8de4fafff 100644 --- a/tools/testing/selftests/ftrace/config +++ b/tools/testing/selftests/ftrace/config | |||
@@ -4,6 +4,12 @@ CONFIG_FUNCTION_PROFILER=y | |||
4 | CONFIG_TRACER_SNAPSHOT=y | 4 | CONFIG_TRACER_SNAPSHOT=y |
5 | CONFIG_STACK_TRACER=y | 5 | CONFIG_STACK_TRACER=y |
6 | CONFIG_HIST_TRIGGERS=y | 6 | CONFIG_HIST_TRIGGERS=y |
7 | CONFIG_SCHED_TRACER=y | ||
7 | CONFIG_PREEMPT_TRACER=y | 8 | CONFIG_PREEMPT_TRACER=y |
8 | CONFIG_IRQSOFF_TRACER=y | 9 | CONFIG_IRQSOFF_TRACER=y |
9 | CONFIG_PREEMPTIRQ_DELAY_TEST=m | 10 | CONFIG_PREEMPTIRQ_DELAY_TEST=m |
11 | CONFIG_MODULES=y | ||
12 | CONFIG_MODULE_UNLOAD=y | ||
13 | CONFIG_SAMPLES=y | ||
14 | CONFIG_SAMPLE_TRACE_PRINTK=m | ||
15 | CONFIG_KALLSYMS_ALL=y | ||
diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest index f9a9d424c980..75244db70331 100755 --- a/tools/testing/selftests/ftrace/ftracetest +++ b/tools/testing/selftests/ftrace/ftracetest | |||
@@ -60,15 +60,29 @@ parse_opts() { # opts | |||
60 | shift 1 | 60 | shift 1 |
61 | ;; | 61 | ;; |
62 | --verbose|-v|-vv|-vvv) | 62 | --verbose|-v|-vv|-vvv) |
63 | if [ $VERBOSE -eq -1 ]; then | ||
64 | usage "--console can not use with --verbose" | ||
65 | fi | ||
63 | VERBOSE=$((VERBOSE + 1)) | 66 | VERBOSE=$((VERBOSE + 1)) |
64 | [ $1 = '-vv' ] && VERBOSE=$((VERBOSE + 1)) | 67 | [ $1 = '-vv' ] && VERBOSE=$((VERBOSE + 1)) |
65 | [ $1 = '-vvv' ] && VERBOSE=$((VERBOSE + 2)) | 68 | [ $1 = '-vvv' ] && VERBOSE=$((VERBOSE + 2)) |
66 | shift 1 | 69 | shift 1 |
67 | ;; | 70 | ;; |
71 | --console) | ||
72 | if [ $VERBOSE -ne 0 ]; then | ||
73 | usage "--console can not use with --verbose" | ||
74 | fi | ||
75 | VERBOSE=-1 | ||
76 | shift 1 | ||
77 | ;; | ||
68 | --debug|-d) | 78 | --debug|-d) |
69 | DEBUG=1 | 79 | DEBUG=1 |
70 | shift 1 | 80 | shift 1 |
71 | ;; | 81 | ;; |
82 | --stop-fail) | ||
83 | STOP_FAILURE=1 | ||
84 | shift 1 | ||
85 | ;; | ||
72 | --fail-unsupported) | 86 | --fail-unsupported) |
73 | UNSUPPORTED_RESULT=1 | 87 | UNSUPPORTED_RESULT=1 |
74 | shift 1 | 88 | shift 1 |
@@ -117,6 +131,7 @@ KEEP_LOG=0 | |||
117 | DEBUG=0 | 131 | DEBUG=0 |
118 | VERBOSE=0 | 132 | VERBOSE=0 |
119 | UNSUPPORTED_RESULT=0 | 133 | UNSUPPORTED_RESULT=0 |
134 | STOP_FAILURE=0 | ||
120 | # Parse command-line options | 135 | # Parse command-line options |
121 | parse_opts $* | 136 | parse_opts $* |
122 | 137 | ||
@@ -137,11 +152,33 @@ else | |||
137 | date > $LOG_FILE | 152 | date > $LOG_FILE |
138 | fi | 153 | fi |
139 | 154 | ||
155 | # Define text colors | ||
156 | # Check available colors on the terminal, if any | ||
157 | ncolors=`tput colors 2>/dev/null` | ||
158 | color_reset= | ||
159 | color_red= | ||
160 | color_green= | ||
161 | color_blue= | ||
162 | # If stdout exists and number of colors is eight or more, use them | ||
163 | if [ -t 1 -a "$ncolors" -a "$ncolors" -ge 8 ]; then | ||
164 | color_reset="\e[0m" | ||
165 | color_red="\e[31m" | ||
166 | color_green="\e[32m" | ||
167 | color_blue="\e[34m" | ||
168 | fi | ||
169 | |||
170 | strip_esc() { | ||
171 | # busybox sed implementation doesn't accept "\x1B", so use [:cntrl:] instead. | ||
172 | sed -E "s/[[:cntrl:]]\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" | ||
173 | } | ||
174 | |||
140 | prlog() { # messages | 175 | prlog() { # messages |
141 | [ -z "$LOG_FILE" ] && echo "$@" || echo "$@" | tee -a $LOG_FILE | 176 | echo -e "$@" |
177 | [ "$LOG_FILE" ] && echo -e "$@" | strip_esc >> $LOG_FILE | ||
142 | } | 178 | } |
143 | catlog() { #file | 179 | catlog() { #file |
144 | [ -z "$LOG_FILE" ] && cat $1 || cat $1 | tee -a $LOG_FILE | 180 | cat $1 |
181 | [ "$LOG_FILE" ] && cat $1 | strip_esc >> $LOG_FILE | ||
145 | } | 182 | } |
146 | prlog "=== Ftrace unit tests ===" | 183 | prlog "=== Ftrace unit tests ===" |
147 | 184 | ||
@@ -180,37 +217,37 @@ test_on_instance() { # testfile | |||
180 | eval_result() { # sigval | 217 | eval_result() { # sigval |
181 | case $1 in | 218 | case $1 in |
182 | $PASS) | 219 | $PASS) |
183 | prlog " [PASS]" | 220 | prlog " [${color_green}PASS${color_reset}]" |
184 | PASSED_CASES="$PASSED_CASES $CASENO" | 221 | PASSED_CASES="$PASSED_CASES $CASENO" |
185 | return 0 | 222 | return 0 |
186 | ;; | 223 | ;; |
187 | $FAIL) | 224 | $FAIL) |
188 | prlog " [FAIL]" | 225 | prlog " [${color_red}FAIL${color_reset}]" |
189 | FAILED_CASES="$FAILED_CASES $CASENO" | 226 | FAILED_CASES="$FAILED_CASES $CASENO" |
190 | return 1 # this is a bug. | 227 | return 1 # this is a bug. |
191 | ;; | 228 | ;; |
192 | $UNRESOLVED) | 229 | $UNRESOLVED) |
193 | prlog " [UNRESOLVED]" | 230 | prlog " [${color_blue}UNRESOLVED${color_reset}]" |
194 | UNRESOLVED_CASES="$UNRESOLVED_CASES $CASENO" | 231 | UNRESOLVED_CASES="$UNRESOLVED_CASES $CASENO" |
195 | return 1 # this is a kind of bug.. something happened. | 232 | return 1 # this is a kind of bug.. something happened. |
196 | ;; | 233 | ;; |
197 | $UNTESTED) | 234 | $UNTESTED) |
198 | prlog " [UNTESTED]" | 235 | prlog " [${color_blue}UNTESTED${color_reset}]" |
199 | UNTESTED_CASES="$UNTESTED_CASES $CASENO" | 236 | UNTESTED_CASES="$UNTESTED_CASES $CASENO" |
200 | return 0 | 237 | return 0 |
201 | ;; | 238 | ;; |
202 | $UNSUPPORTED) | 239 | $UNSUPPORTED) |
203 | prlog " [UNSUPPORTED]" | 240 | prlog " [${color_blue}UNSUPPORTED${color_reset}]" |
204 | UNSUPPORTED_CASES="$UNSUPPORTED_CASES $CASENO" | 241 | UNSUPPORTED_CASES="$UNSUPPORTED_CASES $CASENO" |
205 | return $UNSUPPORTED_RESULT # depends on use case | 242 | return $UNSUPPORTED_RESULT # depends on use case |
206 | ;; | 243 | ;; |
207 | $XFAIL) | 244 | $XFAIL) |
208 | prlog " [XFAIL]" | 245 | prlog " [${color_red}XFAIL${color_reset}]" |
209 | XFAILED_CASES="$XFAILED_CASES $CASENO" | 246 | XFAILED_CASES="$XFAILED_CASES $CASENO" |
210 | return 0 | 247 | return 0 |
211 | ;; | 248 | ;; |
212 | *) | 249 | *) |
213 | prlog " [UNDEFINED]" | 250 | prlog " [${color_blue}UNDEFINED${color_reset}]" |
214 | UNDEFINED_CASES="$UNDEFINED_CASES $CASENO" | 251 | UNDEFINED_CASES="$UNDEFINED_CASES $CASENO" |
215 | return 1 # this must be a test bug | 252 | return 1 # this must be a test bug |
216 | ;; | 253 | ;; |
@@ -269,16 +306,18 @@ __run_test() { # testfile | |||
269 | # Run one test case | 306 | # Run one test case |
270 | run_test() { # testfile | 307 | run_test() { # testfile |
271 | local testname=`basename $1` | 308 | local testname=`basename $1` |
309 | testcase $1 | ||
272 | if [ ! -z "$LOG_FILE" ] ; then | 310 | if [ ! -z "$LOG_FILE" ] ; then |
273 | local testlog=`mktemp $LOG_DIR/${testname}-log.XXXXXX` | 311 | local testlog=`mktemp $LOG_DIR/${CASENO}-${testname}-log.XXXXXX` |
274 | else | 312 | else |
275 | local testlog=/proc/self/fd/1 | 313 | local testlog=/proc/self/fd/1 |
276 | fi | 314 | fi |
277 | export TMPDIR=`mktemp -d /tmp/ftracetest-dir.XXXXXX` | 315 | export TMPDIR=`mktemp -d /tmp/ftracetest-dir.XXXXXX` |
278 | testcase $1 | ||
279 | echo "execute$INSTANCE: "$1 > $testlog | 316 | echo "execute$INSTANCE: "$1 > $testlog |
280 | SIG_RESULT=0 | 317 | SIG_RESULT=0 |
281 | if [ -z "$LOG_FILE" ]; then | 318 | if [ $VERBOSE -eq -1 ]; then |
319 | __run_test $1 | ||
320 | elif [ -z "$LOG_FILE" ]; then | ||
282 | __run_test $1 2>&1 | 321 | __run_test $1 2>&1 |
283 | elif [ $VERBOSE -ge 3 ]; then | 322 | elif [ $VERBOSE -ge 3 ]; then |
284 | __run_test $1 | tee -a $testlog 2>&1 | 323 | __run_test $1 | tee -a $testlog 2>&1 |
@@ -304,6 +343,10 @@ run_test() { # testfile | |||
304 | # Main loop | 343 | # Main loop |
305 | for t in $TEST_CASES; do | 344 | for t in $TEST_CASES; do |
306 | run_test $t | 345 | run_test $t |
346 | if [ $STOP_FAILURE -ne 0 -a $TOTAL_RESULT -ne 0 ]; then | ||
347 | echo "A failure detected. Stop test." | ||
348 | exit 1 | ||
349 | fi | ||
307 | done | 350 | done |
308 | 351 | ||
309 | # Test on instance loop | 352 | # Test on instance loop |
@@ -315,7 +358,12 @@ for t in $TEST_CASES; do | |||
315 | run_test $t | 358 | run_test $t |
316 | rmdir $TRACING_DIR | 359 | rmdir $TRACING_DIR |
317 | TRACING_DIR=$SAVED_TRACING_DIR | 360 | TRACING_DIR=$SAVED_TRACING_DIR |
361 | if [ $STOP_FAILURE -ne 0 -a $TOTAL_RESULT -ne 0 ]; then | ||
362 | echo "A failure detected. Stop test." | ||
363 | exit 1 | ||
364 | fi | ||
318 | done | 365 | done |
366 | (cd $TRACING_DIR; initialize_ftrace) # for cleanup | ||
319 | 367 | ||
320 | prlog "" | 368 | prlog "" |
321 | prlog "# of passed: " `echo $PASSED_CASES | wc -w` | 369 | prlog "# of passed: " `echo $PASSED_CASES | wc -w` |
diff --git a/tools/testing/selftests/ftrace/test.d/00basic/ringbuffer_size.tc b/tools/testing/selftests/ftrace/test.d/00basic/ringbuffer_size.tc new file mode 100644 index 000000000000..ab70f0077c35 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/00basic/ringbuffer_size.tc | |||
@@ -0,0 +1,22 @@ | |||
1 | #!/bin/sh | ||
2 | # SPDX-License-Identifier: GPL-2.0 | ||
3 | # description: Change the ringbuffer size | ||
4 | # flags: instance | ||
5 | |||
6 | rb_size_test() { | ||
7 | ORIG=`cat buffer_size_kb` | ||
8 | |||
9 | expr $ORIG / 2 > buffer_size_kb | ||
10 | |||
11 | expr $ORIG \* 2 > buffer_size_kb | ||
12 | |||
13 | echo $ORIG > buffer_size_kb | ||
14 | } | ||
15 | |||
16 | rb_size_test | ||
17 | |||
18 | : "If per-cpu buffer is supported, imbalance it" | ||
19 | if [ -d per_cpu/cpu0 ]; then | ||
20 | cd per_cpu/cpu0 | ||
21 | rb_size_test | ||
22 | fi | ||
diff --git a/tools/testing/selftests/ftrace/test.d/00basic/trace_pipe.tc b/tools/testing/selftests/ftrace/test.d/00basic/trace_pipe.tc new file mode 100644 index 000000000000..5058fbcfd90f --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/00basic/trace_pipe.tc | |||
@@ -0,0 +1,16 @@ | |||
1 | #!/bin/sh | ||
2 | # SPDX-License-Identifier: GPL-2.0 | ||
3 | # description: trace_pipe and trace_marker | ||
4 | # flags: instance | ||
5 | |||
6 | [ ! -f trace_marker ] && exit_unsupported | ||
7 | |||
8 | echo "test input 1" > trace_marker | ||
9 | |||
10 | : "trace interface never consume the ring buffer" | ||
11 | grep -q "test input 1" trace | ||
12 | grep -q "test input 1" trace | ||
13 | |||
14 | : "trace interface never consume the ring buffer" | ||
15 | head -n 1 trace_pipe | grep -q "test input 1" | ||
16 | ! grep -q "test input 1" trace | ||
diff --git a/tools/testing/selftests/ftrace/test.d/event/event-enable.tc b/tools/testing/selftests/ftrace/test.d/event/event-enable.tc index 9daf034186f5..dfb0d5122f7b 100644 --- a/tools/testing/selftests/ftrace/test.d/event/event-enable.tc +++ b/tools/testing/selftests/ftrace/test.d/event/event-enable.tc | |||
@@ -9,23 +9,15 @@ do_reset() { | |||
9 | } | 9 | } |
10 | 10 | ||
11 | fail() { #msg | 11 | fail() { #msg |
12 | do_reset | ||
13 | echo $1 | 12 | echo $1 |
14 | exit_fail | 13 | exit_fail |
15 | } | 14 | } |
16 | 15 | ||
17 | yield() { | ||
18 | ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1 | ||
19 | } | ||
20 | |||
21 | if [ ! -f set_event -o ! -d events/sched ]; then | 16 | if [ ! -f set_event -o ! -d events/sched ]; then |
22 | echo "event tracing is not supported" | 17 | echo "event tracing is not supported" |
23 | exit_unsupported | 18 | exit_unsupported |
24 | fi | 19 | fi |
25 | 20 | ||
26 | reset_tracer | ||
27 | do_reset | ||
28 | |||
29 | echo 'sched:sched_switch' > set_event | 21 | echo 'sched:sched_switch' > set_event |
30 | 22 | ||
31 | yield | 23 | yield |
@@ -57,6 +49,4 @@ if [ $count -ne 0 ]; then | |||
57 | fail "sched_switch events should not be recorded" | 49 | fail "sched_switch events should not be recorded" |
58 | fi | 50 | fi |
59 | 51 | ||
60 | do_reset | ||
61 | |||
62 | exit 0 | 52 | exit 0 |
diff --git a/tools/testing/selftests/ftrace/test.d/event/event-pid.tc b/tools/testing/selftests/ftrace/test.d/event/event-pid.tc index 132478b305c2..f9cb214220b1 100644 --- a/tools/testing/selftests/ftrace/test.d/event/event-pid.tc +++ b/tools/testing/selftests/ftrace/test.d/event/event-pid.tc | |||
@@ -16,10 +16,6 @@ fail() { #msg | |||
16 | exit_fail | 16 | exit_fail |
17 | } | 17 | } |
18 | 18 | ||
19 | yield() { | ||
20 | ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1 | ||
21 | } | ||
22 | |||
23 | if [ ! -f set_event -o ! -d events/sched ]; then | 19 | if [ ! -f set_event -o ! -d events/sched ]; then |
24 | echo "event tracing is not supported" | 20 | echo "event tracing is not supported" |
25 | exit_unsupported | 21 | exit_unsupported |
@@ -30,8 +26,7 @@ if [ ! -f set_event_pid ]; then | |||
30 | exit_unsupported | 26 | exit_unsupported |
31 | fi | 27 | fi |
32 | 28 | ||
33 | reset_tracer | 29 | echo 0 > options/event-fork |
34 | do_reset | ||
35 | 30 | ||
36 | echo 1 > events/sched/sched_switch/enable | 31 | echo 1 > events/sched/sched_switch/enable |
37 | 32 | ||
@@ -47,6 +42,7 @@ do_reset | |||
47 | read mypid rest < /proc/self/stat | 42 | read mypid rest < /proc/self/stat |
48 | 43 | ||
49 | echo $mypid > set_event_pid | 44 | echo $mypid > set_event_pid |
45 | grep -q $mypid set_event_pid | ||
50 | echo 'sched:sched_switch' > set_event | 46 | echo 'sched:sched_switch' > set_event |
51 | 47 | ||
52 | yield | 48 | yield |
diff --git a/tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc b/tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc index 6a37a8642ee6..83a8c571e93a 100644 --- a/tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc +++ b/tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc | |||
@@ -9,23 +9,15 @@ do_reset() { | |||
9 | } | 9 | } |
10 | 10 | ||
11 | fail() { #msg | 11 | fail() { #msg |
12 | do_reset | ||
13 | echo $1 | 12 | echo $1 |
14 | exit_fail | 13 | exit_fail |
15 | } | 14 | } |
16 | 15 | ||
17 | yield() { | ||
18 | ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1 | ||
19 | } | ||
20 | |||
21 | if [ ! -f set_event -o ! -d events/sched ]; then | 16 | if [ ! -f set_event -o ! -d events/sched ]; then |
22 | echo "event tracing is not supported" | 17 | echo "event tracing is not supported" |
23 | exit_unsupported | 18 | exit_unsupported |
24 | fi | 19 | fi |
25 | 20 | ||
26 | reset_tracer | ||
27 | do_reset | ||
28 | |||
29 | echo 'sched:*' > set_event | 21 | echo 'sched:*' > set_event |
30 | 22 | ||
31 | yield | 23 | yield |
@@ -57,6 +49,4 @@ if [ $count -ne 0 ]; then | |||
57 | fail "any of scheduler events should not be recorded" | 49 | fail "any of scheduler events should not be recorded" |
58 | fi | 50 | fi |
59 | 51 | ||
60 | do_reset | ||
61 | |||
62 | exit 0 | 52 | exit 0 |
diff --git a/tools/testing/selftests/ftrace/test.d/event/toplevel-enable.tc b/tools/testing/selftests/ftrace/test.d/event/toplevel-enable.tc index 4e9b6e2c0219..84d7bda08d2a 100644 --- a/tools/testing/selftests/ftrace/test.d/event/toplevel-enable.tc +++ b/tools/testing/selftests/ftrace/test.d/event/toplevel-enable.tc | |||
@@ -8,23 +8,15 @@ do_reset() { | |||
8 | } | 8 | } |
9 | 9 | ||
10 | fail() { #msg | 10 | fail() { #msg |
11 | do_reset | ||
12 | echo $1 | 11 | echo $1 |
13 | exit_fail | 12 | exit_fail |
14 | } | 13 | } |
15 | 14 | ||
16 | yield() { | ||
17 | ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1 | ||
18 | } | ||
19 | |||
20 | if [ ! -f available_events -o ! -f set_event -o ! -d events ]; then | 15 | if [ ! -f available_events -o ! -f set_event -o ! -d events ]; then |
21 | echo "event tracing is not supported" | 16 | echo "event tracing is not supported" |
22 | exit_unsupported | 17 | exit_unsupported |
23 | fi | 18 | fi |
24 | 19 | ||
25 | reset_tracer | ||
26 | do_reset | ||
27 | |||
28 | echo '*:*' > set_event | 20 | echo '*:*' > set_event |
29 | 21 | ||
30 | yield | 22 | yield |
@@ -60,6 +52,4 @@ if [ $count -ne 0 ]; then | |||
60 | fail "any of events should not be recorded" | 52 | fail "any of events should not be recorded" |
61 | fi | 53 | fi |
62 | 54 | ||
63 | do_reset | ||
64 | |||
65 | exit 0 | 55 | exit 0 |
diff --git a/tools/testing/selftests/ftrace/test.d/event/trace_printk.tc b/tools/testing/selftests/ftrace/test.d/event/trace_printk.tc new file mode 100644 index 000000000000..b02550b42be9 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/event/trace_printk.tc | |||
@@ -0,0 +1,27 @@ | |||
1 | #!/bin/sh | ||
2 | # SPDX-License-Identifier: GPL-2.0 | ||
3 | # description: Test trace_printk from module | ||
4 | |||
5 | rmmod trace-printk ||: | ||
6 | if ! modprobe trace-printk ; then | ||
7 | echo "No trace-printk sample module - please make CONFIG_SAMPLE_TRACE_PRINTK=m" | ||
8 | exit_unresolved; | ||
9 | fi | ||
10 | |||
11 | echo "Waiting for irq work" | ||
12 | sleep 1 | ||
13 | |||
14 | grep -q ": This .* trace_bputs" trace | ||
15 | grep -q ": This .* trace_puts" trace | ||
16 | grep -q ": This .* trace_bprintk" trace | ||
17 | grep -q ": This .* trace_printk" trace | ||
18 | |||
19 | grep -q ": (irq) .* trace_bputs" trace | ||
20 | grep -q ": (irq) .* trace_puts" trace | ||
21 | grep -q ": (irq) .* trace_bprintk" trace | ||
22 | grep -q ": (irq) .* trace_printk" trace | ||
23 | |||
24 | grep -q "This is a %s that will use trace_bprintk" printk_formats | ||
25 | grep -q "(irq) This is a static string that will use trace_bputs" printk_formats | ||
26 | |||
27 | rmmod trace-printk ||: | ||
diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter-stack.tc b/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter-stack.tc index 1aec99d108eb..aefab0c66d54 100644 --- a/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter-stack.tc +++ b/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter-stack.tc | |||
@@ -16,13 +16,9 @@ if [ ! -f set_ftrace_filter ]; then | |||
16 | fi | 16 | fi |
17 | 17 | ||
18 | do_reset() { | 18 | do_reset() { |
19 | reset_tracer | ||
20 | if [ -e /proc/sys/kernel/stack_tracer_enabled ]; then | 19 | if [ -e /proc/sys/kernel/stack_tracer_enabled ]; then |
21 | echo 0 > /proc/sys/kernel/stack_tracer_enabled | 20 | echo 0 > /proc/sys/kernel/stack_tracer_enabled |
22 | fi | 21 | fi |
23 | enable_tracing | ||
24 | clear_trace | ||
25 | echo > set_ftrace_filter | ||
26 | } | 22 | } |
27 | 23 | ||
28 | fail() { # msg | 24 | fail() { # msg |
diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter.tc b/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter.tc index 9f8d27ca39cf..c8a5209f2119 100644 --- a/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter.tc +++ b/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter.tc | |||
@@ -9,14 +9,7 @@ if ! grep -q function_graph available_tracers; then | |||
9 | exit_unsupported | 9 | exit_unsupported |
10 | fi | 10 | fi |
11 | 11 | ||
12 | do_reset() { | ||
13 | reset_tracer | ||
14 | enable_tracing | ||
15 | clear_trace | ||
16 | } | ||
17 | |||
18 | fail() { # msg | 12 | fail() { # msg |
19 | do_reset | ||
20 | echo $1 | 13 | echo $1 |
21 | exit_fail | 14 | exit_fail |
22 | } | 15 | } |
@@ -48,6 +41,4 @@ if [ $count -eq 0 ]; then | |||
48 | fail "No schedule traces found?" | 41 | fail "No schedule traces found?" |
49 | fi | 42 | fi |
50 | 43 | ||
51 | do_reset | ||
52 | |||
53 | exit 0 | 44 | exit 0 |
diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc index 524ce24b3c22..64cfcc75e3c1 100644 --- a/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc +++ b/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc | |||
@@ -35,12 +35,6 @@ if [ $do_function_fork -eq 1 ]; then | |||
35 | fi | 35 | fi |
36 | 36 | ||
37 | do_reset() { | 37 | do_reset() { |
38 | reset_tracer | ||
39 | clear_trace | ||
40 | enable_tracing | ||
41 | echo > set_ftrace_filter | ||
42 | echo > set_ftrace_pid | ||
43 | |||
44 | if [ $do_function_fork -eq 0 ]; then | 38 | if [ $do_function_fork -eq 0 ]; then |
45 | return | 39 | return |
46 | fi | 40 | fi |
@@ -54,10 +48,6 @@ fail() { # msg | |||
54 | exit_fail | 48 | exit_fail |
55 | } | 49 | } |
56 | 50 | ||
57 | yield() { | ||
58 | ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1 | ||
59 | } | ||
60 | |||
61 | do_test() { | 51 | do_test() { |
62 | disable_tracing | 52 | disable_tracing |
63 | 53 | ||
diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-stacktrace.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-stacktrace.tc new file mode 100644 index 000000000000..bf72e783d014 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-stacktrace.tc | |||
@@ -0,0 +1,12 @@ | |||
1 | #!/bin/sh | ||
2 | # SPDX-License-Identifier: GPL2.0 | ||
3 | # description: ftrace - stacktrace filter command | ||
4 | # flags: instance | ||
5 | |||
6 | echo _do_fork:stacktrace >> set_ftrace_filter | ||
7 | |||
8 | grep -q "_do_fork:stacktrace:unlimited" set_ftrace_filter | ||
9 | |||
10 | (echo "forked"; sleep 1) | ||
11 | |||
12 | grep -q "<stack trace>" trace | ||
diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func_cpumask.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func_cpumask.tc new file mode 100644 index 000000000000..0e6810743576 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/ftrace/func_cpumask.tc | |||
@@ -0,0 +1,42 @@ | |||
1 | #!/bin/sh | ||
2 | # SPDX-License-Identifier: GPL2.0 | ||
3 | # description: ftrace - function trace with cpumask | ||
4 | |||
5 | if ! which nproc ; then | ||
6 | nproc() { | ||
7 | ls -d /sys/devices/system/cpu/cpu[0-9]* | wc -l | ||
8 | } | ||
9 | fi | ||
10 | |||
11 | NP=`nproc` | ||
12 | |||
13 | if [ $NP -eq 1 ] ;then | ||
14 | echo "We can not test cpumask on UP environment" | ||
15 | exit_unresolved | ||
16 | fi | ||
17 | |||
18 | ORIG_CPUMASK=`cat tracing_cpumask` | ||
19 | |||
20 | do_reset() { | ||
21 | echo $ORIG_CPUMASK > tracing_cpumask | ||
22 | } | ||
23 | |||
24 | echo 0 > tracing_on | ||
25 | echo > trace | ||
26 | : "Bitmask only record on CPU1" | ||
27 | echo 2 > tracing_cpumask | ||
28 | MASK=0x`cat tracing_cpumask` | ||
29 | test `printf "%d" $MASK` -eq 2 || do_reset | ||
30 | |||
31 | echo function > current_tracer | ||
32 | echo 1 > tracing_on | ||
33 | (echo "forked") | ||
34 | echo 0 > tracing_on | ||
35 | |||
36 | : "Check CPU1 events are recorded" | ||
37 | grep -q -e "\[001\]" trace || do_reset | ||
38 | |||
39 | : "There should be No other cpu events" | ||
40 | ! grep -qv -e "\[001\]" -e "^#" trace || do_reset | ||
41 | |||
42 | do_reset | ||
diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc index 6fed4cf2db81..ca2ffd7957f9 100644 --- a/tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc +++ b/tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc | |||
@@ -25,15 +25,12 @@ do_reset() { | |||
25 | } | 25 | } |
26 | 26 | ||
27 | fail() { # mesg | 27 | fail() { # mesg |
28 | do_reset | ||
29 | echo $1 | 28 | echo $1 |
30 | exit_fail | 29 | exit_fail |
31 | } | 30 | } |
32 | 31 | ||
33 | SLEEP_TIME=".1" | 32 | SLEEP_TIME=".1" |
34 | 33 | ||
35 | do_reset | ||
36 | |||
37 | echo "Testing function probes with events:" | 34 | echo "Testing function probes with events:" |
38 | 35 | ||
39 | EVENT="sched:sched_switch" | 36 | EVENT="sched:sched_switch" |
diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func_mod_trace.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func_mod_trace.tc new file mode 100644 index 000000000000..9330c873f9fe --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/ftrace/func_mod_trace.tc | |||
@@ -0,0 +1,24 @@ | |||
1 | #!/bin/sh | ||
2 | # SPDX-License-Identifier: GPL-2.0 | ||
3 | # description: ftrace - function trace on module | ||
4 | |||
5 | [ ! -f set_ftrace_filter ] && exit_unsupported | ||
6 | |||
7 | : "mod: allows to filter a non exist function" | ||
8 | echo 'non_exist_func:mod:non_exist_module' > set_ftrace_filter | ||
9 | grep -q "non_exist_func" set_ftrace_filter | ||
10 | |||
11 | : "mod: on exist module" | ||
12 | echo '*:mod:trace_printk' > set_ftrace_filter | ||
13 | if ! modprobe trace-printk ; then | ||
14 | echo "No trace-printk sample module - please make CONFIG_SAMPLE_TRACE_PRINTK= | ||
15 | m" | ||
16 | exit_unresolved; | ||
17 | fi | ||
18 | |||
19 | : "Wildcard should be resolved after loading module" | ||
20 | grep -q "trace_printk_irq_work" set_ftrace_filter | ||
21 | |||
22 | : "After removing the filter becomes empty" | ||
23 | rmmod trace_printk | ||
24 | test `cat set_ftrace_filter | wc -l` -eq 0 | ||
diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func_profile_stat.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func_profile_stat.tc new file mode 100644 index 000000000000..0d501058aa75 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/ftrace/func_profile_stat.tc | |||
@@ -0,0 +1,22 @@ | |||
1 | #!/bin/sh | ||
2 | # SPDX-License-Identifier: GPL-2.0 | ||
3 | # description: ftrace - function profiling | ||
4 | |||
5 | [ ! -f function_profile_enabled ] && exit_unsupported | ||
6 | |||
7 | : "Enable function profile" | ||
8 | echo 1 > function_profile_enabled | ||
9 | |||
10 | : "Profile must be updated" | ||
11 | cp trace_stat/function0 $TMPDIR/ | ||
12 | ( echo "forked"; sleep 1 ) | ||
13 | : "diff returns 0 if there is no difference" | ||
14 | ! diff trace_stat/function0 $TMPDIR/function0 | ||
15 | |||
16 | echo 0 > function_profile_enabled | ||
17 | |||
18 | : "Profile must NOT be updated" | ||
19 | cp trace_stat/function0 $TMPDIR/ | ||
20 | ( echo "forked"; sleep 1 ) | ||
21 | : "diff returns 0 if there is no difference" | ||
22 | diff trace_stat/function0 $TMPDIR/function0 | ||
diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func_profiler.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func_profiler.tc index b2d5a8febfe8..dfbae637c60c 100644 --- a/tools/testing/selftests/ftrace/test.d/ftrace/func_profiler.tc +++ b/tools/testing/selftests/ftrace/test.d/ftrace/func_profiler.tc | |||
@@ -29,8 +29,6 @@ if [ ! -f function_profile_enabled ]; then | |||
29 | fi | 29 | fi |
30 | 30 | ||
31 | fail() { # mesg | 31 | fail() { # mesg |
32 | reset_tracer | ||
33 | echo > set_ftrace_filter | ||
34 | echo $1 | 32 | echo $1 |
35 | exit_fail | 33 | exit_fail |
36 | } | 34 | } |
@@ -76,6 +74,4 @@ if ! grep -v -e '^#' -e 'schedule' trace > /dev/null; then | |||
76 | fail "no other functions besides schedule was found" | 74 | fail "no other functions besides schedule was found" |
77 | fi | 75 | fi |
78 | 76 | ||
79 | reset_tracer | ||
80 | |||
81 | exit 0 | 77 | exit 0 |
diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func_set_ftrace_file.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func_set_ftrace_file.tc index 68e7a48f5828..51f6e6146bd9 100644 --- a/tools/testing/selftests/ftrace/test.d/ftrace/func_set_ftrace_file.tc +++ b/tools/testing/selftests/ftrace/test.d/ftrace/func_set_ftrace_file.tc | |||
@@ -15,22 +15,11 @@ if [ ! -f set_ftrace_filter ]; then | |||
15 | exit_unsupported | 15 | exit_unsupported |
16 | fi | 16 | fi |
17 | 17 | ||
18 | do_reset() { | ||
19 | reset_tracer | ||
20 | reset_ftrace_filter | ||
21 | disable_events | ||
22 | clear_trace | ||
23 | enable_tracing | ||
24 | } | ||
25 | |||
26 | fail() { # mesg | 18 | fail() { # mesg |
27 | do_reset | ||
28 | echo $1 | 19 | echo $1 |
29 | exit_fail | 20 | exit_fail |
30 | } | 21 | } |
31 | 22 | ||
32 | do_reset | ||
33 | |||
34 | FILTER=set_ftrace_filter | 23 | FILTER=set_ftrace_filter |
35 | FUNC1="schedule" | 24 | FUNC1="schedule" |
36 | FUNC2="do_softirq" | 25 | FUNC2="do_softirq" |
@@ -165,6 +154,4 @@ test_actual | |||
165 | rm $TMPDIR/expected | 154 | rm $TMPDIR/expected |
166 | rm $TMPDIR/actual | 155 | rm $TMPDIR/actual |
167 | 156 | ||
168 | do_reset | ||
169 | |||
170 | exit 0 | 157 | exit 0 |
diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc new file mode 100644 index 000000000000..b414f0e3c646 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc | |||
@@ -0,0 +1,39 @@ | |||
1 | #!/bin/sh | ||
2 | # SPDX-License-Identifier: GPL-2.0 | ||
3 | # description: ftrace - Max stack tracer | ||
4 | # Test the basic function of max-stack usage tracing | ||
5 | |||
6 | if [ ! -f stack_trace ]; then | ||
7 | echo "Max stack tracer is not supported - please make CONFIG_STACK_TRACER=y" | ||
8 | exit_unsupported | ||
9 | fi | ||
10 | |||
11 | echo > stack_trace_filter | ||
12 | echo 0 > stack_max_size | ||
13 | echo 1 > /proc/sys/kernel/stack_tracer_enabled | ||
14 | |||
15 | : "Fork and wait for the first entry become !lock" | ||
16 | timeout=10 | ||
17 | while [ $timeout -ne 0 ]; do | ||
18 | ( echo "forked" ) | ||
19 | FL=`grep " 0)" stack_trace` | ||
20 | echo $FL | grep -q "lock" || break; | ||
21 | timeout=$((timeout - 1)) | ||
22 | done | ||
23 | echo 0 > /proc/sys/kernel/stack_tracer_enabled | ||
24 | |||
25 | echo '*lock*' > stack_trace_filter | ||
26 | test `cat stack_trace_filter | wc -l` -eq `grep lock stack_trace_filter | wc -l` | ||
27 | |||
28 | echo 0 > stack_max_size | ||
29 | echo 1 > /proc/sys/kernel/stack_tracer_enabled | ||
30 | |||
31 | : "Fork and always the first entry including lock" | ||
32 | timeout=10 | ||
33 | while [ $timeout -ne 0 ]; do | ||
34 | ( echo "forked" ) | ||
35 | FL=`grep " 0)" stack_trace` | ||
36 | echo $FL | grep -q "lock" | ||
37 | timeout=$((timeout - 1)) | ||
38 | done | ||
39 | echo 0 > /proc/sys/kernel/stack_tracer_enabled | ||
diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func_traceonoff_triggers.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func_traceonoff_triggers.tc index f6d9ac73268a..0c04282d33dd 100644 --- a/tools/testing/selftests/ftrace/test.d/ftrace/func_traceonoff_triggers.tc +++ b/tools/testing/selftests/ftrace/test.d/ftrace/func_traceonoff_triggers.tc | |||
@@ -16,24 +16,13 @@ if [ ! -f set_ftrace_filter ]; then | |||
16 | exit_unsupported | 16 | exit_unsupported |
17 | fi | 17 | fi |
18 | 18 | ||
19 | do_reset() { | ||
20 | reset_ftrace_filter | ||
21 | reset_tracer | ||
22 | disable_events | ||
23 | clear_trace | ||
24 | enable_tracing | ||
25 | } | ||
26 | |||
27 | fail() { # mesg | 19 | fail() { # mesg |
28 | do_reset | ||
29 | echo $1 | 20 | echo $1 |
30 | exit_fail | 21 | exit_fail |
31 | } | 22 | } |
32 | 23 | ||
33 | SLEEP_TIME=".1" | 24 | SLEEP_TIME=".1" |
34 | 25 | ||
35 | do_reset | ||
36 | |||
37 | echo "Testing function probes with enabling disabling tracing:" | 26 | echo "Testing function probes with enabling disabling tracing:" |
38 | 27 | ||
39 | cnt_trace() { | 28 | cnt_trace() { |
diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions index e4645d5e3126..7b96e80e6b8a 100644 --- a/tools/testing/selftests/ftrace/test.d/functions +++ b/tools/testing/selftests/ftrace/test.d/functions | |||
@@ -89,12 +89,23 @@ initialize_ftrace() { # Reset ftrace to initial-state | |||
89 | reset_tracer | 89 | reset_tracer |
90 | reset_trigger | 90 | reset_trigger |
91 | reset_events_filter | 91 | reset_events_filter |
92 | reset_ftrace_filter | ||
92 | disable_events | 93 | disable_events |
93 | echo > set_event_pid # event tracer is always on | 94 | echo > set_event_pid # event tracer is always on |
95 | echo > set_ftrace_pid | ||
94 | [ -f set_ftrace_filter ] && echo | tee set_ftrace_* | 96 | [ -f set_ftrace_filter ] && echo | tee set_ftrace_* |
95 | [ -f set_graph_function ] && echo | tee set_graph_* | 97 | [ -f set_graph_function ] && echo | tee set_graph_* |
96 | [ -f stack_trace_filter ] && echo > stack_trace_filter | 98 | [ -f stack_trace_filter ] && echo > stack_trace_filter |
97 | [ -f kprobe_events ] && echo > kprobe_events | 99 | [ -f kprobe_events ] && echo > kprobe_events |
98 | [ -f uprobe_events ] && echo > uprobe_events | 100 | [ -f uprobe_events ] && echo > uprobe_events |
101 | [ -f synthetic_events ] && echo > synthetic_events | ||
102 | [ -f snapshot ] && echo 0 > snapshot | ||
103 | clear_trace | ||
99 | enable_tracing | 104 | enable_tracing |
100 | } | 105 | } |
106 | |||
107 | LOCALHOST=127.0.0.1 | ||
108 | |||
109 | yield() { | ||
110 | ping $LOCALHOST -c 1 || sleep .001 || usleep 1 || sleep 1 | ||
111 | } | ||
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/add_and_remove.tc b/tools/testing/selftests/ftrace/test.d/kprobe/add_and_remove.tc index 4604d2103c89..bb1eb5a7c64e 100644 --- a/tools/testing/selftests/ftrace/test.d/kprobe/add_and_remove.tc +++ b/tools/testing/selftests/ftrace/test.d/kprobe/add_and_remove.tc | |||
@@ -4,10 +4,7 @@ | |||
4 | 4 | ||
5 | [ -f kprobe_events ] || exit_unsupported # this is configurable | 5 | [ -f kprobe_events ] || exit_unsupported # this is configurable |
6 | 6 | ||
7 | echo 0 > events/enable | ||
8 | echo > kprobe_events | ||
9 | echo p:myevent _do_fork > kprobe_events | 7 | echo p:myevent _do_fork > kprobe_events |
10 | grep myevent kprobe_events | 8 | grep myevent kprobe_events |
11 | test -d events/kprobes/myevent | 9 | test -d events/kprobes/myevent |
12 | echo > kprobe_events | 10 | echo > kprobe_events |
13 | clear_trace | ||
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/busy_check.tc b/tools/testing/selftests/ftrace/test.d/kprobe/busy_check.tc index bbc443a9190c..442c1a8c5edf 100644 --- a/tools/testing/selftests/ftrace/test.d/kprobe/busy_check.tc +++ b/tools/testing/selftests/ftrace/test.d/kprobe/busy_check.tc | |||
@@ -4,12 +4,9 @@ | |||
4 | 4 | ||
5 | [ -f kprobe_events ] || exit_unsupported | 5 | [ -f kprobe_events ] || exit_unsupported |
6 | 6 | ||
7 | echo 0 > events/enable | ||
8 | echo > kprobe_events | ||
9 | echo p:myevent _do_fork > kprobe_events | 7 | echo p:myevent _do_fork > kprobe_events |
10 | test -d events/kprobes/myevent | 8 | test -d events/kprobes/myevent |
11 | echo 1 > events/kprobes/myevent/enable | 9 | echo 1 > events/kprobes/myevent/enable |
12 | echo > kprobe_events && exit_fail # this must fail | 10 | echo > kprobe_events && exit_fail # this must fail |
13 | echo 0 > events/kprobes/myevent/enable | 11 | echo 0 > events/kprobes/myevent/enable |
14 | echo > kprobe_events # this must succeed | 12 | echo > kprobe_events # this must succeed |
15 | clear_trace | ||
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args.tc index 8b43c6804fc3..bcdecf80a8f1 100644 --- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args.tc +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args.tc | |||
@@ -4,13 +4,15 @@ | |||
4 | 4 | ||
5 | [ -f kprobe_events ] || exit_unsupported # this is configurable | 5 | [ -f kprobe_events ] || exit_unsupported # this is configurable |
6 | 6 | ||
7 | echo 0 > events/enable | ||
8 | echo > kprobe_events | ||
9 | echo 'p:testprobe _do_fork $stack $stack0 +0($stack)' > kprobe_events | 7 | echo 'p:testprobe _do_fork $stack $stack0 +0($stack)' > kprobe_events |
10 | grep testprobe kprobe_events | 8 | grep testprobe kprobe_events | grep -q 'arg1=\$stack arg2=\$stack0 arg3=+0(\$stack)' |
11 | test -d events/kprobes/testprobe | 9 | test -d events/kprobes/testprobe |
10 | |||
12 | echo 1 > events/kprobes/testprobe/enable | 11 | echo 1 > events/kprobes/testprobe/enable |
13 | ( echo "forked") | 12 | ( echo "forked") |
13 | grep testprobe trace | grep '_do_fork' | \ | ||
14 | grep -q 'arg1=0x[[:xdigit:]]* arg2=0x[[:xdigit:]]* arg3=0x[[:xdigit:]]*$' | ||
15 | |||
14 | echo 0 > events/kprobes/testprobe/enable | 16 | echo 0 > events/kprobes/testprobe/enable |
15 | echo "-:testprobe" >> kprobe_events | 17 | echo "-:testprobe" >> kprobe_events |
16 | clear_trace | 18 | clear_trace |
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_comm.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_comm.tc new file mode 100644 index 000000000000..15c1f70fcaf9 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_comm.tc | |||
@@ -0,0 +1,17 @@ | |||
1 | #!/bin/sh | ||
2 | # SPDX-License-Identifier: GPL-2.0 | ||
3 | # description: Kprobe event with comm arguments | ||
4 | |||
5 | [ -f kprobe_events ] || exit_unsupported # this is configurable | ||
6 | |||
7 | grep -A1 "fetcharg:" README | grep -q "\$comm" || exit_unsupported # this is too old | ||
8 | |||
9 | echo 'p:testprobe _do_fork comm=$comm ' > kprobe_events | ||
10 | grep testprobe kprobe_events | grep -q 'comm=$comm' | ||
11 | test -d events/kprobes/testprobe | ||
12 | |||
13 | echo 1 > events/kprobes/testprobe/enable | ||
14 | ( echo "forked") | ||
15 | grep testprobe trace | grep -q 'comm=".*"' | ||
16 | |||
17 | exit 0 | ||
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_string.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_string.tc index 1ad70cdaf442..46e7744f8358 100644 --- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_string.tc +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_string.tc | |||
@@ -4,9 +4,6 @@ | |||
4 | 4 | ||
5 | [ -f kprobe_events ] || exit_unsupported # this is configurable | 5 | [ -f kprobe_events ] || exit_unsupported # this is configurable |
6 | 6 | ||
7 | echo 0 > events/enable | ||
8 | echo > kprobe_events | ||
9 | |||
10 | case `uname -m` in | 7 | case `uname -m` in |
11 | x86_64) | 8 | x86_64) |
12 | ARG1=%di | 9 | ARG1=%di |
@@ -44,5 +41,3 @@ echo 1 > events/kprobes/testprobe/enable | |||
44 | echo "p:test _do_fork" >> kprobe_events | 41 | echo "p:test _do_fork" >> kprobe_events |
45 | grep -qe "testprobe.* arg1=\"test\" arg2=\"test\"" trace | 42 | grep -qe "testprobe.* arg1=\"test\" arg2=\"test\"" trace |
46 | 43 | ||
47 | echo 0 > events/enable | ||
48 | echo > kprobe_events | ||
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_symbol.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_symbol.tc new file mode 100644 index 000000000000..2b6dd33f9076 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_symbol.tc | |||
@@ -0,0 +1,39 @@ | |||
1 | #!/bin/sh | ||
2 | # SPDX-License-Identifier: GPL-2.0 | ||
3 | # description: Kprobe event symbol argument | ||
4 | |||
5 | [ -f kprobe_events ] || exit_unsupported # this is configurable | ||
6 | |||
7 | SYMBOL="linux_proc_banner" | ||
8 | |||
9 | if [ ! -f /proc/kallsyms ]; then | ||
10 | echo "Can not check the target symbol - please enable CONFIG_KALLSYMS" | ||
11 | exit_unresolved | ||
12 | elif ! grep "$SYMBOL\$" /proc/kallsyms; then | ||
13 | echo "Linux banner is not exported - please enable CONFIG_KALLSYMS_ALL" | ||
14 | exit_unresolved | ||
15 | fi | ||
16 | |||
17 | : "Test get basic types symbol argument" | ||
18 | echo "p:testprobe_u _do_fork arg1=@linux_proc_banner:u64 arg2=@linux_proc_banner:u32 arg3=@linux_proc_banner:u16 arg4=@linux_proc_banner:u8" > kprobe_events | ||
19 | echo "p:testprobe_s _do_fork arg1=@linux_proc_banner:s64 arg2=@linux_proc_banner:s32 arg3=@linux_proc_banner:s16 arg4=@linux_proc_banner:s8" >> kprobe_events | ||
20 | if grep -q "x8/16/32/64" README; then | ||
21 | echo "p:testprobe_x _do_fork arg1=@linux_proc_banner:x64 arg2=@linux_proc_banner:x32 arg3=@linux_proc_banner:x16 arg4=@linux_proc_banner:x8" >> kprobe_events | ||
22 | fi | ||
23 | echo "p:testprobe_bf _do_fork arg1=@linux_proc_banner:b8@4/32" >> kprobe_events | ||
24 | echo 1 > events/kprobes/enable | ||
25 | (echo "forked") | ||
26 | echo 0 > events/kprobes/enable | ||
27 | grep "testprobe_[usx]:.* arg1=.* arg2=.* arg3=.* arg4=.*" trace | ||
28 | grep "testprobe_bf:.* arg1=.*" trace | ||
29 | |||
30 | : "Test get string symbol argument" | ||
31 | echo "p:testprobe_str _do_fork arg1=@linux_proc_banner:string" > kprobe_events | ||
32 | echo 1 > events/kprobes/enable | ||
33 | (echo "forked") | ||
34 | echo 0 > events/kprobes/enable | ||
35 | RESULT=`grep "testprobe_str" trace | sed -e 's/.* arg1=\(.*\)/\1/'` | ||
36 | |||
37 | RESULT=`echo $RESULT | sed -e 's/.* \((.*)\) \((.*)\) .*/\1 \2/'` | ||
38 | ORIG=`cat /proc/version | sed -e 's/.* \((.*)\) \((.*)\) .*/\1 \2/'` | ||
39 | test "$RESULT" = "$ORIG" | ||
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_syntax.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_syntax.tc index d026ff4e562f..6f0f19953193 100644 --- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_syntax.tc +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_syntax.tc | |||
@@ -6,9 +6,6 @@ | |||
6 | 6 | ||
7 | grep "x8/16/32/64" README > /dev/null || exit_unsupported # version issue | 7 | grep "x8/16/32/64" README > /dev/null || exit_unsupported # version issue |
8 | 8 | ||
9 | echo 0 > events/enable | ||
10 | echo > kprobe_events | ||
11 | |||
12 | PROBEFUNC="vfs_read" | 9 | PROBEFUNC="vfs_read" |
13 | GOODREG= | 10 | GOODREG= |
14 | BADREG= | 11 | BADREG= |
@@ -78,8 +75,11 @@ test_badarg "\$stackp" "\$stack0+10" "\$stack1-10" | |||
78 | echo "r ${PROBEFUNC} \$retval" > kprobe_events | 75 | echo "r ${PROBEFUNC} \$retval" > kprobe_events |
79 | ! echo "p ${PROBEFUNC} \$retval" > kprobe_events | 76 | ! echo "p ${PROBEFUNC} \$retval" > kprobe_events |
80 | 77 | ||
78 | # $comm was introduced in 4.8, older kernels reject it. | ||
79 | if grep -A1 "fetcharg:" README | grep -q '\$comm' ; then | ||
81 | : "Comm access" | 80 | : "Comm access" |
82 | test_goodarg "\$comm" | 81 | test_goodarg "\$comm" |
82 | fi | ||
83 | 83 | ||
84 | : "Indirect memory access" | 84 | : "Indirect memory access" |
85 | test_goodarg "+0(${GOODREG})" "-0(${GOODREG})" "+10(\$stack)" \ | 85 | test_goodarg "+0(${GOODREG})" "-0(${GOODREG})" "+10(\$stack)" \ |
@@ -100,5 +100,3 @@ test_badarg "${GOODREG}::${GOODTYPE}" "${GOODREG}:${BADTYPE}" \ | |||
100 | 100 | ||
101 | test_goodarg "\$comm:string" "+0(\$stack):string" | 101 | test_goodarg "\$comm:string" "+0(\$stack):string" |
102 | test_badarg "\$comm:x64" "\$stack:string" "${GOODREG}:string" | 102 | test_badarg "\$comm:x64" "\$stack:string" "${GOODREG}:string" |
103 | |||
104 | echo > kprobe_events | ||
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc index 2a1755bfc290..1bcb67dcae26 100644 --- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc | |||
@@ -6,33 +6,45 @@ | |||
6 | 6 | ||
7 | grep "x8/16/32/64" README > /dev/null || exit_unsupported # version issue | 7 | grep "x8/16/32/64" README > /dev/null || exit_unsupported # version issue |
8 | 8 | ||
9 | echo 0 > events/enable | 9 | gen_event() { # Bitsize |
10 | echo > kprobe_events | 10 | echo "p:testprobe _do_fork \$stack0:s$1 \$stack0:u$1 \$stack0:x$1 \$stack0:b4@4/$1" |
11 | enable_tracing | 11 | } |
12 | |||
13 | echo 'p:testprobe _do_fork $stack0:s32 $stack0:u32 $stack0:x32 $stack0:b8@4/32' > kprobe_events | ||
14 | grep testprobe kprobe_events | ||
15 | test -d events/kprobes/testprobe | ||
16 | |||
17 | echo 1 > events/kprobes/testprobe/enable | ||
18 | ( echo "forked") | ||
19 | echo 0 > events/kprobes/testprobe/enable | ||
20 | ARGS=`tail -n 1 trace | sed -e 's/.* arg1=\(.*\) arg2=\(.*\) arg3=\(.*\) arg4=\(.*\)/\1 \2 \3 \4/'` | ||
21 | 12 | ||
22 | check_types() { | 13 | check_types() { # s-type u-type x-type bf-type width |
23 | X1=`printf "%x" $1 | tail -c 8` | 14 | test $# -eq 5 |
15 | CW=$5 | ||
16 | CW=$((CW / 4)) | ||
17 | X1=`printf "%x" $1 | tail -c ${CW}` | ||
24 | X2=`printf "%x" $2` | 18 | X2=`printf "%x" $2` |
25 | X3=`printf "%x" $3` | 19 | X3=`printf "%x" $3` |
26 | test $X1 = $X2 | 20 | test $X1 = $X2 |
27 | test $X2 = $X3 | 21 | test $X2 = $X3 |
28 | test 0x$X3 = $3 | 22 | test 0x$X3 = $3 |
29 | 23 | ||
30 | B4=`printf "%02x" $4` | 24 | B4=`printf "%1x" $4` |
31 | B3=`echo -n $X3 | tail -c 3 | head -c 2` | 25 | B3=`printf "%03x" 0x$X3 | tail -c 2 | head -c 1` |
32 | test $B3 = $B4 | 26 | test $B3 = $B4 |
33 | } | 27 | } |
34 | check_types $ARGS | ||
35 | 28 | ||
36 | echo "-:testprobe" >> kprobe_events | 29 | for width in 64 32 16 8; do |
37 | clear_trace | 30 | : "Add new event with basic types" |
38 | test -d events/kprobes/testprobe && exit_fail || exit_pass | 31 | gen_event $width > kprobe_events |
32 | grep testprobe kprobe_events | ||
33 | test -d events/kprobes/testprobe | ||
34 | |||
35 | : "Trace the event" | ||
36 | echo 1 > events/kprobes/testprobe/enable | ||
37 | ( echo "forked") | ||
38 | echo 0 > events/kprobes/testprobe/enable | ||
39 | |||
40 | : "Confirm the arguments is recorded in given types correctly" | ||
41 | ARGS=`grep "testprobe" trace | sed -e 's/.* arg1=\(.*\) arg2=\(.*\) arg3=\(.*\) arg4=\(.*\)/\1 \2 \3 \4/'` | ||
42 | check_types $ARGS $width | ||
43 | |||
44 | : "Clear event for next loop" | ||
45 | echo "-:testprobe" >> kprobe_events | ||
46 | clear_trace | ||
47 | |||
48 | done | ||
49 | |||
50 | exit_pass | ||
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc index 2724a1068cb1..3fb70e01b1fe 100644 --- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc | |||
@@ -4,9 +4,6 @@ | |||
4 | 4 | ||
5 | [ -f kprobe_events ] || exit_unsupported # this is configurable | 5 | [ -f kprobe_events ] || exit_unsupported # this is configurable |
6 | 6 | ||
7 | disable_events | ||
8 | echo > kprobe_events | ||
9 | |||
10 | :;: "Add an event on function without name" ;: | 7 | :;: "Add an event on function without name" ;: |
11 | 8 | ||
12 | FUNC=`grep " [tT] .*vfs_read$" /proc/kallsyms | tail -n 1 | cut -f 3 -d " "` | 9 | FUNC=`grep " [tT] .*vfs_read$" /proc/kallsyms | tail -n 1 | cut -f 3 -d " "` |
@@ -33,5 +30,3 @@ echo "p $FUNC" > kprobe_events | |||
33 | EVENT=`grep $FUNC kprobe_events | cut -f 1 -d " " | cut -f 2 -d:` | 30 | EVENT=`grep $FUNC kprobe_events | cut -f 1 -d " " | cut -f 2 -d:` |
34 | [ "x" != "x$EVENT" ] || exit_failure | 31 | [ "x" != "x$EVENT" ] || exit_failure |
35 | test -d events/$EVENT || exit_failure | 32 | test -d events/$EVENT || exit_failure |
36 | |||
37 | echo > kprobe_events | ||
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc index cc4cac0e60f2..492426e95e09 100644 --- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc | |||
@@ -8,8 +8,6 @@ grep function available_tracers || exit_unsupported # this is configurable | |||
8 | # prepare | 8 | # prepare |
9 | echo nop > current_tracer | 9 | echo nop > current_tracer |
10 | echo _do_fork > set_ftrace_filter | 10 | echo _do_fork > set_ftrace_filter |
11 | echo 0 > events/enable | ||
12 | echo > kprobe_events | ||
13 | echo 'p:testprobe _do_fork' > kprobe_events | 11 | echo 'p:testprobe _do_fork' > kprobe_events |
14 | 12 | ||
15 | # kprobe on / ftrace off | 13 | # kprobe on / ftrace off |
@@ -47,10 +45,3 @@ echo > trace | |||
47 | ( echo "forked") | 45 | ( echo "forked") |
48 | grep testprobe trace | 46 | grep testprobe trace |
49 | ! grep '_do_fork <-' trace | 47 | ! grep '_do_fork <-' trace |
50 | |||
51 | # cleanup | ||
52 | echo nop > current_tracer | ||
53 | echo > set_ftrace_filter | ||
54 | echo 0 > events/kprobes/testprobe/enable | ||
55 | echo > kprobe_events | ||
56 | echo > trace | ||
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_module.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_module.tc index 1e9f75f7a30f..d861bd776c5e 100644 --- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_module.tc +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_module.tc | |||
@@ -4,14 +4,18 @@ | |||
4 | 4 | ||
5 | [ -f kprobe_events ] || exit_unsupported # this is configurable | 5 | [ -f kprobe_events ] || exit_unsupported # this is configurable |
6 | 6 | ||
7 | disable_events | 7 | rmmod trace-printk ||: |
8 | echo > kprobe_events | 8 | if ! modprobe trace-printk ; then |
9 | echo "No trace-printk sample module - please make CONFIG_SAMPLE_TRACE_PRINTK= | ||
10 | m" | ||
11 | exit_unresolved; | ||
12 | fi | ||
13 | |||
14 | MOD=trace_printk | ||
15 | FUNC=trace_printk_irq_work | ||
9 | 16 | ||
10 | :;: "Add an event on a module function without specifying event name" ;: | 17 | :;: "Add an event on a module function without specifying event name" ;: |
11 | 18 | ||
12 | MOD=`lsmod | head -n 2 | tail -n 1 | cut -f1 -d" "` | ||
13 | FUNC=`grep -m 1 ".* t .*\\[$MOD\\]" /proc/kallsyms | xargs | cut -f3 -d" "` | ||
14 | [ "x" != "x$MOD" -a "y" != "y$FUNC" ] || exit_unresolved | ||
15 | echo "p $MOD:$FUNC" > kprobe_events | 19 | echo "p $MOD:$FUNC" > kprobe_events |
16 | PROBE_NAME=`echo $MOD:$FUNC | tr ".:" "_"` | 20 | PROBE_NAME=`echo $MOD:$FUNC | tr ".:" "_"` |
17 | test -d events/kprobes/p_${PROBE_NAME}_0 || exit_failure | 21 | test -d events/kprobes/p_${PROBE_NAME}_0 || exit_failure |
@@ -26,4 +30,24 @@ test -d events/kprobes/event1 || exit_failure | |||
26 | echo "p:kprobes1/event1 $MOD:$FUNC" > kprobe_events | 30 | echo "p:kprobes1/event1 $MOD:$FUNC" > kprobe_events |
27 | test -d events/kprobes1/event1 || exit_failure | 31 | test -d events/kprobes1/event1 || exit_failure |
28 | 32 | ||
29 | echo > kprobe_events | 33 | :;: "Remove target module, but event still be there" ;: |
34 | if ! rmmod trace-printk ; then | ||
35 | echo "Failed to unload module - please enable CONFIG_MODULE_UNLOAD" | ||
36 | exit_unresolved; | ||
37 | fi | ||
38 | test -d events/kprobes1/event1 | ||
39 | |||
40 | :;: "Check posibility to defining events on unloaded module";: | ||
41 | echo "p:event2 $MOD:$FUNC" >> kprobe_events | ||
42 | |||
43 | :;: "Target is gone, but we can prepare for next time";: | ||
44 | echo 1 > events/kprobes1/event1/enable | ||
45 | |||
46 | :;: "Load module again, which means the event1 should be recorded";: | ||
47 | modprobe trace-printk | ||
48 | grep "event1:" trace | ||
49 | |||
50 | :;: "Remove the module again and check the event is not locked" | ||
51 | rmmod trace-printk | ||
52 | echo 0 > events/kprobes1/event1/enable | ||
53 | echo "-:kprobes1/event1" >> kprobe_events | ||
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_args.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_args.tc index 321954683aaa..ac9ab4a12e53 100644 --- a/tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_args.tc +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_args.tc | |||
@@ -4,13 +4,16 @@ | |||
4 | 4 | ||
5 | [ -f kprobe_events ] || exit_unsupported # this is configurable | 5 | [ -f kprobe_events ] || exit_unsupported # this is configurable |
6 | 6 | ||
7 | echo 0 > events/enable | 7 | # Add new kretprobe event |
8 | echo > kprobe_events | ||
9 | echo 'r:testprobe2 _do_fork $retval' > kprobe_events | 8 | echo 'r:testprobe2 _do_fork $retval' > kprobe_events |
10 | grep testprobe2 kprobe_events | 9 | grep testprobe2 kprobe_events | grep -q 'arg1=\$retval' |
11 | test -d events/kprobes/testprobe2 | 10 | test -d events/kprobes/testprobe2 |
11 | |||
12 | echo 1 > events/kprobes/testprobe2/enable | 12 | echo 1 > events/kprobes/testprobe2/enable |
13 | ( echo "forked") | 13 | ( echo "forked") |
14 | |||
15 | cat trace | grep testprobe2 | grep -q '<- _do_fork' | ||
16 | |||
14 | echo 0 > events/kprobes/testprobe2/enable | 17 | echo 0 > events/kprobes/testprobe2/enable |
15 | echo '-:testprobe2' >> kprobe_events | 18 | echo '-:testprobe2' >> kprobe_events |
16 | clear_trace | 19 | clear_trace |
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_maxactive.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_maxactive.tc index 7c0290684c43..8e05b178519a 100644 --- a/tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_maxactive.tc +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_maxactive.tc | |||
@@ -5,8 +5,6 @@ | |||
5 | [ -f kprobe_events ] || exit_unsupported # this is configurable | 5 | [ -f kprobe_events ] || exit_unsupported # this is configurable |
6 | grep -q 'r\[maxactive\]' README || exit_unsupported # this is older version | 6 | grep -q 'r\[maxactive\]' README || exit_unsupported # this is older version |
7 | 7 | ||
8 | echo > kprobe_events | ||
9 | |||
10 | # Test if we successfully reject unknown messages | 8 | # Test if we successfully reject unknown messages |
11 | if echo 'a:myprobeaccept inet_csk_accept' > kprobe_events; then false; else true; fi | 9 | if echo 'a:myprobeaccept inet_csk_accept' > kprobe_events; then false; else true; fi |
12 | 10 | ||
@@ -37,5 +35,3 @@ echo > kprobe_events | |||
37 | echo 'r10 inet_csk_accept' > kprobe_events | 35 | echo 'r10 inet_csk_accept' > kprobe_events |
38 | grep inet_csk_accept kprobe_events | 36 | grep inet_csk_accept kprobe_events |
39 | echo > kprobe_events | 37 | echo > kprobe_events |
40 | |||
41 | clear_trace | ||
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc b/tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc index ce361b9d62cf..5862eee91e1d 100644 --- a/tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc +++ b/tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc | |||
@@ -12,11 +12,6 @@ case `uname -m` in | |||
12 | *) OFFS=0;; | 12 | *) OFFS=0;; |
13 | esac | 13 | esac |
14 | 14 | ||
15 | if [ -d events/kprobes ]; then | ||
16 | echo 0 > events/kprobes/enable | ||
17 | echo > kprobe_events | ||
18 | fi | ||
19 | |||
20 | N=0 | 15 | N=0 |
21 | echo "Setup up kprobes on first available 256 text symbols" | 16 | echo "Setup up kprobes on first available 256 text symbols" |
22 | grep -i " t " /proc/kallsyms | cut -f3 -d" " | grep -v .*\\..* | \ | 17 | grep -i " t " /proc/kallsyms | cut -f3 -d" " | grep -v .*\\..* | \ |
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/probepoint.tc b/tools/testing/selftests/ftrace/test.d/kprobe/probepoint.tc index 519d2763f5d2..a902aa0aaabc 100644 --- a/tools/testing/selftests/ftrace/test.d/kprobe/probepoint.tc +++ b/tools/testing/selftests/ftrace/test.d/kprobe/probepoint.tc | |||
@@ -30,8 +30,6 @@ if [ `printf "%x" -1 | wc -c` != 9 ]; then | |||
30 | UINT_TEST=yes | 30 | UINT_TEST=yes |
31 | fi | 31 | fi |
32 | 32 | ||
33 | echo 0 > events/enable | ||
34 | echo > kprobe_events | ||
35 | echo "p:testprobe ${TARGET_FUNC}" > kprobe_events | 33 | echo "p:testprobe ${TARGET_FUNC}" > kprobe_events |
36 | echo "p:testprobe ${TARGET}" > kprobe_events | 34 | echo "p:testprobe ${TARGET}" > kprobe_events |
37 | echo "p:testprobe ${TARGET_FUNC}${NEXT}" > kprobe_events | 35 | echo "p:testprobe ${TARGET_FUNC}${NEXT}" > kprobe_events |
@@ -39,5 +37,3 @@ echo "p:testprobe ${TARGET_FUNC}${NEXT}" > kprobe_events | |||
39 | if [ "${UINT_TEST}" = yes ]; then | 37 | if [ "${UINT_TEST}" = yes ]; then |
40 | ! echo "p:testprobe ${TARGET_FUNC}${OVERFLOW}" > kprobe_events | 38 | ! echo "p:testprobe ${TARGET_FUNC}${OVERFLOW}" > kprobe_events |
41 | fi | 39 | fi |
42 | echo > kprobe_events | ||
43 | clear_trace | ||
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/profile.tc b/tools/testing/selftests/ftrace/test.d/kprobe/profile.tc new file mode 100644 index 000000000000..0384b525cdee --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/kprobe/profile.tc | |||
@@ -0,0 +1,15 @@ | |||
1 | #!/bin/sh | ||
2 | # SPDX-License-Identifier: GPL-2.0 | ||
3 | # description: Kprobe dynamic event - adding and removing | ||
4 | |||
5 | [ -f kprobe_events ] || exit_unsupported # this is configurable | ||
6 | |||
7 | ! grep -q 'myevent' kprobe_profile | ||
8 | echo p:myevent _do_fork > kprobe_events | ||
9 | grep -q 'myevent[[:space:]]*0[[:space:]]*0$' kprobe_profile | ||
10 | echo 1 > events/kprobes/myevent/enable | ||
11 | ( echo "forked" ) | ||
12 | grep -q 'myevent[[:space:]]*[[:digit:]]*[[:space:]]*0$' kprobe_profile | ||
13 | echo 0 > events/kprobes/myevent/enable | ||
14 | echo > kprobe_events | ||
15 | ! grep -q 'myevent' kprobe_profile | ||
diff --git a/tools/testing/selftests/ftrace/test.d/template b/tools/testing/selftests/ftrace/test.d/template index 5c39ceb18a0d..799da7e0b3c9 100644 --- a/tools/testing/selftests/ftrace/test.d/template +++ b/tools/testing/selftests/ftrace/test.d/template | |||
@@ -1,4 +1,5 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | # SPDX-License-Identifier: GPL2.0 | ||
2 | # description: %HERE DESCRIBE WHAT THIS DOES% | 3 | # description: %HERE DESCRIBE WHAT THIS DOES% |
3 | # you have to add ".tc" extention for your testcase file | 4 | # you have to add ".tc" extention for your testcase file |
4 | # Note that all tests are run with "errexit" option. | 5 | # Note that all tests are run with "errexit" option. |
diff --git a/tools/testing/selftests/ftrace/test.d/tracer/wakeup.tc b/tools/testing/selftests/ftrace/test.d/tracer/wakeup.tc new file mode 100644 index 000000000000..e3005fa785f0 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/tracer/wakeup.tc | |||
@@ -0,0 +1,25 @@ | |||
1 | #!/bin/sh | ||
2 | # SPDX-License-Identifier: GPL2.0 | ||
3 | # description: Test wakeup tracer | ||
4 | |||
5 | if ! which chrt ; then | ||
6 | echo "chrt is not found. This test requires nice command." | ||
7 | exit_unresolved | ||
8 | fi | ||
9 | |||
10 | if ! grep -wq "wakeup" available_tracers ; then | ||
11 | echo "wakeup tracer is not supported" | ||
12 | exit_unsupported | ||
13 | fi | ||
14 | |||
15 | echo wakeup > current_tracer | ||
16 | echo 1 > tracing_on | ||
17 | echo 0 > tracing_max_latency | ||
18 | |||
19 | : "Wakeup higher priority task" | ||
20 | chrt -f 5 sleep 1 | ||
21 | |||
22 | echo 0 > tracing_on | ||
23 | grep '+ \[[[:digit:]]*\]' trace | ||
24 | grep '==> \[[[:digit:]]*\]' trace | ||
25 | |||
diff --git a/tools/testing/selftests/ftrace/test.d/tracer/wakeup_rt.tc b/tools/testing/selftests/ftrace/test.d/tracer/wakeup_rt.tc new file mode 100644 index 000000000000..f99b5178e00a --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/tracer/wakeup_rt.tc | |||
@@ -0,0 +1,25 @@ | |||
1 | #!/bin/sh | ||
2 | # SPDX-License-Identifier: GPL2.0 | ||
3 | # description: Test wakeup RT tracer | ||
4 | |||
5 | if ! which chrt ; then | ||
6 | echo "chrt is not found. This test requires chrt command." | ||
7 | exit_unresolved | ||
8 | fi | ||
9 | |||
10 | if ! grep -wq "wakeup_rt" available_tracers ; then | ||
11 | echo "wakeup_rt tracer is not supported" | ||
12 | exit_unsupported | ||
13 | fi | ||
14 | |||
15 | echo wakeup_rt > current_tracer | ||
16 | echo 1 > tracing_on | ||
17 | echo 0 > tracing_max_latency | ||
18 | |||
19 | : "Wakeup a realtime task" | ||
20 | chrt -f 5 sleep 1 | ||
21 | |||
22 | echo 0 > tracing_on | ||
23 | grep "+ \[[[:digit:]]*\]" trace | ||
24 | grep "==> \[[[:digit:]]*\]" trace | ||
25 | |||
diff --git a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-extended-error-support.tc b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-extended-error-support.tc index 2aabab363cfb..401104344593 100644 --- a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-extended-error-support.tc +++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-extended-error-support.tc | |||
@@ -2,14 +2,7 @@ | |||
2 | # description: event trigger - test extended error support | 2 | # description: event trigger - test extended error support |
3 | 3 | ||
4 | 4 | ||
5 | do_reset() { | ||
6 | reset_trigger | ||
7 | echo > set_event | ||
8 | clear_trace | ||
9 | } | ||
10 | |||
11 | fail() { #msg | 5 | fail() { #msg |
12 | do_reset | ||
13 | echo $1 | 6 | echo $1 |
14 | exit_fail | 7 | exit_fail |
15 | } | 8 | } |
@@ -24,9 +17,6 @@ if [ ! -f synthetic_events ]; then | |||
24 | exit_unsupported | 17 | exit_unsupported |
25 | fi | 18 | fi |
26 | 19 | ||
27 | reset_tracer | ||
28 | do_reset | ||
29 | |||
30 | echo "Test extended error support" | 20 | echo "Test extended error support" |
31 | echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' > events/sched/sched_wakeup/trigger | 21 | echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' > events/sched/sched_wakeup/trigger |
32 | ! echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' >> events/sched/sched_wakeup/trigger 2> /dev/null | 22 | ! echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' >> events/sched/sched_wakeup/trigger 2> /dev/null |
@@ -34,6 +24,4 @@ if ! grep -q "ERROR:" events/sched/sched_wakeup/hist; then | |||
34 | fail "Failed to generate extended error in histogram" | 24 | fail "Failed to generate extended error in histogram" |
35 | fi | 25 | fi |
36 | 26 | ||
37 | do_reset | ||
38 | |||
39 | exit 0 | 27 | exit 0 |
diff --git a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-field-variable-support.tc b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-field-variable-support.tc index 7fd5b4a8f060..f59b2a9a1f22 100644 --- a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-field-variable-support.tc +++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-field-variable-support.tc | |||
@@ -1,14 +1,7 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | # description: event trigger - test field variable support | 2 | # description: event trigger - test field variable support |
3 | 3 | ||
4 | do_reset() { | ||
5 | reset_trigger | ||
6 | echo > set_event | ||
7 | clear_trace | ||
8 | } | ||
9 | |||
10 | fail() { #msg | 4 | fail() { #msg |
11 | do_reset | ||
12 | echo $1 | 5 | echo $1 |
13 | exit_fail | 6 | exit_fail |
14 | } | 7 | } |
@@ -23,10 +16,6 @@ if [ ! -f synthetic_events ]; then | |||
23 | exit_unsupported | 16 | exit_unsupported |
24 | fi | 17 | fi |
25 | 18 | ||
26 | clear_synthetic_events | ||
27 | reset_tracer | ||
28 | do_reset | ||
29 | |||
30 | echo "Test field variable support" | 19 | echo "Test field variable support" |
31 | 20 | ||
32 | echo 'wakeup_latency u64 lat; pid_t pid; int prio; char comm[16]' > synthetic_events | 21 | echo 'wakeup_latency u64 lat; pid_t pid; int prio; char comm[16]' > synthetic_events |
@@ -34,7 +23,7 @@ echo 'hist:keys=comm:ts0=common_timestamp.usecs if comm=="ping"' > events/sched/ | |||
34 | echo 'hist:keys=next_comm:wakeup_lat=common_timestamp.usecs-$ts0:onmatch(sched.sched_waking).wakeup_latency($wakeup_lat,next_pid,sched.sched_waking.prio,next_comm) if next_comm=="ping"' > events/sched/sched_switch/trigger | 23 | echo 'hist:keys=next_comm:wakeup_lat=common_timestamp.usecs-$ts0:onmatch(sched.sched_waking).wakeup_latency($wakeup_lat,next_pid,sched.sched_waking.prio,next_comm) if next_comm=="ping"' > events/sched/sched_switch/trigger |
35 | echo 'hist:keys=pid,prio,comm:vals=lat:sort=pid,prio' > events/synthetic/wakeup_latency/trigger | 24 | echo 'hist:keys=pid,prio,comm:vals=lat:sort=pid,prio' > events/synthetic/wakeup_latency/trigger |
36 | 25 | ||
37 | ping localhost -c 3 | 26 | ping $LOCALHOST -c 3 |
38 | if ! grep -q "ping" events/synthetic/wakeup_latency/hist; then | 27 | if ! grep -q "ping" events/synthetic/wakeup_latency/hist; then |
39 | fail "Failed to create inter-event histogram" | 28 | fail "Failed to create inter-event histogram" |
40 | fi | 29 | fi |
@@ -49,6 +38,4 @@ if grep -q "synthetic_prio=prio" events/sched/sched_waking/hist; then | |||
49 | fail "Failed to remove histogram with field variable" | 38 | fail "Failed to remove histogram with field variable" |
50 | fi | 39 | fi |
51 | 40 | ||
52 | do_reset | ||
53 | |||
54 | exit 0 | 41 | exit 0 |
diff --git a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-inter-event-combined-hist.tc b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-inter-event-combined-hist.tc index c93dbe38b5df..524d9ce361e2 100644 --- a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-inter-event-combined-hist.tc +++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-inter-event-combined-hist.tc | |||
@@ -1,14 +1,7 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | # description: event trigger - test inter-event combined histogram trigger | 2 | # description: event trigger - test inter-event combined histogram trigger |
3 | 3 | ||
4 | do_reset() { | ||
5 | reset_trigger | ||
6 | echo > set_event | ||
7 | clear_trace | ||
8 | } | ||
9 | |||
10 | fail() { #msg | 4 | fail() { #msg |
11 | do_reset | ||
12 | echo $1 | 5 | echo $1 |
13 | exit_fail | 6 | exit_fail |
14 | } | 7 | } |
@@ -23,10 +16,6 @@ if [ ! -f synthetic_events ]; then | |||
23 | exit_unsupported | 16 | exit_unsupported |
24 | fi | 17 | fi |
25 | 18 | ||
26 | reset_tracer | ||
27 | do_reset | ||
28 | clear_synthetic_events | ||
29 | |||
30 | echo "Test create synthetic event" | 19 | echo "Test create synthetic event" |
31 | 20 | ||
32 | echo 'waking_latency u64 lat pid_t pid' > synthetic_events | 21 | echo 'waking_latency u64 lat pid_t pid' > synthetic_events |
@@ -48,11 +37,9 @@ echo 'waking+wakeup_latency u64 lat; pid_t pid' >> synthetic_events | |||
48 | echo 'hist:keys=pid,lat:sort=pid,lat:ww_lat=$waking_lat+$wakeup_lat:onmatch(synthetic.wakeup_latency).waking+wakeup_latency($ww_lat,pid)' >> events/synthetic/wakeup_latency/trigger | 37 | echo 'hist:keys=pid,lat:sort=pid,lat:ww_lat=$waking_lat+$wakeup_lat:onmatch(synthetic.wakeup_latency).waking+wakeup_latency($ww_lat,pid)' >> events/synthetic/wakeup_latency/trigger |
49 | echo 'hist:keys=pid,lat:sort=pid,lat' >> events/synthetic/waking+wakeup_latency/trigger | 38 | echo 'hist:keys=pid,lat:sort=pid,lat' >> events/synthetic/waking+wakeup_latency/trigger |
50 | 39 | ||
51 | ping localhost -c 3 | 40 | ping $LOCALHOST -c 3 |
52 | if ! grep -q "pid:" events/synthetic/waking+wakeup_latency/hist; then | 41 | if ! grep -q "pid:" events/synthetic/waking+wakeup_latency/hist; then |
53 | fail "Failed to create combined histogram" | 42 | fail "Failed to create combined histogram" |
54 | fi | 43 | fi |
55 | 44 | ||
56 | do_reset | ||
57 | |||
58 | exit 0 | 45 | exit 0 |
diff --git a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-multi-actions-accept.tc b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-multi-actions-accept.tc index c193dce611a2..4ddc546771b5 100644 --- a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-multi-actions-accept.tc +++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-multi-actions-accept.tc | |||
@@ -1,15 +1,7 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | # description: event trigger - test multiple actions on hist trigger | 2 | # description: event trigger - test multiple actions on hist trigger |
3 | 3 | ||
4 | |||
5 | do_reset() { | ||
6 | reset_trigger | ||
7 | echo > set_event | ||
8 | clear_trace | ||
9 | } | ||
10 | |||
11 | fail() { #msg | 4 | fail() { #msg |
12 | do_reset | ||
13 | echo $1 | 5 | echo $1 |
14 | exit_fail | 6 | exit_fail |
15 | } | 7 | } |
@@ -24,10 +16,6 @@ if [ ! -f synthetic_events ]; then | |||
24 | exit_unsupported | 16 | exit_unsupported |
25 | fi | 17 | fi |
26 | 18 | ||
27 | clear_synthetic_events | ||
28 | reset_tracer | ||
29 | do_reset | ||
30 | |||
31 | echo "Test multiple actions on hist trigger" | 19 | echo "Test multiple actions on hist trigger" |
32 | echo 'wakeup_latency u64 lat; pid_t pid' >> synthetic_events | 20 | echo 'wakeup_latency u64 lat; pid_t pid' >> synthetic_events |
33 | TRIGGER1=events/sched/sched_wakeup/trigger | 21 | TRIGGER1=events/sched/sched_wakeup/trigger |
@@ -39,6 +27,4 @@ echo 'hist:keys=next_pid:onmatch(sched.sched_wakeup).wakeup_latency(sched.sched_ | |||
39 | echo 'hist:keys=next_pid:onmatch(sched.sched_wakeup).wakeup_latency(sched.sched_switch.$wakeup_lat,prev_pid) if next_comm=="cyclictest"' >> $TRIGGER2 | 27 | echo 'hist:keys=next_pid:onmatch(sched.sched_wakeup).wakeup_latency(sched.sched_switch.$wakeup_lat,prev_pid) if next_comm=="cyclictest"' >> $TRIGGER2 |
40 | echo 'hist:keys=next_pid if next_comm=="cyclictest"' >> $TRIGGER2 | 28 | echo 'hist:keys=next_pid if next_comm=="cyclictest"' >> $TRIGGER2 |
41 | 29 | ||
42 | do_reset | ||
43 | |||
44 | exit 0 | 30 | exit 0 |
diff --git a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-action-hist.tc b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-action-hist.tc index e84e7d048566..39fb65b0cd9f 100644 --- a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-action-hist.tc +++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-action-hist.tc | |||
@@ -1,14 +1,7 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | # description: event trigger - test inter-event histogram trigger onmatch action | 2 | # description: event trigger - test inter-event histogram trigger onmatch action |
3 | 3 | ||
4 | do_reset() { | ||
5 | reset_trigger | ||
6 | echo > set_event | ||
7 | clear_trace | ||
8 | } | ||
9 | |||
10 | fail() { #msg | 4 | fail() { #msg |
11 | do_reset | ||
12 | echo $1 | 5 | echo $1 |
13 | exit_fail | 6 | exit_fail |
14 | } | 7 | } |
@@ -23,10 +16,6 @@ if [ ! -f synthetic_events ]; then | |||
23 | exit_unsupported | 16 | exit_unsupported |
24 | fi | 17 | fi |
25 | 18 | ||
26 | clear_synthetic_events | ||
27 | reset_tracer | ||
28 | do_reset | ||
29 | |||
30 | echo "Test create synthetic event" | 19 | echo "Test create synthetic event" |
31 | 20 | ||
32 | echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events | 21 | echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events |
@@ -40,11 +29,10 @@ echo "Test histogram variables,simple expression support and onmatch action" | |||
40 | echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' > events/sched/sched_wakeup/trigger | 29 | echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' > events/sched/sched_wakeup/trigger |
41 | echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0:onmatch(sched.sched_wakeup).wakeup_latency($wakeup_lat,next_pid,next_comm) if next_comm=="ping"' > events/sched/sched_switch/trigger | 30 | echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0:onmatch(sched.sched_wakeup).wakeup_latency($wakeup_lat,next_pid,next_comm) if next_comm=="ping"' > events/sched/sched_switch/trigger |
42 | echo 'hist:keys=comm,pid,lat:wakeup_lat=lat:sort=lat' > events/synthetic/wakeup_latency/trigger | 31 | echo 'hist:keys=comm,pid,lat:wakeup_lat=lat:sort=lat' > events/synthetic/wakeup_latency/trigger |
43 | ping localhost -c 5 | 32 | |
33 | ping $LOCALHOST -c 5 | ||
44 | if ! grep -q "ping" events/synthetic/wakeup_latency/hist; then | 34 | if ! grep -q "ping" events/synthetic/wakeup_latency/hist; then |
45 | fail "Failed to create onmatch action inter-event histogram" | 35 | fail "Failed to create onmatch action inter-event histogram" |
46 | fi | 36 | fi |
47 | 37 | ||
48 | do_reset | ||
49 | |||
50 | exit 0 | 38 | exit 0 |
diff --git a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-onmax-action-hist.tc b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-onmax-action-hist.tc index 7907d8aacde3..81ab3939c96a 100644 --- a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-onmax-action-hist.tc +++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-onmax-action-hist.tc | |||
@@ -1,14 +1,7 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | # description: event trigger - test inter-event histogram trigger onmatch-onmax action | 2 | # description: event trigger - test inter-event histogram trigger onmatch-onmax action |
3 | 3 | ||
4 | do_reset() { | ||
5 | reset_trigger | ||
6 | echo > set_event | ||
7 | clear_trace | ||
8 | } | ||
9 | |||
10 | fail() { #msg | 4 | fail() { #msg |
11 | do_reset | ||
12 | echo $1 | 5 | echo $1 |
13 | exit_fail | 6 | exit_fail |
14 | } | 7 | } |
@@ -23,10 +16,6 @@ if [ ! -f synthetic_events ]; then | |||
23 | exit_unsupported | 16 | exit_unsupported |
24 | fi | 17 | fi |
25 | 18 | ||
26 | clear_synthetic_events | ||
27 | reset_tracer | ||
28 | do_reset | ||
29 | |||
30 | echo "Test create synthetic event" | 19 | echo "Test create synthetic event" |
31 | 20 | ||
32 | echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events | 21 | echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events |
@@ -40,11 +29,10 @@ echo "Test histogram variables,simple expression support and onmatch-onmax actio | |||
40 | echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' > events/sched/sched_wakeup/trigger | 29 | echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' > events/sched/sched_wakeup/trigger |
41 | echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0:onmatch(sched.sched_wakeup).wakeup_latency($wakeup_lat,next_pid,next_comm):onmax($wakeup_lat).save(next_comm,prev_pid,prev_prio,prev_comm) if next_comm=="ping"' >> events/sched/sched_switch/trigger | 30 | echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0:onmatch(sched.sched_wakeup).wakeup_latency($wakeup_lat,next_pid,next_comm):onmax($wakeup_lat).save(next_comm,prev_pid,prev_prio,prev_comm) if next_comm=="ping"' >> events/sched/sched_switch/trigger |
42 | echo 'hist:keys=comm,pid,lat:wakeup_lat=lat:sort=lat' > events/synthetic/wakeup_latency/trigger | 31 | echo 'hist:keys=comm,pid,lat:wakeup_lat=lat:sort=lat' > events/synthetic/wakeup_latency/trigger |
43 | ping localhost -c 5 | 32 | |
33 | ping $LOCALHOST -c 5 | ||
44 | if [ ! grep -q "ping" events/synthetic/wakeup_latency/hist -o ! grep -q "max:" events/sched/sched_switch/hist]; then | 34 | if [ ! grep -q "ping" events/synthetic/wakeup_latency/hist -o ! grep -q "max:" events/sched/sched_switch/hist]; then |
45 | fail "Failed to create onmatch-onmax action inter-event histogram" | 35 | fail "Failed to create onmatch-onmax action inter-event histogram" |
46 | fi | 36 | fi |
47 | 37 | ||
48 | do_reset | ||
49 | |||
50 | exit 0 | 38 | exit 0 |
diff --git a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmax-action-hist.tc b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmax-action-hist.tc index 38b7ed6242b2..1180ab5f0845 100644 --- a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmax-action-hist.tc +++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmax-action-hist.tc | |||
@@ -1,14 +1,7 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | # description: event trigger - test inter-event histogram trigger onmax action | 2 | # description: event trigger - test inter-event histogram trigger onmax action |
3 | 3 | ||
4 | do_reset() { | ||
5 | reset_trigger | ||
6 | echo > set_event | ||
7 | clear_trace | ||
8 | } | ||
9 | |||
10 | fail() { #msg | 4 | fail() { #msg |
11 | do_reset | ||
12 | echo $1 | 5 | echo $1 |
13 | exit_fail | 6 | exit_fail |
14 | } | 7 | } |
@@ -23,10 +16,6 @@ if [ ! -f synthetic_events ]; then | |||
23 | exit_unsupported | 16 | exit_unsupported |
24 | fi | 17 | fi |
25 | 18 | ||
26 | clear_synthetic_events | ||
27 | reset_tracer | ||
28 | do_reset | ||
29 | |||
30 | echo "Test create synthetic event" | 19 | echo "Test create synthetic event" |
31 | 20 | ||
32 | echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events | 21 | echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events |
@@ -38,11 +27,10 @@ echo "Test onmax action" | |||
38 | 27 | ||
39 | echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' >> events/sched/sched_waking/trigger | 28 | echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' >> events/sched/sched_waking/trigger |
40 | echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0:onmax($wakeup_lat).save(next_comm,prev_pid,prev_prio,prev_comm) if next_comm=="ping"' >> events/sched/sched_switch/trigger | 29 | echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0:onmax($wakeup_lat).save(next_comm,prev_pid,prev_prio,prev_comm) if next_comm=="ping"' >> events/sched/sched_switch/trigger |
41 | ping localhost -c 3 | 30 | |
31 | ping $LOCALHOST -c 3 | ||
42 | if ! grep -q "max:" events/sched/sched_switch/hist; then | 32 | if ! grep -q "max:" events/sched/sched_switch/hist; then |
43 | fail "Failed to create onmax action inter-event histogram" | 33 | fail "Failed to create onmax action inter-event histogram" |
44 | fi | 34 | fi |
45 | 35 | ||
46 | do_reset | ||
47 | |||
48 | exit 0 | 36 | exit 0 |
diff --git a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-synthetic-event-createremove.tc b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-synthetic-event-createremove.tc index cef11377dcbd..8d647fb572dd 100644 --- a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-synthetic-event-createremove.tc +++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-synthetic-event-createremove.tc | |||
@@ -1,13 +1,7 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | # description: event trigger - test synthetic event create remove | 2 | # description: event trigger - test synthetic event create remove |
3 | do_reset() { | ||
4 | reset_trigger | ||
5 | echo > set_event | ||
6 | clear_trace | ||
7 | } | ||
8 | 3 | ||
9 | fail() { #msg | 4 | fail() { #msg |
10 | do_reset | ||
11 | echo $1 | 5 | echo $1 |
12 | exit_fail | 6 | exit_fail |
13 | } | 7 | } |
@@ -22,10 +16,6 @@ if [ ! -f synthetic_events ]; then | |||
22 | exit_unsupported | 16 | exit_unsupported |
23 | fi | 17 | fi |
24 | 18 | ||
25 | clear_synthetic_events | ||
26 | reset_tracer | ||
27 | do_reset | ||
28 | |||
29 | echo "Test create synthetic event" | 19 | echo "Test create synthetic event" |
30 | 20 | ||
31 | echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events | 21 | echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events |
@@ -49,6 +39,4 @@ if [ -d events/synthetic/wakeup_latency ]; then | |||
49 | fail "Failed to delete wakeup_latency synthetic event" | 39 | fail "Failed to delete wakeup_latency synthetic event" |
50 | fi | 40 | fi |
51 | 41 | ||
52 | do_reset | ||
53 | |||
54 | exit 0 | 42 | exit 0 |
diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-eventonoff.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-eventonoff.tc index 28cc355a3a7b..eddb51e1fbf7 100644 --- a/tools/testing/selftests/ftrace/test.d/trigger/trigger-eventonoff.tc +++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-eventonoff.tc | |||
@@ -3,14 +3,7 @@ | |||
3 | # description: event trigger - test event enable/disable trigger | 3 | # description: event trigger - test event enable/disable trigger |
4 | # flags: instance | 4 | # flags: instance |
5 | 5 | ||
6 | do_reset() { | ||
7 | reset_trigger | ||
8 | echo > set_event | ||
9 | clear_trace | ||
10 | } | ||
11 | |||
12 | fail() { #msg | 6 | fail() { #msg |
13 | do_reset | ||
14 | echo $1 | 7 | echo $1 |
15 | exit_fail | 8 | exit_fail |
16 | } | 9 | } |
@@ -25,9 +18,6 @@ if [ ! -f events/sched/sched_process_fork/trigger ]; then | |||
25 | exit_unsupported | 18 | exit_unsupported |
26 | fi | 19 | fi |
27 | 20 | ||
28 | reset_tracer | ||
29 | do_reset | ||
30 | |||
31 | FEATURE=`grep enable_event events/sched/sched_process_fork/trigger` | 21 | FEATURE=`grep enable_event events/sched/sched_process_fork/trigger` |
32 | if [ -z "$FEATURE" ]; then | 22 | if [ -z "$FEATURE" ]; then |
33 | echo "event enable/disable trigger is not supported" | 23 | echo "event enable/disable trigger is not supported" |
@@ -61,6 +51,4 @@ echo 'enable_event:sched:sched_switch' > events/sched/sched_process_fork/trigger | |||
61 | ! echo 'enable_event:sched:sched_switch' > events/sched/sched_process_fork/trigger | 51 | ! echo 'enable_event:sched:sched_switch' > events/sched/sched_process_fork/trigger |
62 | ! echo 'disable_event:sched:sched_switch' > events/sched/sched_process_fork/trigger | 52 | ! echo 'disable_event:sched:sched_switch' > events/sched/sched_process_fork/trigger |
63 | 53 | ||
64 | do_reset | ||
65 | |||
66 | exit 0 | 54 | exit 0 |
diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-filter.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-filter.tc index a48e23eb8a8b..2dcc2296ebdd 100644 --- a/tools/testing/selftests/ftrace/test.d/trigger/trigger-filter.tc +++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-filter.tc | |||
@@ -3,14 +3,7 @@ | |||
3 | # description: event trigger - test trigger filter | 3 | # description: event trigger - test trigger filter |
4 | # flags: instance | 4 | # flags: instance |
5 | 5 | ||
6 | do_reset() { | ||
7 | reset_trigger | ||
8 | echo > set_event | ||
9 | clear_trace | ||
10 | } | ||
11 | |||
12 | fail() { #msg | 6 | fail() { #msg |
13 | do_reset | ||
14 | echo $1 | 7 | echo $1 |
15 | exit_fail | 8 | exit_fail |
16 | } | 9 | } |
@@ -25,9 +18,6 @@ if [ ! -f events/sched/sched_process_fork/trigger ]; then | |||
25 | exit_unsupported | 18 | exit_unsupported |
26 | fi | 19 | fi |
27 | 20 | ||
28 | reset_tracer | ||
29 | do_reset | ||
30 | |||
31 | echo "Test trigger filter" | 21 | echo "Test trigger filter" |
32 | echo 1 > tracing_on | 22 | echo 1 > tracing_on |
33 | echo 'traceoff if child_pid == 0' > events/sched/sched_process_fork/trigger | 23 | echo 'traceoff if child_pid == 0' > events/sched/sched_process_fork/trigger |
@@ -54,8 +44,4 @@ echo '!traceoff' > events/sched/sched_process_fork/trigger | |||
54 | echo 'traceoff if parent_pid >= 0 || child_pid >= 0' > events/sched/sched_process_fork/trigger | 44 | echo 'traceoff if parent_pid >= 0 || child_pid >= 0' > events/sched/sched_process_fork/trigger |
55 | echo '!traceoff' > events/sched/sched_process_fork/trigger | 45 | echo '!traceoff' > events/sched/sched_process_fork/trigger |
56 | 46 | ||
57 | |||
58 | |||
59 | do_reset | ||
60 | |||
61 | exit 0 | 47 | exit 0 |
diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-mod.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-mod.tc index 8da80efc44d8..fab4431639d3 100644 --- a/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-mod.tc +++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-mod.tc | |||
@@ -3,14 +3,7 @@ | |||
3 | # description: event trigger - test histogram modifiers | 3 | # description: event trigger - test histogram modifiers |
4 | # flags: instance | 4 | # flags: instance |
5 | 5 | ||
6 | do_reset() { | ||
7 | reset_trigger | ||
8 | echo > set_event | ||
9 | clear_trace | ||
10 | } | ||
11 | |||
12 | fail() { #msg | 6 | fail() { #msg |
13 | do_reset | ||
14 | echo $1 | 7 | echo $1 |
15 | exit_fail | 8 | exit_fail |
16 | } | 9 | } |
@@ -30,9 +23,6 @@ if [ ! -f events/sched/sched_process_fork/hist ]; then | |||
30 | exit_unsupported | 23 | exit_unsupported |
31 | fi | 24 | fi |
32 | 25 | ||
33 | reset_tracer | ||
34 | do_reset | ||
35 | |||
36 | echo "Test histogram with execname modifier" | 26 | echo "Test histogram with execname modifier" |
37 | 27 | ||
38 | echo 'hist:keys=common_pid.execname' > events/sched/sched_process_fork/trigger | 28 | echo 'hist:keys=common_pid.execname' > events/sched/sched_process_fork/trigger |
@@ -71,6 +61,4 @@ for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done | |||
71 | grep 'bytes_req: ~ 2^[0-9]*' events/kmem/kmalloc/hist > /dev/null || \ | 61 | grep 'bytes_req: ~ 2^[0-9]*' events/kmem/kmalloc/hist > /dev/null || \ |
72 | fail "log2 modifier on kmem/kmalloc did not work" | 62 | fail "log2 modifier on kmem/kmalloc did not work" |
73 | 63 | ||
74 | do_reset | ||
75 | |||
76 | exit 0 | 64 | exit 0 |
diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist.tc index 449fe9ff91a2..177e8d4c4744 100644 --- a/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist.tc +++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist.tc | |||
@@ -3,14 +3,7 @@ | |||
3 | # description: event trigger - test histogram trigger | 3 | # description: event trigger - test histogram trigger |
4 | # flags: instance | 4 | # flags: instance |
5 | 5 | ||
6 | do_reset() { | ||
7 | reset_trigger | ||
8 | echo > set_event | ||
9 | clear_trace | ||
10 | } | ||
11 | |||
12 | fail() { #msg | 6 | fail() { #msg |
13 | do_reset | ||
14 | echo $1 | 7 | echo $1 |
15 | exit_fail | 8 | exit_fail |
16 | } | 9 | } |
@@ -30,9 +23,6 @@ if [ ! -f events/sched/sched_process_fork/hist ]; then | |||
30 | exit_unsupported | 23 | exit_unsupported |
31 | fi | 24 | fi |
32 | 25 | ||
33 | reset_tracer | ||
34 | do_reset | ||
35 | |||
36 | echo "Test histogram basic tigger" | 26 | echo "Test histogram basic tigger" |
37 | 27 | ||
38 | echo 'hist:keys=parent_pid:vals=child_pid' > events/sched/sched_process_fork/trigger | 28 | echo 'hist:keys=parent_pid:vals=child_pid' > events/sched/sched_process_fork/trigger |
@@ -79,6 +69,4 @@ check_inc `grep -o "child_pid:[[:space:]]*[[:digit:]]*" \ | |||
79 | events/sched/sched_process_fork/hist | cut -d: -f2 ` || | 69 | events/sched/sched_process_fork/hist | cut -d: -f2 ` || |
80 | fail "sort param on sched_process_fork did not work" | 70 | fail "sort param on sched_process_fork did not work" |
81 | 71 | ||
82 | do_reset | ||
83 | |||
84 | exit 0 | 72 | exit 0 |
diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-multihist.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-multihist.tc index c5ef8b9d02b3..18fdaab9f570 100644 --- a/tools/testing/selftests/ftrace/test.d/trigger/trigger-multihist.tc +++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-multihist.tc | |||
@@ -3,14 +3,7 @@ | |||
3 | # description: event trigger - test multiple histogram triggers | 3 | # description: event trigger - test multiple histogram triggers |
4 | # flags: instance | 4 | # flags: instance |
5 | 5 | ||
6 | do_reset() { | ||
7 | reset_trigger | ||
8 | echo > set_event | ||
9 | clear_trace | ||
10 | } | ||
11 | |||
12 | fail() { #msg | 6 | fail() { #msg |
13 | do_reset | ||
14 | echo $1 | 7 | echo $1 |
15 | exit_fail | 8 | exit_fail |
16 | } | 9 | } |
@@ -30,11 +23,6 @@ if [ ! -f events/sched/sched_process_fork/hist ]; then | |||
30 | exit_unsupported | 23 | exit_unsupported |
31 | fi | 24 | fi |
32 | 25 | ||
33 | reset_tracer | ||
34 | do_reset | ||
35 | |||
36 | reset_trigger | ||
37 | |||
38 | echo "Test histogram multiple tiggers" | 26 | echo "Test histogram multiple tiggers" |
39 | 27 | ||
40 | echo 'hist:keys=parent_pid:vals=child_pid' > events/sched/sched_process_fork/trigger | 28 | echo 'hist:keys=parent_pid:vals=child_pid' > events/sched/sched_process_fork/trigger |
@@ -67,8 +55,4 @@ grep test_hist events/sched/sched_process_exit/hist > /dev/null || \ | |||
67 | diffs=`diff events/sched/sched_process_exit/hist events/sched/sched_process_fork/hist | wc -l` | 55 | diffs=`diff events/sched/sched_process_exit/hist events/sched/sched_process_fork/hist | wc -l` |
68 | test $diffs -eq 0 || fail "Same name histograms are not same" | 56 | test $diffs -eq 0 || fail "Same name histograms are not same" |
69 | 57 | ||
70 | reset_trigger | ||
71 | |||
72 | do_reset | ||
73 | |||
74 | exit 0 | 58 | exit 0 |
diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-snapshot.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-snapshot.tc index ed38f0050d77..7717c0a09686 100644 --- a/tools/testing/selftests/ftrace/test.d/trigger/trigger-snapshot.tc +++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-snapshot.tc | |||
@@ -2,14 +2,7 @@ | |||
2 | # SPDX-License-Identifier: GPL-2.0 | 2 | # SPDX-License-Identifier: GPL-2.0 |
3 | # description: event trigger - test snapshot-trigger | 3 | # description: event trigger - test snapshot-trigger |
4 | 4 | ||
5 | do_reset() { | ||
6 | reset_trigger | ||
7 | echo > set_event | ||
8 | clear_trace | ||
9 | } | ||
10 | |||
11 | fail() { #msg | 5 | fail() { #msg |
12 | do_reset | ||
13 | echo $1 | 6 | echo $1 |
14 | exit_fail | 7 | exit_fail |
15 | } | 8 | } |
@@ -29,9 +22,6 @@ if [ ! -f snapshot ]; then | |||
29 | exit_unsupported | 22 | exit_unsupported |
30 | fi | 23 | fi |
31 | 24 | ||
32 | reset_tracer | ||
33 | do_reset | ||
34 | |||
35 | FEATURE=`grep snapshot events/sched/sched_process_fork/trigger` | 25 | FEATURE=`grep snapshot events/sched/sched_process_fork/trigger` |
36 | if [ -z "$FEATURE" ]; then | 26 | if [ -z "$FEATURE" ]; then |
37 | echo "snapshot trigger is not supported" | 27 | echo "snapshot trigger is not supported" |
@@ -57,6 +47,4 @@ echo "Test snapshot semantic errors" | |||
57 | echo "snapshot" > events/sched/sched_process_fork/trigger | 47 | echo "snapshot" > events/sched/sched_process_fork/trigger |
58 | ! echo "snapshot" > events/sched/sched_process_fork/trigger | 48 | ! echo "snapshot" > events/sched/sched_process_fork/trigger |
59 | 49 | ||
60 | do_reset | ||
61 | |||
62 | exit 0 | 50 | exit 0 |
diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-stacktrace.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-stacktrace.tc index 3121d795a868..398c05c4d2a7 100644 --- a/tools/testing/selftests/ftrace/test.d/trigger/trigger-stacktrace.tc +++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-stacktrace.tc | |||
@@ -2,14 +2,7 @@ | |||
2 | # SPDX-License-Identifier: GPL-2.0 | 2 | # SPDX-License-Identifier: GPL-2.0 |
3 | # description: event trigger - test stacktrace-trigger | 3 | # description: event trigger - test stacktrace-trigger |
4 | 4 | ||
5 | do_reset() { | ||
6 | reset_trigger | ||
7 | echo > set_event | ||
8 | clear_trace | ||
9 | } | ||
10 | |||
11 | fail() { #msg | 5 | fail() { #msg |
12 | do_reset | ||
13 | echo $1 | 6 | echo $1 |
14 | exit_fail | 7 | exit_fail |
15 | } | 8 | } |
@@ -24,9 +17,6 @@ if [ ! -f events/sched/sched_process_fork/trigger ]; then | |||
24 | exit_unsupported | 17 | exit_unsupported |
25 | fi | 18 | fi |
26 | 19 | ||
27 | reset_tracer | ||
28 | do_reset | ||
29 | |||
30 | FEATURE=`grep stacktrace events/sched/sched_process_fork/trigger` | 20 | FEATURE=`grep stacktrace events/sched/sched_process_fork/trigger` |
31 | if [ -z "$FEATURE" ]; then | 21 | if [ -z "$FEATURE" ]; then |
32 | echo "stacktrace trigger is not supported" | 22 | echo "stacktrace trigger is not supported" |
@@ -49,6 +39,4 @@ echo "Test stacktrace semantic errors" | |||
49 | echo "stacktrace" > events/sched/sched_process_fork/trigger | 39 | echo "stacktrace" > events/sched/sched_process_fork/trigger |
50 | ! echo "stacktrace" > events/sched/sched_process_fork/trigger | 40 | ! echo "stacktrace" > events/sched/sched_process_fork/trigger |
51 | 41 | ||
52 | do_reset | ||
53 | |||
54 | exit 0 | 42 | exit 0 |
diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-hist.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-hist.tc index 2acbfe2c0c0c..ab6bedb25736 100644 --- a/tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-hist.tc +++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-hist.tc | |||
@@ -3,14 +3,7 @@ | |||
3 | # description: trace_marker trigger - test histogram trigger | 3 | # description: trace_marker trigger - test histogram trigger |
4 | # flags: instance | 4 | # flags: instance |
5 | 5 | ||
6 | do_reset() { | ||
7 | reset_trigger | ||
8 | echo > set_event | ||
9 | clear_trace | ||
10 | } | ||
11 | |||
12 | fail() { #msg | 6 | fail() { #msg |
13 | do_reset | ||
14 | echo $1 | 7 | echo $1 |
15 | exit_fail | 8 | exit_fail |
16 | } | 9 | } |
@@ -35,8 +28,6 @@ if [ ! -f events/ftrace/print/hist ]; then | |||
35 | exit_unsupported | 28 | exit_unsupported |
36 | fi | 29 | fi |
37 | 30 | ||
38 | do_reset | ||
39 | |||
40 | echo "Test histogram trace_marker tigger" | 31 | echo "Test histogram trace_marker tigger" |
41 | 32 | ||
42 | echo 'hist:keys=common_pid' > events/ftrace/print/trigger | 33 | echo 'hist:keys=common_pid' > events/ftrace/print/trigger |
@@ -44,6 +35,4 @@ for i in `seq 1 10` ; do echo "hello" > trace_marker; done | |||
44 | grep 'hitcount: *10$' events/ftrace/print/hist > /dev/null || \ | 35 | grep 'hitcount: *10$' events/ftrace/print/hist > /dev/null || \ |
45 | fail "hist trigger did not trigger correct times on trace_marker" | 36 | fail "hist trigger did not trigger correct times on trace_marker" |
46 | 37 | ||
47 | do_reset | ||
48 | |||
49 | exit 0 | 38 | exit 0 |
diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-snapshot.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-snapshot.tc index 6748e8cb42d0..df246e505af7 100644 --- a/tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-snapshot.tc +++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-snapshot.tc | |||
@@ -3,15 +3,7 @@ | |||
3 | # description: trace_marker trigger - test snapshot trigger | 3 | # description: trace_marker trigger - test snapshot trigger |
4 | # flags: instance | 4 | # flags: instance |
5 | 5 | ||
6 | do_reset() { | ||
7 | reset_trigger | ||
8 | echo > set_event | ||
9 | echo 0 > snapshot | ||
10 | clear_trace | ||
11 | } | ||
12 | |||
13 | fail() { #msg | 6 | fail() { #msg |
14 | do_reset | ||
15 | echo $1 | 7 | echo $1 |
16 | exit_fail | 8 | exit_fail |
17 | } | 9 | } |
@@ -47,15 +39,13 @@ test_trace() { | |||
47 | fi | 39 | fi |
48 | echo "testing $line for >$x<" | 40 | echo "testing $line for >$x<" |
49 | match=`echo $line | sed -e "s/>$x<//"` | 41 | match=`echo $line | sed -e "s/>$x<//"` |
50 | if [ "$line" == "$match" ]; then | 42 | if [ "$line" = "$match" ]; then |
51 | fail "$line does not have >$x< in it" | 43 | fail "$line does not have >$x< in it" |
52 | fi | 44 | fi |
53 | let x=$x+2 | 45 | x=$((x+2)) |
54 | done | 46 | done |
55 | } | 47 | } |
56 | 48 | ||
57 | do_reset | ||
58 | |||
59 | echo "Test snapshot trace_marker tigger" | 49 | echo "Test snapshot trace_marker tigger" |
60 | 50 | ||
61 | echo 'snapshot' > events/ftrace/print/trigger | 51 | echo 'snapshot' > events/ftrace/print/trigger |
@@ -69,6 +59,4 @@ for i in `seq 1 10` ; do echo "hello >$i<" > trace_marker; done | |||
69 | test_trace trace 1 | 59 | test_trace trace 1 |
70 | test_trace snapshot 2 | 60 | test_trace snapshot 2 |
71 | 61 | ||
72 | do_reset | ||
73 | |||
74 | exit 0 | 62 | exit 0 |
diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-synthetic-kernel.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-synthetic-kernel.tc index 0a69c5d1cda8..18b4d1c2807e 100644 --- a/tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-synthetic-kernel.tc +++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-synthetic-kernel.tc | |||
@@ -3,15 +3,7 @@ | |||
3 | # description: trace_marker trigger - test histogram with synthetic event against kernel event | 3 | # description: trace_marker trigger - test histogram with synthetic event against kernel event |
4 | # flags: | 4 | # flags: |
5 | 5 | ||
6 | do_reset() { | ||
7 | reset_trigger | ||
8 | echo > set_event | ||
9 | echo > synthetic_events | ||
10 | clear_trace | ||
11 | } | ||
12 | |||
13 | fail() { #msg | 6 | fail() { #msg |
14 | do_reset | ||
15 | echo $1 | 7 | echo $1 |
16 | exit_fail | 8 | exit_fail |
17 | } | 9 | } |
@@ -46,8 +38,6 @@ if [ ! -f events/ftrace/print/hist ]; then | |||
46 | exit_unsupported | 38 | exit_unsupported |
47 | fi | 39 | fi |
48 | 40 | ||
49 | do_reset | ||
50 | |||
51 | echo "Test histogram kernel event to trace_marker latency histogram trigger" | 41 | echo "Test histogram kernel event to trace_marker latency histogram trigger" |
52 | 42 | ||
53 | echo 'latency u64 lat' > synthetic_events | 43 | echo 'latency u64 lat' > synthetic_events |
@@ -63,6 +53,4 @@ grep 'hitcount: *1$' events/ftrace/print/hist > /dev/null || \ | |||
63 | grep 'hitcount: *1$' events/synthetic/latency/hist > /dev/null || \ | 53 | grep 'hitcount: *1$' events/synthetic/latency/hist > /dev/null || \ |
64 | fail "hist trigger did not trigger " | 54 | fail "hist trigger did not trigger " |
65 | 55 | ||
66 | do_reset | ||
67 | |||
68 | exit 0 | 56 | exit 0 |
diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-synthetic.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-synthetic.tc index 3666dd6ab02a..dd262d6d0db6 100644 --- a/tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-synthetic.tc +++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-synthetic.tc | |||
@@ -3,15 +3,7 @@ | |||
3 | # description: trace_marker trigger - test histogram with synthetic event | 3 | # description: trace_marker trigger - test histogram with synthetic event |
4 | # flags: | 4 | # flags: |
5 | 5 | ||
6 | do_reset() { | ||
7 | reset_trigger | ||
8 | echo > set_event | ||
9 | echo > synthetic_events | ||
10 | clear_trace | ||
11 | } | ||
12 | |||
13 | fail() { #msg | 6 | fail() { #msg |
14 | do_reset | ||
15 | echo $1 | 7 | echo $1 |
16 | exit_fail | 8 | exit_fail |
17 | } | 9 | } |
@@ -41,8 +33,6 @@ if [ ! -f events/ftrace/print/hist ]; then | |||
41 | exit_unsupported | 33 | exit_unsupported |
42 | fi | 34 | fi |
43 | 35 | ||
44 | do_reset | ||
45 | |||
46 | echo "Test histogram trace_marker to trace_marker latency histogram trigger" | 36 | echo "Test histogram trace_marker to trace_marker latency histogram trigger" |
47 | 37 | ||
48 | echo 'latency u64 lat' > synthetic_events | 38 | echo 'latency u64 lat' > synthetic_events |
@@ -61,6 +51,4 @@ fi | |||
61 | grep 'hitcount: *1$' events/synthetic/latency/hist > /dev/null || \ | 51 | grep 'hitcount: *1$' events/synthetic/latency/hist > /dev/null || \ |
62 | fail "hist trigger did not trigger " | 52 | fail "hist trigger did not trigger " |
63 | 53 | ||
64 | do_reset | ||
65 | |||
66 | exit 0 | 54 | exit 0 |
diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-traceonoff.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-traceonoff.tc index c59d9eb546da..d5d2dcbc9cab 100644 --- a/tools/testing/selftests/ftrace/test.d/trigger/trigger-traceonoff.tc +++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-traceonoff.tc | |||
@@ -2,14 +2,7 @@ | |||
2 | # SPDX-License-Identifier: GPL-2.0 | 2 | # SPDX-License-Identifier: GPL-2.0 |
3 | # description: event trigger - test traceon/off trigger | 3 | # description: event trigger - test traceon/off trigger |
4 | 4 | ||
5 | do_reset() { | ||
6 | reset_trigger | ||
7 | echo > set_event | ||
8 | clear_trace | ||
9 | } | ||
10 | |||
11 | fail() { #msg | 5 | fail() { #msg |
12 | do_reset | ||
13 | echo $1 | 6 | echo $1 |
14 | exit_fail | 7 | exit_fail |
15 | } | 8 | } |
@@ -24,9 +17,6 @@ if [ ! -f events/sched/sched_process_fork/trigger ]; then | |||
24 | exit_unsupported | 17 | exit_unsupported |
25 | fi | 18 | fi |
26 | 19 | ||
27 | reset_tracer | ||
28 | do_reset | ||
29 | |||
30 | echo "Test traceoff trigger" | 20 | echo "Test traceoff trigger" |
31 | echo 1 > tracing_on | 21 | echo 1 > tracing_on |
32 | echo 'traceoff' > events/sched/sched_process_fork/trigger | 22 | echo 'traceoff' > events/sched/sched_process_fork/trigger |
@@ -54,6 +44,4 @@ echo 'traceon' > events/sched/sched_process_fork/trigger | |||
54 | ! echo 'traceon' > events/sched/sched_process_fork/trigger | 44 | ! echo 'traceon' > events/sched/sched_process_fork/trigger |
55 | ! echo 'traceoff' > events/sched/sched_process_fork/trigger | 45 | ! echo 'traceoff' > events/sched/sched_process_fork/trigger |
56 | 46 | ||
57 | do_reset | ||
58 | |||
59 | exit 0 | 47 | exit 0 |
diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile index 4665cdbf1a8d..46648427d537 100644 --- a/tools/testing/selftests/gpio/Makefile +++ b/tools/testing/selftests/gpio/Makefile | |||
@@ -1,28 +1,26 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | 1 | # SPDX-License-Identifier: GPL-2.0 |
2 | 2 | ||
3 | CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/ | ||
4 | LDLIBS += -lmount -I/usr/include/libmount | ||
5 | |||
3 | TEST_PROGS := gpio-mockup.sh | 6 | TEST_PROGS := gpio-mockup.sh |
4 | TEST_FILES := gpio-mockup-sysfs.sh $(BINARIES) | 7 | TEST_FILES := gpio-mockup-sysfs.sh |
5 | BINARIES := gpio-mockup-chardev | 8 | TEST_PROGS_EXTENDED := gpio-mockup-chardev |
6 | EXTRA_PROGS := ../gpiogpio-event-mon ../gpiogpio-hammer ../gpiolsgpio | 9 | |
7 | EXTRA_DIRS := ../gpioinclude/ | 10 | GPIODIR := $(realpath ../../../gpio) |
8 | EXTRA_OBJS := ../gpiogpio-event-mon-in.o ../gpiogpio-event-mon.o | 11 | GPIOOBJ := gpio-utils.o |
9 | EXTRA_OBJS += ../gpiogpio-hammer-in.o ../gpiogpio-utils.o ../gpiolsgpio-in.o | ||
10 | EXTRA_OBJS += ../gpiolsgpio.o | ||
11 | 12 | ||
12 | include ../lib.mk | 13 | include ../lib.mk |
13 | 14 | ||
14 | all: $(BINARIES) | 15 | all: $(TEST_PROGS_EXTENDED) |
15 | 16 | ||
16 | override define CLEAN | 17 | override define CLEAN |
17 | $(RM) $(BINARIES) $(EXTRA_PROGS) $(EXTRA_OBJS) | 18 | $(RM) $(TEST_PROGS_EXTENDED) |
18 | $(RM) -r $(EXTRA_DIRS) | 19 | $(MAKE) -C $(GPIODIR) OUTPUT=$(GPIODIR)/ clean |
19 | endef | 20 | endef |
20 | 21 | ||
21 | CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/ | 22 | $(TEST_PROGS_EXTENDED):| khdr |
22 | LDLIBS += -lmount -I/usr/include/libmount | 23 | $(TEST_PROGS_EXTENDED): $(GPIODIR)/$(GPIOOBJ) |
23 | |||
24 | $(BINARIES):| khdr | ||
25 | $(BINARIES): ../../../gpio/gpio-utils.o | ||
26 | 24 | ||
27 | ../../../gpio/gpio-utils.o: | 25 | $(GPIODIR)/$(GPIOOBJ): |
28 | make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio | 26 | $(MAKE) OUTPUT=$(GPIODIR)/ -C $(GPIODIR) |
diff --git a/tools/testing/selftests/kvm/dirty_log_test.c b/tools/testing/selftests/kvm/dirty_log_test.c index d59820cc2d39..aeff95a91b15 100644 --- a/tools/testing/selftests/kvm/dirty_log_test.c +++ b/tools/testing/selftests/kvm/dirty_log_test.c | |||
@@ -33,10 +33,10 @@ | |||
33 | #define TEST_PAGES_PER_LOOP 1024 | 33 | #define TEST_PAGES_PER_LOOP 1024 |
34 | 34 | ||
35 | /* How many host loops to run (one KVM_GET_DIRTY_LOG for each loop) */ | 35 | /* How many host loops to run (one KVM_GET_DIRTY_LOG for each loop) */ |
36 | #define TEST_HOST_LOOP_N 32 | 36 | #define TEST_HOST_LOOP_N 32UL |
37 | 37 | ||
38 | /* Interval for each host loop (ms) */ | 38 | /* Interval for each host loop (ms) */ |
39 | #define TEST_HOST_LOOP_INTERVAL 10 | 39 | #define TEST_HOST_LOOP_INTERVAL 10UL |
40 | 40 | ||
41 | /* | 41 | /* |
42 | * Guest/Host shared variables. Ensure addr_gva2hva() and/or | 42 | * Guest/Host shared variables. Ensure addr_gva2hva() and/or |
diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c index 8c06da4f03db..1b41e71283d5 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c | |||
@@ -128,7 +128,7 @@ struct kvm_vm *vm_create(enum vm_guest_mode mode, uint64_t phy_pages, int perm) | |||
128 | int kvm_fd; | 128 | int kvm_fd; |
129 | 129 | ||
130 | vm = calloc(1, sizeof(*vm)); | 130 | vm = calloc(1, sizeof(*vm)); |
131 | TEST_ASSERT(vm != NULL, "Insufficent Memory"); | 131 | TEST_ASSERT(vm != NULL, "Insufficient Memory"); |
132 | 132 | ||
133 | vm->mode = mode; | 133 | vm->mode = mode; |
134 | vm_open(vm, perm); | 134 | vm_open(vm, perm); |
diff --git a/tools/testing/selftests/proc/fd-001-lookup.c b/tools/testing/selftests/proc/fd-001-lookup.c index a2010dfb2110..60d7948e7124 100644 --- a/tools/testing/selftests/proc/fd-001-lookup.c +++ b/tools/testing/selftests/proc/fd-001-lookup.c | |||
@@ -14,7 +14,7 @@ | |||
14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
15 | */ | 15 | */ |
16 | // Test /proc/*/fd lookup. | 16 | // Test /proc/*/fd lookup. |
17 | #define _GNU_SOURCE | 17 | |
18 | #undef NDEBUG | 18 | #undef NDEBUG |
19 | #include <assert.h> | 19 | #include <assert.h> |
20 | #include <dirent.h> | 20 | #include <dirent.h> |
diff --git a/tools/testing/selftests/proc/fd-003-kthread.c b/tools/testing/selftests/proc/fd-003-kthread.c index 1d659d55368c..dc591f97b63d 100644 --- a/tools/testing/selftests/proc/fd-003-kthread.c +++ b/tools/testing/selftests/proc/fd-003-kthread.c | |||
@@ -14,7 +14,7 @@ | |||
14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
15 | */ | 15 | */ |
16 | // Test that /proc/$KERNEL_THREAD/fd/ is empty. | 16 | // Test that /proc/$KERNEL_THREAD/fd/ is empty. |
17 | #define _GNU_SOURCE | 17 | |
18 | #undef NDEBUG | 18 | #undef NDEBUG |
19 | #include <sys/syscall.h> | 19 | #include <sys/syscall.h> |
20 | #include <assert.h> | 20 | #include <assert.h> |
diff --git a/tools/testing/selftests/watchdog/watchdog-test.c b/tools/testing/selftests/watchdog/watchdog-test.c index 6e290874b70e..c6bd9a68306b 100644 --- a/tools/testing/selftests/watchdog/watchdog-test.c +++ b/tools/testing/selftests/watchdog/watchdog-test.c | |||
@@ -19,7 +19,7 @@ | |||
19 | 19 | ||
20 | int fd; | 20 | int fd; |
21 | const char v = 'V'; | 21 | const char v = 'V'; |
22 | static const char sopts[] = "bdehp:t:"; | 22 | static const char sopts[] = "bdehp:t:Tn:N"; |
23 | static const struct option lopts[] = { | 23 | static const struct option lopts[] = { |
24 | {"bootstatus", no_argument, NULL, 'b'}, | 24 | {"bootstatus", no_argument, NULL, 'b'}, |
25 | {"disable", no_argument, NULL, 'd'}, | 25 | {"disable", no_argument, NULL, 'd'}, |
@@ -27,6 +27,9 @@ static const struct option lopts[] = { | |||
27 | {"help", no_argument, NULL, 'h'}, | 27 | {"help", no_argument, NULL, 'h'}, |
28 | {"pingrate", required_argument, NULL, 'p'}, | 28 | {"pingrate", required_argument, NULL, 'p'}, |
29 | {"timeout", required_argument, NULL, 't'}, | 29 | {"timeout", required_argument, NULL, 't'}, |
30 | {"gettimeout", no_argument, NULL, 'T'}, | ||
31 | {"pretimeout", required_argument, NULL, 'n'}, | ||
32 | {"getpretimeout", no_argument, NULL, 'N'}, | ||
30 | {NULL, no_argument, NULL, 0x0} | 33 | {NULL, no_argument, NULL, 0x0} |
31 | }; | 34 | }; |
32 | 35 | ||
@@ -71,9 +74,13 @@ static void usage(char *progname) | |||
71 | printf(" -h, --help Print the help message\n"); | 74 | printf(" -h, --help Print the help message\n"); |
72 | printf(" -p, --pingrate=P Set ping rate to P seconds (default %d)\n", DEFAULT_PING_RATE); | 75 | printf(" -p, --pingrate=P Set ping rate to P seconds (default %d)\n", DEFAULT_PING_RATE); |
73 | printf(" -t, --timeout=T Set timeout to T seconds\n"); | 76 | printf(" -t, --timeout=T Set timeout to T seconds\n"); |
77 | printf(" -T, --gettimeout Get the timeout\n"); | ||
78 | printf(" -n, --pretimeout=T Set the pretimeout to T seconds\n"); | ||
79 | printf(" -N, --getpretimeout Get the pretimeout\n"); | ||
74 | printf("\n"); | 80 | printf("\n"); |
75 | printf("Parameters are parsed left-to-right in real-time.\n"); | 81 | printf("Parameters are parsed left-to-right in real-time.\n"); |
76 | printf("Example: %s -d -t 10 -p 5 -e\n", progname); | 82 | printf("Example: %s -d -t 10 -p 5 -e\n", progname); |
83 | printf("Example: %s -t 12 -T -n 7 -N\n", progname); | ||
77 | } | 84 | } |
78 | 85 | ||
79 | int main(int argc, char *argv[]) | 86 | int main(int argc, char *argv[]) |
@@ -89,7 +96,13 @@ int main(int argc, char *argv[]) | |||
89 | fd = open("/dev/watchdog", O_WRONLY); | 96 | fd = open("/dev/watchdog", O_WRONLY); |
90 | 97 | ||
91 | if (fd == -1) { | 98 | if (fd == -1) { |
92 | printf("Watchdog device not enabled.\n"); | 99 | if (errno == ENOENT) |
100 | printf("Watchdog device not enabled.\n"); | ||
101 | else if (errno == EACCES) | ||
102 | printf("Run watchdog as root.\n"); | ||
103 | else | ||
104 | printf("Watchdog device open failed %s\n", | ||
105 | strerror(errno)); | ||
93 | exit(-1); | 106 | exit(-1); |
94 | } | 107 | } |
95 | 108 | ||
@@ -103,23 +116,27 @@ int main(int argc, char *argv[]) | |||
103 | printf("Last boot is caused by: %s.\n", (flags != 0) ? | 116 | printf("Last boot is caused by: %s.\n", (flags != 0) ? |
104 | "Watchdog" : "Power-On-Reset"); | 117 | "Watchdog" : "Power-On-Reset"); |
105 | else | 118 | else |
106 | printf("WDIOC_GETBOOTSTATUS errno '%s'\n", strerror(errno)); | 119 | printf("WDIOC_GETBOOTSTATUS error '%s'\n", strerror(errno)); |
107 | break; | 120 | break; |
108 | case 'd': | 121 | case 'd': |
109 | flags = WDIOS_DISABLECARD; | 122 | flags = WDIOS_DISABLECARD; |
110 | ret = ioctl(fd, WDIOC_SETOPTIONS, &flags); | 123 | ret = ioctl(fd, WDIOC_SETOPTIONS, &flags); |
111 | if (!ret) | 124 | if (!ret) |
112 | printf("Watchdog card disabled.\n"); | 125 | printf("Watchdog card disabled.\n"); |
113 | else | 126 | else { |
114 | printf("WDIOS_DISABLECARD errno '%s'\n", strerror(errno)); | 127 | printf("WDIOS_DISABLECARD error '%s'\n", strerror(errno)); |
128 | oneshot = 1; | ||
129 | } | ||
115 | break; | 130 | break; |
116 | case 'e': | 131 | case 'e': |
117 | flags = WDIOS_ENABLECARD; | 132 | flags = WDIOS_ENABLECARD; |
118 | ret = ioctl(fd, WDIOC_SETOPTIONS, &flags); | 133 | ret = ioctl(fd, WDIOC_SETOPTIONS, &flags); |
119 | if (!ret) | 134 | if (!ret) |
120 | printf("Watchdog card enabled.\n"); | 135 | printf("Watchdog card enabled.\n"); |
121 | else | 136 | else { |
122 | printf("WDIOS_ENABLECARD errno '%s'\n", strerror(errno)); | 137 | printf("WDIOS_ENABLECARD error '%s'\n", strerror(errno)); |
138 | oneshot = 1; | ||
139 | } | ||
123 | break; | 140 | break; |
124 | case 'p': | 141 | case 'p': |
125 | ping_rate = strtoul(optarg, NULL, 0); | 142 | ping_rate = strtoul(optarg, NULL, 0); |
@@ -132,8 +149,36 @@ int main(int argc, char *argv[]) | |||
132 | ret = ioctl(fd, WDIOC_SETTIMEOUT, &flags); | 149 | ret = ioctl(fd, WDIOC_SETTIMEOUT, &flags); |
133 | if (!ret) | 150 | if (!ret) |
134 | printf("Watchdog timeout set to %u seconds.\n", flags); | 151 | printf("Watchdog timeout set to %u seconds.\n", flags); |
152 | else { | ||
153 | printf("WDIOC_SETTIMEOUT error '%s'\n", strerror(errno)); | ||
154 | oneshot = 1; | ||
155 | } | ||
156 | break; | ||
157 | case 'T': | ||
158 | oneshot = 1; | ||
159 | ret = ioctl(fd, WDIOC_GETTIMEOUT, &flags); | ||
160 | if (!ret) | ||
161 | printf("WDIOC_GETTIMEOUT returns %u seconds.\n", flags); | ||
162 | else | ||
163 | printf("WDIOC_GETTIMEOUT error '%s'\n", strerror(errno)); | ||
164 | break; | ||
165 | case 'n': | ||
166 | flags = strtoul(optarg, NULL, 0); | ||
167 | ret = ioctl(fd, WDIOC_SETPRETIMEOUT, &flags); | ||
168 | if (!ret) | ||
169 | printf("Watchdog pretimeout set to %u seconds.\n", flags); | ||
170 | else { | ||
171 | printf("WDIOC_SETPRETIMEOUT error '%s'\n", strerror(errno)); | ||
172 | oneshot = 1; | ||
173 | } | ||
174 | break; | ||
175 | case 'N': | ||
176 | oneshot = 1; | ||
177 | ret = ioctl(fd, WDIOC_GETPRETIMEOUT, &flags); | ||
178 | if (!ret) | ||
179 | printf("WDIOC_GETPRETIMEOUT returns %u seconds.\n", flags); | ||
135 | else | 180 | else |
136 | printf("WDIOC_SETTIMEOUT errno '%s'\n", strerror(errno)); | 181 | printf("WDIOC_GETPRETIMEOUT error '%s'\n", strerror(errno)); |
137 | break; | 182 | break; |
138 | default: | 183 | default: |
139 | usage(argv[0]); | 184 | usage(argv[0]); |