1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3# description: event trigger - test inter-event histogram trigger snapshot action
4
5fail() { #msg
6    echo $1
7    exit_fail
8}
9
10if [ ! -f set_event ]; then
11    echo "event tracing is not supported"
12    exit_unsupported
13fi
14
15if [ ! -f events/sched/sched_process_fork/hist ]; then
16    echo "hist trigger is not supported"
17    exit_unsupported
18fi
19
20if [ ! -f snapshot ]; then
21    echo "snapshot is not supported"
22    exit_unsupported
23fi
24
25grep -q "onchange(var)" README || exit_unsupported # version issue
26
27grep -q "snapshot()" README || exit_unsupported # version issue
28
29echo "Test snapshot action"
30
31echo 1 > events/sched/enable
32
33echo 'hist:keys=comm:newprio=prio:onchange($newprio).save(comm,prio):onchange($newprio).snapshot() if comm=="ping"' >> events/sched/sched_waking/trigger
34
35ping $LOCALHOST -c 3
36nice -n 1 ping $LOCALHOST -c 3
37
38echo 0 > tracing_on
39
40if ! grep -q "changed:" events/sched/sched_waking/hist; then
41    fail "Failed to create onchange action inter-event histogram"
42fi
43
44if ! grep -q "comm=ping" snapshot; then
45    fail "Failed to create snapshot action inter-event histogram"
46fi
47
48exit 0
49