diff mbox series

[1/2] tracing/selftests: Support log output when generating KTAP output

Message ID 20240325-kselftest-ftrace-ktap-verbose-v1-1-3785199809da@kernel.org (mailing list archive)
State Accepted
Headers show
Series tracing/selftests: Verbosity improvements to KTAP output | expand

Commit Message

Mark Brown March 25, 2024, 4:15 p.m. UTC
When -v is specified ftracetest will dump logs of test execution to the
console which if -K is also specified for KTAP output will result in
output that is not properly KTAP formatted. All that's required for KTAP
formatting is that anything we log have a '#' at the start of the line so
we can improve things by washing the output through a simple read loop.
This will help automated parsers when verbose mode is enabled.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 tools/testing/selftests/ftrace/ftracetest | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Muhammad Usama Anjum April 6, 2024, 9:03 p.m. UTC | #1
On 3/25/24 9:15 PM, Mark Brown wrote:
> When -v is specified ftracetest will dump logs of test execution to the
> console which if -K is also specified for KTAP output will result in
> output that is not properly KTAP formatted. All that's required for KTAP
> formatting is that anything we log have a '#' at the start of the line so
> we can improve things by washing the output through a simple read loop.
> This will help automated parsers when verbose mode is enabled.
> 
> Signed-off-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>

> ---
>  tools/testing/selftests/ftrace/ftracetest | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest
> index 25d4e0fca385..cce72f8b03dc 100755
> --- a/tools/testing/selftests/ftrace/ftracetest
> +++ b/tools/testing/selftests/ftrace/ftracetest
> @@ -255,7 +255,13 @@ prlog() { # messages
>    [ "$LOG_FILE" ] && printf "$*$newline" | strip_esc >> $LOG_FILE
>  }
>  catlog() { #file
> -  cat $1
> +  if [ "${KTAP}" = "1" ]; then
> +    cat $1 | while read line ; do
> +      echo "# $line"
> +    done
> +  else
> +    cat $1
> +  fi
>    [ "$LOG_FILE" ] && cat $1 | strip_esc >> $LOG_FILE
>  }
>  prlog "=== Ftrace unit tests ==="
>
diff mbox series

Patch

diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest
index 25d4e0fca385..cce72f8b03dc 100755
--- a/tools/testing/selftests/ftrace/ftracetest
+++ b/tools/testing/selftests/ftrace/ftracetest
@@ -255,7 +255,13 @@  prlog() { # messages
   [ "$LOG_FILE" ] && printf "$*$newline" | strip_esc >> $LOG_FILE
 }
 catlog() { #file
-  cat $1
+  if [ "${KTAP}" = "1" ]; then
+    cat $1 | while read line ; do
+      echo "# $line"
+    done
+  else
+    cat $1
+  fi
   [ "$LOG_FILE" ] && cat $1 | strip_esc >> $LOG_FILE
 }
 prlog "=== Ftrace unit tests ==="