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