]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-mod.tc
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[mirror_ubuntu-bionic-kernel.git] / tools / testing / selftests / ftrace / test.d / trigger / trigger-hist-mod.tc
CommitLineData
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
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
0ded5174 28if [ ! -f events/sched/sched_process_fork/hist ]; then
76929ab5
MH
29 echo "hist trigger is not supported"
30 exit_unsupported
31fi
32
0ded5174
SRRH
33reset_tracer
34do_reset
35
76929ab5
MH
36echo "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
780ade55 61grep "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
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
76929ab5
MH
74do_reset
75
76exit 0