WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / ftrace / test.d / event / event-no-pid.tc
blobe6eb78f0b95459956c97117b12974d6cab0663b8
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 echo 0 > options/event-fork
62 do_reset
64 read mypid rest < /proc/self/stat
66 echo $mypid > set_event_notrace_pid
67 grep -q $mypid set_event_notrace_pid
69 enable_events
71 yield
73 echo 0 > tracing_on
75 cnt=`count_pid $mypid`
76 if [ $cnt -ne 0 ]; then
77 fail "Filtered out task has events"
80 cnt=`count_no_pid $mypid`
81 if [ $cnt -eq 0 ]; then
82 fail "No other events were recorded"
85 do_reset
87 echo $mypid > set_event_notrace_pid
88 echo 1 > options/event-fork
90 enable_events
92 yield &
93 child=$!
94 echo "child = $child"
95 wait $child
97 echo 0 > tracing_on
99 cnt=`count_pid $mypid`
100 if [ $cnt -ne 0 ]; then
101 fail "Filtered out task has events"
104 cnt=`count_pid $child`
105 if [ $cnt -ne 0 ]; then
106 fail "Child of filtered out taskhas events"
109 cnt=`count_no_pid $mypid`
110 if [ $cnt -eq 0 ]; then
111 fail "No other events were recorded"
114 do_reset
116 exit 0