]>
Commit | Line | Data |
---|---|---|
76929ab5 | 1 | #!/bin/sh |
b2441318 | 2 | # SPDX-License-Identifier: GPL-2.0 |
76929ab5 | 3 | # description: event trigger - test histogram modifiers |
ca2958f1 | 4 | # flags: instance |
76929ab5 MH |
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 | ||
0ded5174 | 28 | if [ ! -f events/sched/sched_process_fork/hist ]; then |
76929ab5 MH |
29 | echo "hist trigger is not supported" |
30 | exit_unsupported | |
31 | fi | |
32 | ||
0ded5174 SRRH |
33 | reset_tracer |
34 | do_reset | |
35 | ||
76929ab5 MH |
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 | |
780ade55 | 61 | grep "id: \(unknown_\|sys_\)" events/raw_syscalls/sys_exit/hist > /dev/null || \ |
76929ab5 MH |
62 | fail "syscall modifier on raw_syscalls/sys_exit did not work" |
63 | ||
93c5f671 MH |
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 | ||
76929ab5 MH |
74 | do_reset |
75 | ||
76 | exit 0 |