xref: /openbmc/linux/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmax-action-hist.tc (revision c62d3cd0ddd629606a3830aa22e9dcc6c2a0d3bf)
1#!/bin/sh
2# description: event trigger - test inter-event histogram trigger onmax action
3
4do_reset() {
5    reset_trigger
6    echo > set_event
7    clear_trace
8}
9
10fail() { #msg
11    do_reset
12    echo $1
13    exit_fail
14}
15
16if [ ! -f set_event ]; then
17    echo "event tracing is not supported"
18    exit_unsupported
19fi
20
21if [ ! -f synthetic_events ]; then
22    echo "synthetic event is not supported"
23    exit_unsupported
24fi
25
26clear_synthetic_events
27reset_tracer
28do_reset
29
30echo "Test create synthetic event"
31
32echo 'wakeup_latency  u64 lat pid_t pid char comm[16]' > synthetic_events
33if [ ! -d events/synthetic/wakeup_latency ]; then
34    fail "Failed to create wakeup_latency synthetic event"
35fi
36
37echo "Test onmax action"
38
39echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' >> events/sched/sched_waking/trigger
40echo '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
41ping localhost -c 3
42if ! grep -q "max:" events/sched/sched_switch/hist; then
43    fail "Failed to create onmax action inter-event histogram"
44fi
45
46do_reset
47
48exit 0
49