1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3# description: event trigger - test multiple histogram triggers
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 multiple tiggers"
27
28echo 'hist:keys=parent_pid:vals=child_pid' > events/sched/sched_process_fork/trigger
29echo 'hist:keys=parent_comm:vals=child_pid' >> events/sched/sched_process_fork/trigger
30for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done
31grep parent_pid events/sched/sched_process_fork/hist > /dev/null || \
32    fail "hist trigger on sched_process_fork did not work"
33grep child events/sched/sched_process_fork/hist > /dev/null || \
34    fail "hist trigger on sched_process_fork did not work"
35COMM=`cat /proc/$$/comm`
36grep "parent_comm: $COMM" events/sched/sched_process_fork/hist > /dev/null || \
37    fail "string key on sched_process_fork did not work"
38
39reset_trigger
40
41echo "Test histogram with its name"
42
43echo 'hist:name=test_hist:keys=common_pid' > events/sched/sched_process_fork/trigger
44for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done
45grep test_hist events/sched/sched_process_fork/hist > /dev/null || \
46    fail "named event on sched_process_fork did not work"
47
48echo "Test same named histogram on different events"
49
50echo 'hist:name=test_hist:keys=common_pid' > events/sched/sched_process_exit/trigger
51for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done
52grep test_hist events/sched/sched_process_exit/hist > /dev/null || \
53    fail "named event on sched_process_fork did not work"
54
55diffs=`diff events/sched/sched_process_exit/hist events/sched/sched_process_fork/hist | wc -l`
56test $diffs -eq 0 || fail "Same name histograms are not same"
57
58exit 0
59