1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3# description: event trigger - test inter-event histogram trigger snapshot action
4# requires: set_event snapshot events/sched/sched_process_fork/hist "onchange(var)":README "snapshot()":README
5
6fail() { #msg
7    echo $1
8    exit_fail
9}
10
11echo "Test snapshot action"
12
13echo 1 > events/sched/enable
14
15echo 'hist:keys=comm:newprio=prio:onchange($newprio).save(comm,prio):onchange($newprio).snapshot() if comm=="ping"' >> events/sched/sched_waking/trigger
16
17ping $LOCALHOST -c 3
18nice -n 1 ping $LOCALHOST -c 3
19
20echo 0 > tracing_on
21
22if ! grep -q "changed:" events/sched/sched_waking/hist; then
23    fail "Failed to create onchange action inter-event histogram"
24fi
25
26if ! grep -q "comm=ping" snapshot; then
27    fail "Failed to create snapshot action inter-event histogram"
28fi
29
30exit 0
31