~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/ftrace/test.d/event/event-no-pid.tc

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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
  6 
  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
 15 }
 16 
 17 fail() { #msg
 18     cat trace
 19     do_reset
 20     echo $1
 21     exit_fail
 22 }
 23 
 24 count_pid() {
 25     pid=$@
 26     cat trace | grep -v '^#' | sed -e 's/[^-]*-\([0-9]*\).*/\1/' | grep $pid | wc -l
 27 }
 28 
 29 count_no_pid() {
 30     pid=$1
 31     cat trace | grep -v '^#' | sed -e 's/[^-]*-\([0-9]*\).*/\1/' | grep -v $pid | wc -l
 32 }
 33 
 34 enable_system() {
 35     system=$1
 36 
 37     if [ -d events/$system ]; then
 38         echo 1 > events/$system/enable
 39     fi
 40 }
 41 
 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
 58 }
 59 
 60 other_task() {
 61     sleep .001 || usleep 1 || sleep 1
 62 }
 63 
 64 echo 0 > options/event-fork
 65 
 66 do_reset
 67 
 68 read mypid rest < /proc/self/stat
 69 
 70 echo $mypid > set_event_notrace_pid
 71 grep -q $mypid set_event_notrace_pid
 72 
 73 enable_events
 74 
 75 yield
 76 
 77 echo 0 > tracing_on
 78 
 79 cnt=`count_pid $mypid`
 80 if [ $cnt -ne 0 ]; then
 81     fail "Filtered out task has events"
 82 fi
 83 
 84 cnt=`count_no_pid $mypid`
 85 if [ $cnt -eq 0 ]; then
 86     fail "No other events were recorded"
 87 fi
 88 
 89 do_reset
 90 
 91 echo $mypid > set_event_notrace_pid
 92 echo 1 > options/event-fork
 93 
 94 enable_events
 95 
 96 yield &
 97 child=$!
 98 echo "child = $child"
 99 wait $child
100 
101 # Be sure some other events will happen for small systems (e.g. 1 core)
102 other_task
103 
104 echo 0 > tracing_on
105 
106 cnt=`count_pid $mypid`
107 if [ $cnt -ne 0 ]; then
108     fail "Filtered out task has events"
109 fi
110 
111 cnt=`count_pid $child`
112 if [ $cnt -ne 0 ]; then
113     fail "Child of filtered out taskhas events"
114 fi
115 
116 cnt=`count_no_pid $mypid`
117 if [ $cnt -eq 0 ]; then
118     fail "No other events were recorded"
119 fi
120 
121 do_reset
122 
123 exit 0

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php