All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Shuah Khan <shuah@kernel.org>, Cao Ruichuang <create0818@163.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Shuah Khan <skhan@linuxfoundation.org>,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org
Subject: [PATCH] selftests/ftrace: Support multiple error positions in ftrace_errlog_check()
Date: Thu,  3 Dec 2026 00:20:06 +0900	[thread overview]
Message-ID: <179622480672.618733.5201288220652463257.stgit@devnote2> (raw)

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


                 reply	other threads:[~2026-12-02 15:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179622480672.618733.5201288220652463257.stgit@devnote2 \
    --to=mhiramat@kernel.org \
    --cc=create0818@163.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=rostedt@goodmis.org \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.