xref: /linux/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-synthetic-event-stack.tc (revision 1ac731c529cd4d6adbce134754b51ff7d822b145)
1b81a3a10SSteven Rostedt (Google)#!/bin/sh
2b81a3a10SSteven Rostedt (Google)# SPDX-License-Identifier: GPL-2.0
3b81a3a10SSteven Rostedt (Google)# description: event trigger - test inter-event histogram trigger trace action with dynamic string param
4*f1aab363SSteven Rostedt (Google)# requires: set_event synthetic_events events/sched/sched_process_exec/hist "can be any field, or the special string 'common_stacktrace'":README
5b81a3a10SSteven Rostedt (Google)
6b81a3a10SSteven Rostedt (Google)fail() { #msg
7b81a3a10SSteven Rostedt (Google)    echo $1
8b81a3a10SSteven Rostedt (Google)    exit_fail
9b81a3a10SSteven Rostedt (Google)}
10b81a3a10SSteven Rostedt (Google)
11b81a3a10SSteven Rostedt (Google)echo "Test create synthetic event with stack"
12b81a3a10SSteven Rostedt (Google)
13b81a3a10SSteven Rostedt (Google)echo 's:wake_lat pid_t pid; u64 delta; unsigned long[] stack;' > dynamic_events
14*f1aab363SSteven Rostedt (Google)echo 'hist:keys=next_pid:ts=common_timestamp.usecs,st=common_stacktrace  if prev_state == 1||prev_state == 2' >> events/sched/sched_switch/trigger
15b81a3a10SSteven Rostedt (Google)echo '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
16b81a3a10SSteven Rostedt (Google)echo 1 > events/synthetic/wake_lat/enable
17b81a3a10SSteven Rostedt (Google)sleep 1
18b81a3a10SSteven Rostedt (Google)
19b81a3a10SSteven Rostedt (Google)if ! grep -q "=>.*sched" trace; then
20b81a3a10SSteven Rostedt (Google)    fail "Failed to create synthetic event with stack"
21b81a3a10SSteven Rostedt (Google)fi
22b81a3a10SSteven Rostedt (Google)
23b81a3a10SSteven Rostedt (Google)exit 0
24