1#!/bin/sh 2# description: event tracing - restricts events based on pid 3 4do_reset() { 5 echo > set_event 6 echo > set_event_pid 7 echo 0 > options/event-fork 8 clear_trace 9} 10 11fail() { #msg 12 do_reset 13 echo $1 14 exit $FAIL 15} 16 17yield() { 18 ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1 19} 20 21if [ ! -f set_event -o ! -d events/sched ]; then 22 echo "event tracing is not supported" 23 exit_unsupported 24fi 25 26if [ ! -f set_event_pid ]; then 27 echo "event pid filtering is not supported" 28 exit_unsupported 29fi 30 31reset_tracer 32do_reset 33 34echo 1 > events/sched/sched_switch/enable 35 36yield 37 38count=`cat trace | grep sched_switch | wc -l` 39if [ $count -eq 0 ]; then 40 fail "sched_switch events are not recorded" 41fi 42 43do_reset 44 45read mypid rest < /proc/self/stat 46 47echo $mypid > set_event_pid 48echo 'sched:sched_switch' > set_event 49 50yield 51 52count=`cat trace | grep sched_switch | grep -v "pid=$mypid" | wc -l` 53if [ $count -ne 0 ]; then 54 fail "sched_switch events from other task are recorded" 55fi 56 57do_reset 58 59echo $mypid > set_event_pid 60echo 1 > options/event-fork 61echo 1 > events/sched/sched_switch/enable 62 63yield 64 65count=`cat trace | grep sched_switch | grep -v "pid=$mypid" | wc -l` 66if [ $count -eq 0 ]; then 67 fail "sched_switch events from other task are not recorded" 68fi 69 70do_reset 71 72exit 0 73