xref: /linux/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-fully-qualified-var-ref.tc (revision cb30bf881c5b4ee8b879558a2fce93d7de652955)
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3# description: event trigger - test fully-qualified variable reference support
4# requires: set_event synthetic_events events/sched/sched_process_fork/hist ping:program
5
6fail() { #msg
7    echo $1
8    exit_fail
9}
10
11echo "Test fully-qualified variable reference support"
12
13echo 'wakeup_latency u64 lat; pid_t pid; int prio; char comm[16]' > synthetic_events
14echo 'hist:keys=comm:ts0=common_timestamp.usecs if comm=="ping"' > events/sched/sched_waking/trigger
15echo 'hist:keys=comm:ts0=common_timestamp.usecs if comm=="ping"' > events/sched/sched_wakeup/trigger
16echo 'hist:keys=next_comm:wakeup_lat=common_timestamp.usecs-sched.sched_wakeup.$ts0:onmatch(sched.sched_waking).wakeup_latency($wakeup_lat,next_pid,sched.sched_waking.prio,next_comm) if next_comm=="ping"' > events/sched/sched_switch/trigger
17echo 'hist:keys=pid,prio,comm:vals=lat:sort=pid,prio' > events/synthetic/wakeup_latency/trigger
18
19ping $LOCALHOST -c 3
20if ! grep -q "ping" events/synthetic/wakeup_latency/hist; then
21    fail "Failed to create inter-event histogram"
22fi
23
24if ! grep -q "synthetic_prio=prio" events/sched/sched_waking/hist; then
25    fail "Failed to create histogram with fully-qualified variable reference"
26fi
27
28echo '!hist:keys=next_comm:wakeup_lat=common_timestamp.usecs-sched.sched_wakeup.$ts0:onmatch(sched.sched_waking).wakeup_latency($wakeup_lat,next_pid,sched.sched_waking.prio,next_comm) if next_comm=="ping"' >> events/sched/sched_switch/trigger
29
30if grep -q "synthetic_prio=prio" events/sched/sched_waking/hist; then
31    fail "Failed to remove histogram with fully-qualified variable reference"
32fi
33
34exit 0
35