xref: /linux/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmax-action-hist.tc (revision 7ae9fb1b7ecbb5d85d07857943f677fd1a559b18)
1f06eec4dSRajvi Jingar#!/bin/sh
2403726d8STom Zanussi# SPDX-License-Identifier: GPL-2.0
3f06eec4dSRajvi Jingar# description: event trigger - test inter-event histogram trigger onmax action
4*4aa4d4deSNaveen N. Rao# requires: set_event synthetic_events events/sched/sched_process_fork/hist ping:program
5f06eec4dSRajvi Jingar
6f06eec4dSRajvi Jingarfail() { #msg
7f06eec4dSRajvi Jingar    echo $1
8f06eec4dSRajvi Jingar    exit_fail
9f06eec4dSRajvi Jingar}
10f06eec4dSRajvi Jingar
11f06eec4dSRajvi Jingarecho "Test create synthetic event"
12f06eec4dSRajvi Jingar
13f06eec4dSRajvi Jingarecho 'wakeup_latency  u64 lat pid_t pid char comm[16]' > synthetic_events
14f06eec4dSRajvi Jingarif [ ! -d events/synthetic/wakeup_latency ]; then
15f06eec4dSRajvi Jingar    fail "Failed to create wakeup_latency synthetic event"
16f06eec4dSRajvi Jingarfi
17f06eec4dSRajvi Jingar
18f06eec4dSRajvi Jingarecho "Test onmax action"
19f06eec4dSRajvi Jingar
20f06eec4dSRajvi Jingarecho 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' >> events/sched/sched_waking/trigger
21f06eec4dSRajvi Jingarecho 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0:onmax($wakeup_lat).save(next_comm,prev_pid,prev_prio,prev_comm) if next_comm=="ping"' >> events/sched/sched_switch/trigger
22cec3adf5SMasami Hiramatsu
23cec3adf5SMasami Hiramatsuping $LOCALHOST -c 3
24f06eec4dSRajvi Jingarif ! grep -q "max:" events/sched/sched_switch/hist; then
25f06eec4dSRajvi Jingar    fail "Failed to create onmax action inter-event histogram"
26f06eec4dSRajvi Jingarfi
27f06eec4dSRajvi Jingar
28f06eec4dSRajvi Jingarexit 0
29