blob: 4237b32769f14552c9f0ca9ee16357c95fc52345 [file] [log] [blame]
Masami Hiramatsu76929ab2016-03-03 12:55:01 -06001#!/bin/sh
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01002# SPDX-License-Identifier: GPL-2.0
Masami Hiramatsu76929ab2016-03-03 12:55:01 -06003# description: event trigger - test histogram modifiers
Steven Rostedt (VMware)ca2958f2017-04-20 14:20:19 -04004# flags: instance
Masami Hiramatsu76929ab2016-03-03 12:55:01 -06005
6do_reset() {
7 reset_trigger
8 echo > set_event
9 clear_trace
10}
11
12fail() { #msg
13 do_reset
14 echo $1
15 exit $FAIL
16}
17
18if [ ! -f set_event -o ! -d events/sched ]; then
19 echo "event tracing is not supported"
20 exit_unsupported
21fi
22
23if [ ! -f events/sched/sched_process_fork/trigger ]; then
24 echo "event trigger is not supported"
25 exit_unsupported
26fi
27
Steven Rostedt (Red Hat)0ded5172016-05-23 15:06:30 -040028if [ ! -f events/sched/sched_process_fork/hist ]; then
Masami Hiramatsu76929ab2016-03-03 12:55:01 -060029 echo "hist trigger is not supported"
30 exit_unsupported
31fi
32
Steven Rostedt (Red Hat)0ded5172016-05-23 15:06:30 -040033reset_tracer
34do_reset
35
Masami Hiramatsu76929ab2016-03-03 12:55:01 -060036echo "Test histogram with execname modifier"
37
38echo 'hist:keys=common_pid.execname' > events/sched/sched_process_fork/trigger
39for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done
40COMM=`cat /proc/$$/comm`
41grep "common_pid: $COMM" events/sched/sched_process_fork/hist > /dev/null || \
42 fail "execname modifier on sched_process_fork did not work"
43
44reset_trigger
45
46echo "Test histogram with hex modifier"
47
48echo 'hist:keys=parent_pid.hex' > events/sched/sched_process_fork/trigger
49for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done
50# Note that $$ is the parent pid. $PID is current PID.
51HEX=`printf %x $PID`
52grep "parent_pid: $HEX" events/sched/sched_process_fork/hist > /dev/null || \
53 fail "hex modifier on sched_process_fork did not work"
54
55reset_trigger
56
57echo "Test histogram with syscall modifier"
58
59echo 'hist:keys=id.syscall' > events/raw_syscalls/sys_exit/trigger
60for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done
Masami Hiramatsu780ade52016-11-16 17:13:47 +090061grep "id: \(unknown_\|sys_\)" events/raw_syscalls/sys_exit/hist > /dev/null || \
Masami Hiramatsu76929ab2016-03-03 12:55:01 -060062 fail "syscall modifier on raw_syscalls/sys_exit did not work"
63
Masami Hiramatsu93c5f672016-03-03 12:55:03 -060064
65reset_trigger
66
67echo "Test histgram with log2 modifier"
68
69echo 'hist:keys=bytes_req.log2' > events/kmem/kmalloc/trigger
70for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done
71grep 'bytes_req: ~ 2^[0-9]*' events/kmem/kmalloc/hist > /dev/null || \
72 fail "log2 modifier on kmem/kmalloc did not work"
73
Masami Hiramatsu76929ab2016-03-03 12:55:01 -060074do_reset
75
76exit 0