public inbox for linux-trace-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] selftests/tracing: Fix to make --logdir option work again
@ 2026-02-10  9:54 Masami Hiramatsu (Google)
  2026-02-10  9:54 ` [PATCH 2/2] selftests/tracing: Fix to check awk supports non POSIX strtonum() Masami Hiramatsu (Google)
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Masami Hiramatsu (Google) @ 2026-02-10  9:54 UTC (permalink / raw)
  To: Steven Rostedt, Shuah Khan, Gabriele Monaco
  Cc: Mathieu Desnoyers, Masami Hiramatsu, linux-kernel,
	linux-trace-kernel, linux-kselftest

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

Since commit a0aa283c53a7 ("selftest/ftrace: Generalise ftracetest to
use with RV") moved the default LOG_DIR setting after --logdir option
parser, it overwrites the user given LOG_DIR.
This fixes it to check the --logdir option parameter when setting new
default LOG_DIR with a new TOP_DIR.

Fixes: a0aa283c53a7 ("selftest/ftrace: Generalise ftracetest to use with RV")
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
 tools/testing/selftests/ftrace/ftracetest |   18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest
index 3230bd54dba8..0a56bf209f6c 100755
--- a/tools/testing/selftests/ftrace/ftracetest
+++ b/tools/testing/selftests/ftrace/ftracetest
@@ -130,8 +130,7 @@ parse_opts() { # opts
       shift 1
     ;;
     --logdir|-l)
-      LOG_DIR=$2
-      LINK_PTR=
+      USER_LOG_DIR=$2
       shift 2
     ;;
     --rv)
@@ -199,6 +198,7 @@ fi
 TOP_DIR=`absdir $0`
 TEST_DIR=$TOP_DIR/test.d
 TEST_CASES=`find_testcases $TEST_DIR`
+USER_LOG_DIR=
 KEEP_LOG=0
 KTAP=0
 DEBUG=0
@@ -210,12 +210,18 @@ RV_TEST=0
 # Parse command-line options
 parse_opts $*
 
+[ $DEBUG -ne 0 ] && set -x
+
+# TOP_DIR can be changed for rv. Setting log directory.
 LOG_TOP_DIR=$TOP_DIR/logs
 LOG_DATE=`date +%Y%m%d-%H%M%S`
-LOG_DIR=$LOG_TOP_DIR/$LOG_DATE/
-LINK_PTR=$LOG_TOP_DIR/latest
-
-[ $DEBUG -ne 0 ] && set -x
+if [ -n "$USER_LOG_DIR" ]; then
+  LOG_DIR=$USER_LOG_DIR
+  LINK_PTR=
+else
+  LOG_DIR=$LOG_TOP_DIR/$LOG_DATE/
+  LINK_PTR=$LOG_TOP_DIR/latest
+fi
 
 if [ $RV_TEST -ne 0 ]; then
 	TRACING_DIR=$TRACING_DIR/rv


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] selftests/tracing: Fix to check awk supports non POSIX strtonum()
  2026-02-10  9:54 [PATCH 1/2] selftests/tracing: Fix to make --logdir option work again Masami Hiramatsu (Google)
@ 2026-02-10  9:54 ` Masami Hiramatsu (Google)
  2026-02-11  8:16 ` [PATCH 1/2] selftests/tracing: Fix to make --logdir option work again Gabriele Monaco
  2026-03-04  2:04 ` Masami Hiramatsu
  2 siblings, 0 replies; 4+ messages in thread
From: Masami Hiramatsu (Google) @ 2026-02-10  9:54 UTC (permalink / raw)
  To: Steven Rostedt, Shuah Khan, Gabriele Monaco
  Cc: Mathieu Desnoyers, Masami Hiramatsu, linux-kernel,
	linux-trace-kernel, linux-kselftest

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

Check the awk command supports non POSIX strtonum() function in
the trace_marker_raw test case.

Fixes: 37f46601383a ("selftests/tracing: Add basic test for trace_marker_raw file")
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
 .../ftrace/test.d/00basic/trace_marker_raw.tc      |    2 ++
 tools/testing/selftests/ftrace/test.d/functions    |    4 ++++
 2 files changed, 6 insertions(+)

