1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0 3# description: event trigger - test histogram modifiers 4# flags: instance 5 6fail() { #msg 7 echo $1 8 exit_fail 9} 10 11if [ ! -f set_event -o ! -d events/sched ]; then 12 echo "event tracing is not supported" 13 exit_unsupported 14fi 15 16if [ ! -f events/sched/sched_process_fork/trigger ]; then 17 echo "event trigger is not supported" 18 exit_unsupported 19fi 20 21if [ ! -f events/sched/sched_process_fork/hist ]; then 22 echo "hist trigger is not supported" 23 exit_unsupported 24fi 25 26echo "Test histogram with execname modifier" 27 28echo 'hist:keys=common_pid.execname' > events/sched/sched_process_fork/trigger 29for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done 30COMM=`cat /proc/$$/comm` 31grep "common_pid: $COMM" events/sched/sched_process_fork/hist > /dev/null || \ 32 fail "execname modifier on sched_process_fork did not work" 33 34reset_trigger 35 36echo "Test histogram with hex modifier" 37 38echo 'hist:keys=parent_pid.hex' > events/sched/sched_process_fork/trigger 39for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done 40# Note that $$ is the parent pid. $PID is current PID. 41HEX=`printf %x $PID` 42grep "parent_pid: $HEX" events/sched/sched_process_fork/hist > /dev/null || \ 43 fail "hex modifier on sched_process_fork did not work" 44 45reset_trigger 46 47echo "Test histogram with syscall modifier" 48 49echo 'hist:keys=id.syscall' > events/raw_syscalls/sys_exit/trigger 50for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done 51grep "id: \(unknown_\|sys_\)" events/raw_syscalls/sys_exit/hist > /dev/null || \ 52 fail "syscall modifier on raw_syscalls/sys_exit did not work" 53 54 55reset_trigger 56 57echo "Test histgram with log2 modifier" 58 59echo 'hist:keys=bytes_req.log2' > events/kmem/kmalloc/trigger 60for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done 61grep 'bytes_req: ~ 2^[0-9]*' events/kmem/kmalloc/hist > /dev/null || \ 62 fail "log2 modifier on kmem/kmalloc did not work" 63 64exit 0 65