1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3# description: event trigger - test inter-event histogram trigger trace action with dynamic string param
4# requires: set_event synthetic_events events/sched/sched_process_exec/hist "long[]' >> synthetic_events":README
5
6fail() { #msg
7    echo $1
8    exit_fail
9}
10
11echo "Test create synthetic event with stack"
12
13
14echo 's:wake_lat pid_t pid; u64 delta; unsigned long[] stack;' > dynamic_events
15echo 'hist:keys=next_pid:ts=common_timestamp.usecs,st=stacktrace  if prev_state == 1||prev_state == 2' >> events/sched/sched_switch/trigger
16echo 'hist:keys=prev_pid:delta=common_timestamp.usecs-$ts,s=$st:onmax($delta).trace(wake_lat,prev_pid,$delta,$s)' >> events/sched/sched_switch/trigger
17echo 1 > events/synthetic/wake_lat/enable
18sleep 1
19
20if ! grep -q "=>.*sched" trace; then
21    fail "Failed to create synthetic event with stack"
22fi
23
24exit 0
25