1#!/bin/sh 2# description: event trigger - test histogram modifiers 3 4do_reset() { 5 reset_trigger 6 echo > set_event 7 clear_trace 8} 9 10fail() { #msg 11 do_reset 12 echo $1 13 exit $FAIL 14} 15 16if [ ! -f set_event -o ! -d events/sched ]; then 17 echo "event tracing is not supported" 18 exit_unsupported 19fi 20 21if [ ! -f events/sched/sched_process_fork/trigger ]; then 22 echo "event trigger is not supported" 23 exit_unsupported 24fi 25 26reset_tracer 27do_reset 28 29FEATURE=`grep hist events/sched/sched_process_fork/trigger` 30if [ -z "$FEATURE" ]; then 31 echo "hist trigger is not supported" 32 exit_unsupported 33fi 34 35echo "Test histogram with execname modifier" 36 37echo 'hist:keys=common_pid.execname' > events/sched/sched_process_fork/trigger 38for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done 39COMM=`cat /proc/$$/comm` 40grep "common_pid: $COMM" events/sched/sched_process_fork/hist > /dev/null || \ 41 fail "execname modifier on sched_process_fork did not work" 42 43reset_trigger 44 45echo "Test histogram with hex modifier" 46 47echo 'hist:keys=parent_pid.hex' > events/sched/sched_process_fork/trigger 48for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done 49# Note that $$ is the parent pid. $PID is current PID. 50HEX=`printf %x $PID` 51grep "parent_pid: $HEX" events/sched/sched_process_fork/hist > /dev/null || \ 52 fail "hex modifier on sched_process_fork did not work" 53 54reset_trigger 55 56echo "Test histogram with syscall modifier" 57 58echo 'hist:keys=id.syscall' > events/raw_syscalls/sys_exit/trigger 59for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done 60grep "id: sys_" events/raw_syscalls/sys_exit/hist > /dev/null || \ 61 fail "syscall modifier on raw_syscalls/sys_exit did not work" 62 63 64reset_trigger 65 66echo "Test histgram with log2 modifier" 67 68echo 'hist:keys=bytes_req.log2' > events/kmem/kmalloc/trigger 69for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done 70grep 'bytes_req: ~ 2^[0-9]*' events/kmem/kmalloc/hist > /dev/null || \ 71 fail "log2 modifier on kmem/kmalloc did not work" 72 73do_reset 74 75exit 0 76