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