linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Linux trace kernel <linux-trace-kernel@vger.kernel.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Shuah Khan <skhan@linuxfoundation.org>,
	linux-kselftest@vger.kernel.org
Subject: Re: [PATCH] tracing: selftests: Add testing a user string to filters
Date: Fri, 18 Apr 2025 16:14:04 +0900	[thread overview]
Message-ID: <20250418161404.04771abaeafec2dce3413247@kernel.org> (raw)
In-Reply-To: <20250417223323.3edb4f6c@batman.local.home>

On Thu, 17 Apr 2025 22:33:23 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> From: Steven Rostedt <rostedt@goodmis.org>
> 
> Running the following commands was broken:
> 
>   # cd /sys/kernel/tracing
>   # echo "filename.ustring ~ \"/proc*\"" > events/syscalls/sys_enter_openat/filter
>   # echo 1 > events/syscalls/sys_enter_openat/enable
>   # ls /proc/$$/maps
>   # cat trace
> 
> And would produce nothing when it should have produced something like:
> 
>       ls-1192    [007] .....  8169.828333: sys_openat(dfd: ffffffffffffff9c, filename: 7efc18359904, flags: 80000, mode: 0)
> 
> Add a test to check this case so that it will be caught if it breaks
> again.
> 
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> ---
> Shuah, I'm Cc'ing you on this for your information, but I'll take it
> through my tree as it will be attached with the fix, as it will fail
> without it.
> 
>  .../test.d/filter/event-filter-function.tc    | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/tools/testing/selftests/ftrace/test.d/filter/event-filter-function.tc b/tools/testing/selftests/ftrace/test.d/filter/event-filter-function.tc
> index 118247b8dd84..ab449a2cea8c 100644
> --- a/tools/testing/selftests/ftrace/test.d/filter/event-filter-function.tc
> +++ b/tools/testing/selftests/ftrace/test.d/filter/event-filter-function.tc
> @@ -80,6 +80,25 @@ if [ $misscnt -gt 0 ]; then
>  	exit_fail
>  fi
>  
> +# Check strings too
> +if [ -f events/syscalls/sys_enter_openat/filter ]; then
> +	echo "filename.ustring ~ \"*test.d*\"" > events/syscalls/sys_enter_openat/filter

I think it is better to use a $TMPDIR for the test script,
instead of reusing the $TEST_DIR. Since $TMPDIR has been
introduced to be used for this purpose.

DIRNAME=`basename $TMPDIR`

echo "filename.ustring ~ \"\*$DIRNAME\*\"" > events/syscalls/sys_enter_openat/filter

> +	echo 1 > events/syscalls/sys_enter_openat/enable
> +	echo 1 > tracing_on
> +	ls /bin/sh
> +	nocnt=`grep openat trace | wc -l`
> +	ls $TEST_DIR

and `ls $TMPDIR` ?

Does that work?

Thank you,

> +	echo 0 > tracing_on
> +	hitcnt=`grep openat trace | wc -l`;
> +	echo 0 > events/syscalls/sys_enter_openat/enable
> +	if [ $nocnt -gt 0 ]; then
> +		exit_fail
> +	fi
> +	if [ $hitcnt -eq 0 ]; then
> +		exit_fail
> +	fi
> +fi
> +
>  reset_events_filter
>  
>  exit 0
> -- 
> 2.47.2
> 


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

  reply	other threads:[~2025-04-18  7:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-18  2:33 [PATCH] tracing: selftests: Add testing a user string to filters Steven Rostedt
2025-04-18  7:14 ` Masami Hiramatsu [this message]
2025-04-18 12:25   ` Steven Rostedt

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=20250418161404.04771abaeafec2dce3413247@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=akpm@linux-foundation.org \
    --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=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).