1#!/bin/sh 2# description: event tracing - enable/disable with top level files 3 4do_reset() { 5 echo > set_event 6 clear_trace 7} 8 9fail() { #msg 10 do_reset 11 echo $1 12 exit $FAIL 13} 14 15yield() { 16 ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1 17} 18 19if [ ! -f available_events -o ! -f set_event -o ! -d events ]; then 20 echo "event tracing is not supported" 21 exit_unsupported 22fi 23 24reset_tracer 25do_reset 26 27echo '*:*' > set_event 28 29yield 30 31echo 0 > tracing_on 32 33count=`head -n 128 trace | grep -v ^# | wc -l` 34if [ $count -eq 0 ]; then 35 fail "none of events are recorded" 36fi 37 38do_reset 39 40echo 1 > events/enable 41echo 1 > tracing_on 42 43yield 44 45echo 0 > tracing_on 46count=`head -n 128 trace | grep -v ^# | wc -l` 47if [ $count -eq 0 ]; then 48 fail "none of events are recorded" 49fi 50 51do_reset 52 53echo 0 > events/enable 54 55yield 56 57count=`cat trace | grep -v ^# | wc -l` 58if [ $count -ne 0 ]; then 59 fail "any of events should not be recorded" 60fi 61 62do_reset 63 64exit 0 65