• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3# description: event trigger - test histogram trigger
4# flags: instance
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
28if [ ! -f events/sched/sched_process_fork/hist ]; then
29    echo "hist trigger is not supported"
30    exit_unsupported
31fi
32
33reset_tracer
34do_reset
35
36echo "Test histogram basic tigger"
37
38echo 'hist:keys=parent_pid:vals=child_pid' > events/sched/sched_process_fork/trigger
39for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done
40grep parent_pid events/sched/sched_process_fork/hist > /dev/null || \
41    fail "hist trigger on sched_process_fork did not work"
42grep child events/sched/sched_process_fork/hist > /dev/null || \
43    fail "hist trigger on sched_process_fork did not work"
44
45reset_trigger
46
47echo "Test histogram with compound keys"
48
49echo 'hist:keys=parent_pid,child_pid' > events/sched/sched_process_fork/trigger
50for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done
51grep '^{ parent_pid:.*, child_pid:.*}' events/sched/sched_process_fork/hist > /dev/null || \
52    fail "compound keys on sched_process_fork did not work"
53
54reset_trigger
55
56echo "Test histogram with string key"
57
58echo 'hist:keys=parent_comm' > events/sched/sched_process_fork/trigger
59for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done
60COMM=`cat /proc/$$/comm`
61grep "parent_comm: $COMM" events/sched/sched_process_fork/hist > /dev/null || \
62    fail "string key on sched_process_fork did not work"
63
64reset_trigger
65
66echo "Test histogram with sort key"
67
68echo 'hist:keys=parent_pid,child_pid:sort=child_pid.ascending' > events/sched/sched_process_fork/trigger
69for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done
70
71check_inc() {
72    while [ $# -gt 1 ]; do
73        [ $1 -gt $2 ] && return 1
74        shift 1
75    done
76    return 0
77}
78check_inc `grep -o "child_pid:[[:space:]]*[[:digit:]]*" \
79    events/sched/sched_process_fork/hist | cut -d: -f2 ` ||
80    fail "sort param on sched_process_fork did not work"
81
82do_reset
83
84exit 0
85