selftests/ftrace: Fix synthetic event test to delete event correctly
[muen/linux.git] / tools / testing / selftests / ftrace / test.d / trigger / inter-event / trigger-synthetic-event-createremove.tc
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 remove synthetic event"
39 echo '!wakeup_latency  u64 lat pid_t pid char comm[16]' >> synthetic_events
40 if [ -d events/synthetic/wakeup_latency ]; then
41     fail "Failed to delete wakeup_latency synthetic event"
42 fi
43
44 reset_trigger
45
46 echo "Test create synthetic event with an error"
47 echo 'wakeup_latency  u64 lat pid_t pid char' > synthetic_events > /dev/null
48 if [ -d events/synthetic/wakeup_latency ]; then
49     fail "Created wakeup_latency synthetic event with an invalid format"
50 fi
51
52 do_reset
53
54 exit 0