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