diff options
Diffstat (limited to 'tools')
8 files changed, 360 insertions, 0 deletions
diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions index df3dd7fe5f9b..2a4f16fc9819 100644 --- a/tools/testing/selftests/ftrace/test.d/functions +++ b/tools/testing/selftests/ftrace/test.d/functions | |||
@@ -59,6 +59,13 @@ disable_events() { | |||
59 | echo 0 > events/enable | 59 | echo 0 > events/enable |
60 | } | 60 | } |
61 | 61 | ||
62 | clear_synthetic_events() { # reset all current synthetic events | ||
63 | grep -v ^# synthetic_events | | ||
64 | while read line; do | ||
65 | echo "!$line" >> synthetic_events | ||
66 | done | ||
67 | } | ||
68 | |||
62 | initialize_ftrace() { # Reset ftrace to initial-state | 69 | initialize_ftrace() { # Reset ftrace to initial-state |
63 | # As the initial state, ftrace will be set to nop tracer, | 70 | # As the initial state, ftrace will be set to nop tracer, |
64 | # no events, no triggers, no filters, no function filters, | 71 | # no events, no triggers, no filters, no function filters, |
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 new file mode 100644 index 000000000000..786dce7e48be --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-extended-error-support.tc | |||
@@ -0,0 +1,39 @@ | |||
1 | #!/bin/sh | ||
2 | # description: event trigger - test extended error support | ||
3 | |||
4 | |||
5 | do_reset() { | ||
6 | reset_trigger | ||
7 | echo > set_event | ||
8 | clear_trace | ||
9 | } | ||
10 | |||
11 | fail() { #msg | ||
12 | do_reset | ||
13 | echo $1 | ||
14 | exit_fail | ||
15 | } | ||
16 | |||
17 | if [ ! -f set_event ]; then | ||
18 | echo "event tracing is not supported" | ||
19 | exit_unsupported | ||
20 | fi | ||
21 | |||
22 | if [ ! -f synthetic_events ]; then | ||
23 | echo "synthetic event is not supported" | ||
24 | exit_unsupported | ||
25 | fi | ||
26 | |||
27 | reset_tracer | ||
28 | do_reset | ||
29 | |||
30 | echo "Test extended error support" | ||
31 | 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 &>/dev/null | ||
33 | if ! grep -q "ERROR:" events/sched/sched_wakeup/hist; then | ||
34 | fail "Failed to generate extended error in histogram" | ||
35 | fi | ||
36 | |||
37 | do_reset | ||
38 | |||
39 | 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 new file mode 100644 index 000000000000..7fd5b4a8f060 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-field-variable-support.tc | |||
@@ -0,0 +1,54 @@ | |||
1 | #!/bin/sh | ||
2 | # description: event trigger - test field variable support | ||
3 | |||
4 | do_reset() { | ||
5 | reset_trigger | ||
6 | echo > set_event | ||
7 | clear_trace | ||
8 | } | ||
9 | |||
10 | fail() { #msg | ||
11 | do_reset | ||
12 | echo $1 | ||
13 | exit_fail | ||
14 | } | ||
15 | |||
16 | if [ ! -f set_event ]; then | ||
17 | echo "event tracing is not supported" | ||
18 | exit_unsupported | ||
19 | fi | ||
20 | |||
21 | if [ ! -f synthetic_events ]; then | ||
22 | echo "synthetic event is not supported" | ||
23 | exit_unsupported | ||
24 | fi | ||
25 | |||
26 | clear_synthetic_events | ||
27 | reset_tracer | ||
28 | do_reset | ||
29 | |||
30 | echo "Test field variable support" | ||
31 | |||
32 | echo 'wakeup_latency u64 lat; pid_t pid; int prio; char comm[16]' > synthetic_events | ||
33 | echo 'hist:keys=comm:ts0=common_timestamp.usecs if comm=="ping"' > events/sched/sched_waking/trigger | ||
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 | ||
35 | echo 'hist:keys=pid,prio,comm:vals=lat:sort=pid,prio' > events/synthetic/wakeup_latency/trigger | ||
36 | |||
37 | ping localhost -c 3 | ||
38 | if ! grep -q "ping" events/synthetic/wakeup_latency/hist; then | ||
39 | fail "Failed to create inter-event histogram" | ||
40 | fi | ||
41 | |||
42 | if ! grep -q "synthetic_prio=prio" events/sched/sched_waking/hist; then | ||
43 | fail "Failed to create histogram with field variable" | ||
44 | fi | ||
45 | |||
46 | 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 | ||
47 | |||
48 | if grep -q "synthetic_prio=prio" events/sched/sched_waking/hist; then | ||
49 | fail "Failed to remove histogram with field variable" | ||
50 | fi | ||
51 | |||
52 | do_reset | ||
53 | |||
54 | 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 new file mode 100644 index 000000000000..c93dbe38b5df --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-inter-event-combined-hist.tc | |||
@@ -0,0 +1,58 @@ | |||
1 | #!/bin/sh | ||
2 | # description: event trigger - test inter-event combined histogram trigger | ||
3 | |||
4 | do_reset() { | ||
5 | reset_trigger | ||
6 | echo > set_event | ||
7 | clear_trace | ||
8 | } | ||
9 | |||
10 | fail() { #msg | ||
11 | do_reset | ||
12 | echo $1 | ||
13 | exit_fail | ||
14 | } | ||
15 | |||
16 | if [ ! -f set_event ]; then | ||
17 | echo "event tracing is not supported" | ||
18 | exit_unsupported | ||
19 | fi | ||
20 | |||
21 | if [ ! -f synthetic_events ]; then | ||
22 | echo "synthetic event is not supported" | ||
23 | exit_unsupported | ||
24 | fi | ||
25 | |||
26 | reset_tracer | ||
27 | do_reset | ||
28 | clear_synthetic_events | ||
29 | |||
30 | echo "Test create synthetic event" | ||
31 | |||
32 | echo 'waking_latency u64 lat pid_t pid' > synthetic_events | ||
33 | if [ ! -d events/synthetic/waking_latency ]; then | ||
34 | fail "Failed to create waking_latency synthetic event" | ||
35 | fi | ||
36 | |||
37 | echo "Test combined histogram" | ||
38 | |||
39 | echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' > events/sched/sched_waking/trigger | ||
40 | echo 'hist:keys=pid:waking_lat=common_timestamp.usecs-$ts0:onmatch(sched.sched_waking).waking_latency($waking_lat,pid) if comm=="ping"' > events/sched/sched_wakeup/trigger | ||
41 | echo 'hist:keys=pid,lat:sort=pid,lat' > events/synthetic/waking_latency/trigger | ||
42 | |||
43 | echo 'wakeup_latency u64 lat pid_t pid' >> synthetic_events | ||
44 | echo 'hist:keys=pid:ts1=common_timestamp.usecs if comm=="ping"' >> events/sched/sched_wakeup/trigger | ||
45 | echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts1:onmatch(sched.sched_wakeup).wakeup_latency($wakeup_lat,next_pid) if next_comm=="ping"' > events/sched/sched_switch/trigger | ||
46 | |||
47 | 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 | ||
49 | echo 'hist:keys=pid,lat:sort=pid,lat' >> events/synthetic/waking+wakeup_latency/trigger | ||
50 | |||
51 | ping localhost -c 3 | ||
52 | if ! grep -q "pid:" events/synthetic/waking+wakeup_latency/hist; then | ||
53 | fail "Failed to create combined histogram" | ||
54 | fi | ||
55 | |||
56 | do_reset | ||
57 | |||
58 | 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 new file mode 100644 index 000000000000..e84e7d048566 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-action-hist.tc | |||
@@ -0,0 +1,50 @@ | |||
1 | #!/bin/sh | ||
2 | # description: event trigger - test inter-event histogram trigger onmatch action | ||
3 | |||
4 | do_reset() { | ||
5 | reset_trigger | ||
6 | echo > set_event | ||
7 | clear_trace | ||
8 | } | ||
9 | |||
10 | fail() { #msg | ||
11 | do_reset | ||
12 | echo $1 | ||
13 | exit_fail | ||
14 | } | ||
15 | |||
16 | if [ ! -f set_event ]; then | ||
17 | echo "event tracing is not supported" | ||
18 | exit_unsupported | ||
19 | fi | ||
20 | |||
21 | if [ ! -f synthetic_events ]; then | ||
22 | echo "synthetic event is not supported" | ||
23 | exit_unsupported | ||
24 | fi | ||
25 | |||
26 | clear_synthetic_events | ||
27 | reset_tracer | ||
28 | do_reset | ||
29 | |||
30 | echo "Test create synthetic event" | ||
31 | |||
32 | echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events | ||
33 | if [ ! -d events/synthetic/wakeup_latency ]; then | ||
34 | fail "Failed to create wakeup_latency synthetic event" | ||
35 | fi | ||
36 | |||
37 | echo "Test create histogram for synthetic event" | ||
38 | echo "Test histogram variables,simple expression support and onmatch action" | ||
39 | |||
40 | 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 | ||
42 | echo 'hist:keys=comm,pid,lat:wakeup_lat=lat:sort=lat' > events/synthetic/wakeup_latency/trigger | ||
43 | ping localhost -c 5 | ||
44 | if ! grep -q "ping" events/synthetic/wakeup_latency/hist; then | ||
45 | fail "Failed to create onmatch action inter-event histogram" | ||
46 | fi | ||
47 | |||
48 | do_reset | ||
49 | |||
50 | 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 new file mode 100644 index 000000000000..7907d8aacde3 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-onmax-action-hist.tc | |||
@@ -0,0 +1,50 @@ | |||
1 | #!/bin/sh | ||
2 | # description: event trigger - test inter-event histogram trigger onmatch-onmax action | ||
3 | |||
4 | do_reset() { | ||
5 | reset_trigger | ||
6 | echo > set_event | ||
7 | clear_trace | ||
8 | } | ||
9 | |||
10 | fail() { #msg | ||
11 | do_reset | ||
12 | echo $1 | ||
13 | exit_fail | ||
14 | } | ||
15 | |||
16 | if [ ! -f set_event ]; then | ||
17 | echo "event tracing is not supported" | ||
18 | exit_unsupported | ||
19 | fi | ||
20 | |||
21 | if [ ! -f synthetic_events ]; then | ||
22 | echo "synthetic event is not supported" | ||
23 | exit_unsupported | ||
24 | fi | ||
25 | |||
26 | clear_synthetic_events | ||
27 | reset_tracer | ||
28 | do_reset | ||
29 | |||
30 | echo "Test create synthetic event" | ||
31 | |||
32 | echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events | ||
33 | if [ ! -d events/synthetic/wakeup_latency ]; then | ||
34 | fail "Failed to create wakeup_latency synthetic event" | ||
35 | fi | ||
36 | |||
37 | echo "Test create histogram for synthetic event" | ||
38 | echo "Test histogram variables,simple expression support and onmatch-onmax action" | ||
39 | |||
40 | 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 | ||
42 | echo 'hist:keys=comm,pid,lat:wakeup_lat=lat:sort=lat' > events/synthetic/wakeup_latency/trigger | ||
43 | ping localhost -c 5 | ||
44 | 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" | ||
46 | fi | ||
47 | |||
48 | do_reset | ||
49 | |||
50 | 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 new file mode 100644 index 000000000000..38b7ed6242b2 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmax-action-hist.tc | |||
@@ -0,0 +1,48 @@ | |||
1 | #!/bin/sh | ||
2 | # description: event trigger - test inter-event histogram trigger onmax action | ||
3 | |||
4 | do_reset() { | ||
5 | reset_trigger | ||
6 | echo > set_event | ||
7 | clear_trace | ||
8 | } | ||
9 | |||
10 | fail() { #msg | ||
11 | do_reset | ||
12 | echo $1 | ||
13 | exit_fail | ||
14 | } | ||
15 | |||
16 | if [ ! -f set_event ]; then | ||
17 | echo "event tracing is not supported" | ||
18 | exit_unsupported | ||
19 | fi | ||
20 | |||
21 | if [ ! -f synthetic_events ]; then | ||
22 | echo "synthetic event is not supported" | ||
23 | exit_unsupported | ||
24 | fi | ||
25 | |||
26 | clear_synthetic_events | ||
27 | reset_tracer | ||
28 | do_reset | ||
29 | |||
30 | echo "Test create synthetic event" | ||
31 | |||
32 | echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events | ||
33 | if [ ! -d events/synthetic/wakeup_latency ]; then | ||
34 | fail "Failed to create wakeup_latency synthetic event" | ||
35 | fi | ||
36 | |||
37 | echo "Test onmax action" | ||
38 | |||
39 | 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 | ||
41 | ping localhost -c 3 | ||
42 | if ! grep -q "max:" events/sched/sched_switch/hist; then | ||
43 | fail "Failed to create onmax action inter-event histogram" | ||
44 | fi | ||
45 | |||
46 | do_reset | ||
47 | |||
48 | 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 new file mode 100644 index 000000000000..cef11377dcbd --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-synthetic-event-createremove.tc | |||
@@ -0,0 +1,54 @@ | |||
1 | #!/bin/sh | ||
2 | # description: event trigger - test synthetic event create remove | ||
3 | do_reset() { | ||
4 | reset_trigger | ||
5 | echo > set_event | ||
6 | clear_trace | ||
7 | } | ||
8 | |||
9 | fail() { #msg | ||
10 | do_reset | ||
11 | echo $1 | ||
12 | exit_fail | ||
13 | } | ||
14 | |||
15 | if [ ! -f set_event ]; then | ||
16 | echo "event tracing is not supported" | ||
17 | exit_unsupported | ||
18 | fi | ||
19 | |||
20 | if [ ! -f synthetic_events ]; then | ||
21 | echo "synthetic event is not supported" | ||
22 | exit_unsupported | ||
23 | fi | ||
24 | |||
25 | clear_synthetic_events | ||
26 | reset_tracer | ||
27 | do_reset | ||
28 | |||
29 | echo "Test create synthetic event" | ||
30 | |||
31 | echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events | ||
32 | if [ ! -d events/synthetic/wakeup_latency ]; then | ||
33 | fail "Failed to create wakeup_latency synthetic event" | ||
34 | fi | ||
35 | |||
36 | reset_trigger | ||
37 | |||
38 | echo "Test create synthetic event with an error" | ||
39 | echo 'wakeup_latency u64 lat pid_t pid char' > synthetic_events > /dev/null | ||
40 | if [ -d events/synthetic/wakeup_latency ]; then | ||
41 | fail "Created wakeup_latency synthetic event with an invalid format" | ||
42 | fi | ||
43 | |||
44 | reset_trigger | ||
45 | |||
46 | echo "Test remove synthetic event" | ||
47 | echo '!wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events | ||
48 | if [ -d events/synthetic/wakeup_latency ]; then | ||
49 | fail "Failed to delete wakeup_latency synthetic event" | ||
50 | fi | ||
51 | |||
52 | do_reset | ||
53 | |||
54 | exit 0 | ||