All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v2 9/9] selftests/ftrace: Add event filter syntax check test case
Date: Sun, 25 Oct 2026 08:46:39 +0000	[thread overview]
Message-ID: <sashiko-outbox-184136@kernel.org> (raw)
In-Reply-To: <179291751117.492959.1147654467208615243.stgit@devnote2>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] selftests/ftrace: negated pipelines in filter-syntax-check.tc bypass set -e
--

commit 98a96a63f4d758b8db11a7d2138febf6cb5cf6e9
Author: Masami Hiramatsu (Google) <mhiramat@kernel.org>

selftests/ftrace: Add event filter syntax check test case

This patch adds filter-syntax-check.tc to test valid event filter
expressions, error_log caret reporting for malformed filter expressions,
newline truncation on multi-line filter input, and error returns on invalid
subsystem filters.

> diff --git a/tools/testing/selftests/ftrace/test.d/filter/filter-syntax-check.tc b/tools/testing/selftests/ftrace/test.d/filter/filter-syntax-check.tc
> new file mode 100644
> index 0000000000000..68c8accc5ffd0
> --- /dev/null
> +++ b/tools/testing/selftests/ftrace/test.d/filter/filter-syntax-check.tc
> @@ -0,0 +1,52 @@

[ ... ]

> +# Multi-line input must be truncated at the first newline
> +echo > error_log
> +! ( printf "common_pid == CPUS{0\n\"} && common_pid == 0 && common_pid == CPUS{0\n\"}" | \
> +    dd of=events/sched/sched_switch/filter bs=4096 ) 2> /dev/null
> +grep -q "Missing '}'" error_log
> +! grep -q "Missing matching quote" error_log
> +
> +# Subsystem filter must fail on invalid filter expressions
> +echo 'common_pid >= 0' > events/sched/filter
> +! echo 'no_such_field == 1' > events/sched/filter
> +! echo 'common_pid == 1 &&' > events/sched/filter
> +echo 0 > events/sched/filter
> +
> +exit 0

[Severity: Medium]
Will these negated pipelines actually fail the test if any of the inner
commands unexpectedly succeed?

In tools/testing/selftests/ftrace/ftracetest, __run_test() sources each
test script in a /bin/sh subshell with set -e enabled:

    __run_test() { # testfile
      # setup PID and PPID, $$ is not updated.
      (cd $TRACING_DIR; read PID _ < /proc/self/stat; set -e; set -x;
       checkreq $1; initialize_system; . $1)
      [ $? -ne 0 ] && kill -s $SIG_FAIL $SIG_PID
    }

In POSIX sh, set -e is ignored for any pipeline beginning with the !
reserved word. If the dd, grep, or echo commands in filter-syntax-check.tc
unexpectedly return 0, the negated pipeline evaluates to status 1 without
causing the shell to exit, and execution continues through:

    echo 0 > events/sched/filter

    exit 0

allowing the test to pass even when a negative check fails. Should these use
explicit failure handling (such as || exit_fail) or wrap the negation in a
subshell so set -e catches an unexpected success?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/179291742944.492959.11659339795290028998.stgit@devnote2?part=9

      reply	other threads:[~2026-10-25  8:46 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-25  8:37 [PATCH v2 0/9] tracing/filters: Fix event filter parsing and matching bugs Masami Hiramatsu (Google)
2026-10-25  8:37 ` [PATCH v2 1/9] tracing/filters: Fix MATCH_END_ONLY regex matching for fixed-size strings Masami Hiramatsu (Google)
2026-10-26 23:11   ` Masami Hiramatsu (Google)
2026-10-25  8:37 ` [PATCH v2 2/9] tracing/filters: Fix false success return in process_system_preds() Masami Hiramatsu (Google)
2026-10-25  8:37 ` [PATCH v2 3/9] tracing/filters: Handle out-of-range CPU for OP_NE in cpumask comparison Masami Hiramatsu (Google)
2026-10-25  8:37 ` [PATCH v2 4/9] tracing/filters: Report parse error on all -EINVAL paths in filter parsing Masami Hiramatsu (Google)
2026-10-25  8:37 ` [PATCH v2 5/9] tracing/filters: Fix function event operand parsing in parse_pred() Masami Hiramatsu (Google)
2026-10-26 20:32   ` Steven Rostedt
2026-10-26 23:37     ` Masami Hiramatsu (Google)
2026-10-25  8:38 ` [PATCH v2 6/9] tracing/filters: Skip second character of '&&' and '||' in calc_stack() Masami Hiramatsu (Google)
2026-10-26 20:47   ` Steven Rostedt
2026-10-26 23:50     ` Masami Hiramatsu (Google)
2026-10-27  0:12       ` Masami Hiramatsu (Google)
2026-10-27 12:45         ` Steven Rostedt
2026-10-25  8:38 ` [PATCH v2 7/9] tracing/filters: Reject unsupported field sizes in parse_pred() Masami Hiramatsu (Google)
2026-10-25  8:38 ` [PATCH v2 8/9] tracing/filters: Terminate filter string at first newline Masami Hiramatsu (Google)
2026-10-26 20:49   ` Steven Rostedt
2026-10-26 23:53     ` Masami Hiramatsu (Google)
2026-10-25  8:38 ` [PATCH v2 9/9] selftests/ftrace: Add event filter syntax check test case Masami Hiramatsu (Google)
2026-10-25  8:46   ` sashiko-bot [this message]

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=sashiko-outbox-184136@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.