* [PATCH] selftests/ftrace: Support multiple error positions in ftrace_errlog_check()
@ 2026-12-02 15:20 Masami Hiramatsu (Google)
0 siblings, 0 replies; only message in thread
From: Masami Hiramatsu (Google) @ 2026-12-02 15:20 UTC (permalink / raw)
To: Steven Rostedt, Masami Hiramatsu, Shuah Khan, Cao Ruichuang
Cc: Mathieu Desnoyers, Shuah Khan, linux-kernel, linux-trace-kernel,
linux-kselftest
From: Masami Hiramatsu <mhiramat@kernel.org>
Update ftrace_errlog_check() to accept multiple '^' error position
markers in the command string and succeed if the caret position
reported in error_log matches any one of them.
This is a remedy for the previously submitted filter error position
fix patch [1], which corrects the reported caret position in the
kernel filter parser and updates tracing-error-log.tc accordingly.
Because newer ftracetest suites are also run against older kernels
that do not have the parser position fix, allowing a test case to
specify both the new and old caret positions (with a comment
explaining why) preserves backwards compatibility without weakening
other tests.
[1] https://lore.kernel.org/linux-trace-kernel/179323794702.740114.679129900715570251.stgit@devnote2/
Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
tools/testing/selftests/ftrace/test.d/functions | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions
index 826141e299e5..80c0cf3d5e2d 100644
--- a/tools/testing/selftests/ftrace/test.d/functions
+++ b/tools/testing/selftests/ftrace/test.d/functions
@@ -191,9 +191,11 @@ FUNCTION_FORK=`(if grep '\bkernel_clone\b' /proc/kallsyms > /dev/null; then
echo kernel_clone; else echo '_do_fork'; fi)`
# Since probe event command may include backslash, explicitly use printf "%s"
-# to NOT interpret it.
+# to NOT interpret it. Multiple '^' markers may be specified when older and
+# newer kernels report different error positions; matching any one succeeds.
ftrace_errlog_check() { # err-prefix command-with-error-pos-by-^ command-file
- pos=$(printf "%s" "${2%^*}" | wc -c) # error position
+ local command rest head pos N
+
command=$(printf "%s" "$2" | tr -d ^)
echo "Test command: $command"
echo > error_log
@@ -201,7 +203,21 @@ ftrace_errlog_check() { # err-prefix command-with-error-pos-by-^ command-file
grep "$1: error:" -A 3 error_log
N=$(tail -n 1 error_log | wc -c)
# " Command: " and "^\n" => 13
- test $(expr 13 + $pos) -eq $N
+
+ rest="$2"
+ pos=0
+ while true; do
+ case "$rest" in
+ *^*) ;;
+ *) return 1 ;;
+ esac
+ head=${rest%%^*}
+ rest=${rest#*^}
+ pos=$((pos + ${#head}))
+ if [ $((13 + pos)) -eq "$N" ]; then
+ return 0
+ fi
+ done
}
# Helper to get the tracefs mount point
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-02 15:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 15:20 [PATCH] selftests/ftrace: Support multiple error positions in ftrace_errlog_check() Masami Hiramatsu (Google)
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.