drm/panel-edp: Add STA 116QHD024002
[drm/drm-misc.git] / tools / testing / selftests / ftrace / test.d / event / event-no-pid.tc
blob9933ed24f9012441b7bd28ed35ffca4e40514fc8
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0
3 # description: event tracing - restricts events based on pid notrace filtering
4 # requires: set_event events/sched set_event_pid set_event_notrace_pid
5 # flags: instance
7 do_reset() {
8 echo > set_event
9 echo > set_event_pid
10 echo > set_event_notrace_pid
11 echo 0 > options/event-fork
12 echo 0 > events/enable
13 clear_trace
14 echo 1 > tracing_on
17 fail() { #msg
18 cat trace
19 do_reset
20 echo $1
21 exit_fail
24 count_pid() {
25 pid=$@
26 cat trace | grep -v '^#' | sed -e 's/[^-]*-\([0-9]*\).*/\1/' | grep $pid | wc -l
29 count_no_pid() {
30 pid=$1
31 cat trace | grep -v '^#' | sed -e 's/[^-]*-\([0-9]*\).*/\1/' | grep -v $pid | wc -l
34 enable_system() {
35 system=$1
37 if [ -d events/$system ]; then
38 echo 1 > events/$system/enable
42 enable_events() {
43 echo 0 > tracing_on
44 # Enable common groups of events, as all events can allow for
45 # events to be traced via scheduling that we don't care to test.
46 enable_system syscalls
47 enable_system rcu
48 enable_system block
49 enable_system exceptions
50 enable_system irq
51 enable_system net
52 enable_system power
53 enable_system signal
54 enable_system sock
55 enable_system timer
56 enable_system thermal
57 echo 1 > tracing_on
60 other_task() {
61 sleep .001 || usleep 1 || sleep 1
64 echo 0 > options/event-fork
66 do_reset
68 read mypid rest < /proc/self/stat
70 echo $mypid > set_event_notrace_pid
71 grep -q $mypid set_event_notrace_pid
73 enable_events
75 yield
77 echo 0 > tracing_on
79 cnt=`count_pid $mypid`
80 if [ $cnt -ne 0 ]; then
81 fail "Filtered out task has events"
84 cnt=`count_no_pid $mypid`
85 if [ $cnt -eq 0 ]; then
86 fail "No other events were recorded"
89 do_reset
91 echo $mypid > set_event_notrace_pid
92 echo 1 > options/event-fork
94 enable_events
96 yield &
97 child=$!
98 echo "child = $child"
99 wait $child
101 # Be sure some other events will happen for small systems (e.g. 1 core)
102 other_task
104 echo 0 > tracing_on
106 cnt=`count_pid $mypid`
107 if [ $cnt -ne 0 ]; then
108 fail "Filtered out task has events"
111 cnt=`count_pid $child`
112 if [ $cnt -ne 0 ]; then
113 fail "Child of filtered out taskhas events"
116 cnt=`count_no_pid $mypid`
117 if [ $cnt -eq 0 ]; then
118 fail "No other events were recorded"
121 do_reset
123 exit 0