Skip to content

Commit f1aab36

Browse files
committed
tracing/selftests: Update synthetic event selftest to use common_stacktrace
With the rename of the stacktrace field to common_stacktrace, update the selftests to reflect this change. Copy the current selftest to test the backward compatibility "stacktrace" keyword. Also the "requires" of that test was incorrect, so it would never actually ran before. That is fixed now. Link: https://lore.kernel.org/linux-trace-kernel/20230523225402.55951f2f@rorschach.local.home Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Tom Zanussi <zanussi@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Shuah Khan <shuah@kernel.org> Cc: Shuah Khan <skhan@linuxfoundation.org> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 4b51286 commit f1aab36

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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 (legacy stack)
4+
# requires: set_event synthetic_events events/sched/sched_process_exec/hist "long[] stack' >> synthetic_events":README
5+
6+
fail() { #msg
7+
echo $1
8+
exit_fail
9+
}
10+
11+
echo "Test create synthetic event with stack"
12+
13+
# Test the old stacktrace keyword (for backward compatibility)
14+
echo 's:wake_lat pid_t pid; u64 delta; unsigned long[] stack;' > dynamic_events
15+
echo 'hist:keys=next_pid:ts=common_timestamp.usecs,st=stacktrace if prev_state == 1||prev_state == 2' >> events/sched/sched_switch/trigger
16+
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
17+
echo 1 > events/synthetic/wake_lat/enable
18+
sleep 1
19+
20+
if ! grep -q "=>.*sched" trace; then
21+
fail "Failed to create synthetic event with stack"
22+
fi
23+
24+
exit 0

tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-synthetic-event-stack.tc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22
# SPDX-License-Identifier: GPL-2.0
33
# 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
4+
# requires: set_event synthetic_events events/sched/sched_process_exec/hist "can be any field, or the special string 'common_stacktrace'":README
55

66
fail() { #msg
77
echo $1
@@ -10,9 +10,8 @@ fail() { #msg
1010

1111
echo "Test create synthetic event with stack"
1212

13-
1413
echo 's:wake_lat pid_t pid; u64 delta; unsigned long[] stack;' > dynamic_events
15-
echo 'hist:keys=next_pid:ts=common_timestamp.usecs,st=stacktrace if prev_state == 1||prev_state == 2' >> events/sched/sched_switch/trigger
14+
echo 'hist:keys=next_pid:ts=common_timestamp.usecs,st=common_stacktrace if prev_state == 1||prev_state == 2' >> events/sched/sched_switch/trigger
1615
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
1716
echo 1 > events/synthetic/wake_lat/enable
1817
sleep 1

0 commit comments

Comments
 (0)