xref: /linux/tools/testing/selftests/ftrace/test.d/trigger/trigger-multihist.tc (revision 2fe05e1139a555ae91f00a812cb9520e7d3022ab)
1#!/bin/sh
2# description: event trigger - test multiple histogram triggers
3# flags: instance
4
5do_reset() {
6    reset_trigger
7    echo > set_event
8    clear_trace
9}
10
11fail() { #msg
12    do_reset
13    echo $1
14    exit $FAIL
15}
16
17if [ ! -f set_event -o ! -d events/sched ]; then
18    echo "event tracing is not supported"
19    exit_unsupported
20fi
21
22if [ ! -f events/sched/sched_process_fork/trigger ]; then
23    echo "event trigger is not supported"
24    exit_unsupported
25fi
26
27if [ ! -f events/sched/sched_process_fork/hist ]; then
28    echo "hist trigger is not supported"
29    exit_unsupported
30fi
31
32reset_tracer
33do_reset
34
35reset_trigger
36
37echo "Test histogram multiple tiggers"
38
39echo 'hist:keys=parent_pid:vals=child_pid' > events/sched/sched_process_fork/trigger
40echo 'hist:keys=parent_comm:vals=child_pid' >> events/sched/sched_process_fork/trigger
41for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done
42grep parent_pid events/sched/sched_process_fork/hist > /dev/null || \
43    fail "hist trigger on sched_process_fork did not work"
44grep child events/sched/sched_process_fork/hist > /dev/null || \
45    fail "hist trigger on sched_process_fork did not work"
46COMM=`cat /proc/$$/comm`
47grep "parent_comm: $COMM" events/sched/sched_process_fork/hist > /dev/null || \
48    fail "string key on sched_process_fork did not work"
49
50reset_trigger
51
52echo "Test histogram with its name"
53
54echo 'hist:name=test_hist:keys=common_pid' > events/sched/sched_process_fork/trigger
55for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done
56grep test_hist events/sched/sched_process_fork/hist > /dev/null || \
57    fail "named event on sched_process_fork did not work"
58
59echo "Test same named histogram on different events"
60
61echo 'hist:name=test_hist:keys=common_pid' > events/sched/sched_process_exit/trigger
62for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done
63grep test_hist events/sched/sched_process_exit/hist > /dev/null || \
64    fail "named event on sched_process_fork did not work"
65
66diffs=`diff events/sched/sched_process_exit/hist events/sched/sched_process_fork/hist | wc -l`
67test $diffs -eq 0 || fail "Same name histograms are not same"
68
69reset_trigger
70
71do_reset
72
73exit 0
74