diff --git a/tools/testing/selftests/ftrace/test.d/00basic/trace_marker_raw.tc b/tools/testing/selftests/ftrace/test.d/00basic/trace_marker_raw.tc
index a2c42e13f614..8e905d4fe6dd 100644
--- a/tools/testing/selftests/ftrace/test.d/00basic/trace_marker_raw.tc
+++ b/tools/testing/selftests/ftrace/test.d/00basic/trace_marker_raw.tc
@@ -4,6 +4,8 @@
 # requires: trace_marker_raw
 # flags: instance
 
+check_awk_strtonum || exit_unresolved
+
 is_little_endian() {
 	if lscpu | grep -q 'Little Endian'; then
 		echo 1;
diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions
index e8e718139294..41325f387ee7 100644
--- a/tools/testing/selftests/ftrace/test.d/functions
+++ b/tools/testing/selftests/ftrace/test.d/functions
@@ -173,6 +173,10 @@ check_requires() { # Check required files and tracers
     done
 }
 
+check_awk_strtonum() { # strtonum is GNU awk extension
+    awk 'BEGIN{strtonum("0x1")}'
+}
+
 LOCALHOST=127.0.0.1
 
 yield() {


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] selftests/tracing: Fix to make --logdir option work again
  2026-02-10  9:54 [PATCH 1/2] selftests/tracing: Fix to make --logdir option work again Masami Hiramatsu (Google)
  2026-02-10  9:54 ` [PATCH 2/2] selftests/tracing: Fix to check awk supports non POSIX strtonum() Masami Hiramatsu (Google)
@ 2026-02-11  8:16 ` Gabriele Monaco
  2026-03-04  2:04 ` Masami Hiramatsu
  2 siblings, 0 replies; 4+ messages in thread
From: Gabriele Monaco @ 2026-02-11  8:16 UTC (permalink / raw)
  To: Masami Hiramatsu (Google), Steven Rostedt, Shuah Khan
  Cc: Mathieu Desnoyers, linux-kernel, linux-trace-kernel,
	linux-kselftest

On Tue, 2026-02-10 at 18:54 +0900, Masami Hiramatsu (Google) wrote:
> From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> 
> Since commit a0aa283c53a7 ("selftest/ftrace: Generalise ftracetest to
> use with RV") moved the default LOG_DIR setting after --logdir option
> parser, it overwrites the user given LOG_DIR.
> This fixes it to check the --logdir option parameter when setting new
> default LOG_DIR with a new TOP_DIR.
> 
> Fixes: a0aa283c53a7 ("selftest/ftrace: Generalise ftracetest to use with RV")
> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> ---

Thanks for catching this! I should have tested all the options..
The fix works fine on my side.

Tested-by: Gabriele Monaco <gmonaco@redhat.com>

>  tools/testing/selftests/ftrace/ftracetest |   18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/testing/selftests/ftrace/ftracetest
> b/tools/testing/selftests/ftrace/ftracetest
> index 3230bd54dba8..0a56bf209f6c 100755
> --- a/tools/testing/selftests/ftrace/ftracetest
> +++ b/tools/testing/selftests/ftrace/ftracetest
> @@ -130,8 +130,7 @@ parse_opts() { # opts
>        shift 1
>      ;;
>      --logdir|-l)
> -      LOG_DIR=$2
> -      LINK_PTR=
> +      USER_LOG_DIR=$2
>        shift 2
>      ;;
>      --rv)
> @@ -199,6 +198,7 @@ fi
>  TOP_DIR=`absdir $0`
>  TEST_DIR=$TOP_DIR/test.d
>  TEST_CASES=`find_testcases $TEST_DIR`
> +USER_LOG_DIR=
>  KEEP_LOG=0
>  KTAP=0
>  DEBUG=0
> @@ -210,12 +210,18 @@ RV_TEST=0
>  # Parse command-line options
>  parse_opts $*
>  
> +[ $DEBUG -ne 0 ] && set -x
> +
> +# TOP_DIR can be changed for rv. Setting log directory.
>  LOG_TOP_DIR=$TOP_DIR/logs
>  LOG_DATE=`date +%Y%m%d-%H%M%S`
> -LOG_DIR=$LOG_TOP_DIR/$LOG_DATE/
> -LINK_PTR=$LOG_TOP_DIR/latest
> -
> -[ $DEBUG -ne 0 ] && set -x
> +if [ -n "$USER_LOG_DIR" ]; then
> +  LOG_DIR=$USER_LOG_DIR
> +  LINK_PTR=
> +else
> +  LOG_DIR=$LOG_TOP_DIR/$LOG_DATE/
> +  LINK_PTR=$LOG_TOP_DIR/latest
> +fi
>  
>  if [ $RV_TEST -ne 0 ]; then
>  	TRACING_DIR=$TRACING_DIR/rv


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] selftests/tracing: Fix to make --logdir option work again
  2026-02-10  9:54 [PATCH 1/2] selftests/tracing: Fix to make --logdir option work again Masami Hiramatsu (Google)
  2026-02-10  9:54 ` [PATCH 2/2] selftests/tracing: Fix to check awk supports non POSIX strtonum() Masami Hiramatsu (Google)
  2026-02-11  8:16 ` [PATCH 1/2] selftests/tracing: Fix to make --logdir option work again Gabriele Monaco
@ 2026-03-04  2:04 ` Masami Hiramatsu
  2 siblings, 0 replies; 4+ messages in thread
From: Masami Hiramatsu @ 2026-03-04  2:04 UTC (permalink / raw)
  To: Masami Hiramatsu (Google), Shuah Khan
  Cc: Steven Rostedt, Shuah Khan, Gabriele Monaco, Mathieu Desnoyers,
	linux-kernel, linux-trace-kernel, linux-kselftest

Hi Shuah,

Could you pick these 2 patches to the selftests tree or should I pick it?

Thanks,

On Tue, 10 Feb 2026 18:54:12 +0900
"Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:

> From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> 
> Since commit a0aa283c53a7 ("selftest/ftrace: Generalise ftracetest to
> use with RV") moved the default LOG_DIR setting after --logdir option
> parser, it overwrites the user given LOG_DIR.
> This fixes it to check the --logdir option parameter when setting new
> default LOG_DIR with a new TOP_DIR.
> 
> Fixes: a0aa283c53a7 ("selftest/ftrace: Generalise ftracetest to use with RV")
> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> ---
>  tools/testing/selftests/ftrace/ftracetest |   18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest
> index 3230bd54dba8..0a56bf209f6c 100755
> --- a/tools/testing/selftests/ftrace/ftracetest
> +++ b/tools/testing/selftests/ftrace/ftracetest
> @@ -130,8 +130,7 @@ parse_opts() { # opts
>        shift 1
>      ;;
>      --logdir|-l)
> -      LOG_DIR=$2
> -      LINK_PTR=
> +      USER_LOG_DIR=$2
>        shift 2
>      ;;
>      --rv)
> @@ -199,6 +198,7 @@ fi
>  TOP_DIR=`absdir $0`
>  TEST_DIR=$TOP_DIR/test.d
>  TEST_CASES=`find_testcases $TEST_DIR`
> +USER_LOG_DIR=
>  KEEP_LOG=0
>  KTAP=0
>  DEBUG=0
> @@ -210,12 +210,18 @@ RV_TEST=0
>  # Parse command-line options
>  parse_opts $*
>  
> +[ $DEBUG -ne 0 ] && set -x
> +
> +# TOP_DIR can be changed for rv. Setting log directory.
>  LOG_TOP_DIR=$TOP_DIR/logs
>  LOG_DATE=`date +%Y%m%d-%H%M%S`
> -LOG_DIR=$LOG_TOP_DIR/$LOG_DATE/
> -LINK_PTR=$LOG_TOP_DIR/latest
> -
> -[ $DEBUG -ne 0 ] && set -x
> +if [ -n "$USER_LOG_DIR" ]; then
> +  LOG_DIR=$USER_LOG_DIR
> +  LINK_PTR=
> +else
> +  LOG_DIR=$LOG_TOP_DIR/$LOG_DATE/
> +  LINK_PTR=$LOG_TOP_DIR/latest
> +fi
>  
>  if [ $RV_TEST -ne 0 ]; then
>  	TRACING_DIR=$TRACING_DIR/rv
> 


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-04  2:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-10  9:54 [PATCH 1/2] selftests/tracing: Fix to make --logdir option work again Masami Hiramatsu (Google)
2026-02-10  9:54 ` [PATCH 2/2] selftests/tracing: Fix to check awk supports non POSIX strtonum() Masami Hiramatsu (Google)
2026-02-11  8:16 ` [PATCH 1/2] selftests/tracing: Fix to make --logdir option work again Gabriele Monaco
2026-03-04  2:04 ` Masami Hiramatsu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox