diff mbox series

sefltests/ftrace: Use /bin/echo for output with options

Message ID 154350406317.4422.7595059658374071660.stgit@devbox (mailing list archive)
State New
Headers show
Series sefltests/ftrace: Use /bin/echo for output with options | expand

Commit Message

Masami Hiramatsu (Google) Nov. 29, 2018, 3:07 p.m. UTC
Use /bin/echo for console output with options like non
newline (-n) and/or backslash escape (-e).

Tom Zanussi reported that when he tested ftracetest, it
shows "-e" and "-n" options on the console, since a system
which uses dash as the alias of /bin/sh, uses dash built-in
echo command which doesn't accept "-e".

To avoid this issue, use /bin/echo instead of echo for
the output with options.

Fixes: 8f381ac4d321 ("selftests/ftrace: Add color to the PASS / FAIL results")
Link: http://lkml.kernel.org/r/cover.1542221862.git.tom.zanussi@linux.intel.com
Reported-by: Tom Zanussi <zanussi@kernel.org>
Suggested-by: Tom Zanussi <zanussi@kernel.org>
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 tools/testing/selftests/ftrace/ftracetest |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Steven Rostedt Nov. 29, 2018, 4:32 p.m. UTC | #1
On Fri, 30 Nov 2018 00:07:43 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:

> Use /bin/echo for console output with options like non
> newline (-n) and/or backslash escape (-e).
> 
> Tom Zanussi reported that when he tested ftracetest, it
> shows "-e" and "-n" options on the console, since a system
> which uses dash as the alias of /bin/sh, uses dash built-in
> echo command which doesn't accept "-e".
> 
> To avoid this issue, use /bin/echo instead of echo for
> the output with options.
> 
> Fixes: 8f381ac4d321 ("selftests/ftrace: Add color to the PASS / FAIL results")
> Link: http://lkml.kernel.org/r/cover.1542221862.git.tom.zanussi@linux.intel.com
> Reported-by: Tom Zanussi <zanussi@kernel.org>
> Suggested-by: Tom Zanussi <zanussi@kernel.org>
> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
> ---
>  tools/testing/selftests/ftrace/ftracetest |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest
> index 75244db70331..ba670b452bdb 100755
> --- a/tools/testing/selftests/ftrace/ftracetest
> +++ b/tools/testing/selftests/ftrace/ftracetest
> @@ -173,8 +173,8 @@ strip_esc() {
>  }
>  
>  prlog() { # messages
> -  echo -e "$@"
> -  [ "$LOG_FILE" ] && echo -e "$@" | strip_esc >> $LOG_FILE
> +  /bin/echo -e "$@"
> +  [ "$LOG_FILE" ] && /bin/echo -e "$@" | strip_esc >> $LOG_FILE
>  }
>  catlog() { #file
>    cat $1

I'm fine with this change but I wonder if we should have a $ECHO that
is defined to something that can be overwritten if need be.

Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

-- Steve
Tom Zanussi Nov. 29, 2018, 4:43 p.m. UTC | #2
Hi Masami,

On Fri, 2018-11-30 at 00:07 +0900, Masami Hiramatsu wrote:
> Use /bin/echo for console output with options like non
> newline (-n) and/or backslash escape (-e).
> 
> Tom Zanussi reported that when he tested ftracetest, it
> shows "-e" and "-n" options on the console, since a system
> which uses dash as the alias of /bin/sh, uses dash built-in
> echo command which doesn't accept "-e".
> 
> To avoid this issue, use /bin/echo instead of echo for
> the output with options.
> 
> Fixes: 8f381ac4d321 ("selftests/ftrace: Add color to the PASS / FAIL
> results")
> Link: http://lkml.kernel.org/r/cover.1542221862.git.tom.zanussi@linux
> .intel.com
> Reported-by: Tom Zanussi <zanussi@kernel.org>
> Suggested-by: Tom Zanussi <zanussi@kernel.org>
> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
> ---
>  tools/testing/selftests/ftrace/ftracetest |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/ftrace/ftracetest
> b/tools/testing/selftests/ftrace/ftracetest
> index 75244db70331..ba670b452bdb 100755
> --- a/tools/testing/selftests/ftrace/ftracetest
> +++ b/tools/testing/selftests/ftrace/ftracetest
> @@ -173,8 +173,8 @@ strip_esc() {
>  }
>  
>  prlog() { # messages
> -  echo -e "$@"
> -  [ "$LOG_FILE" ] && echo -e "$@" | strip_esc >> $LOG_FILE
> +  /bin/echo -e "$@"
> +  [ "$LOG_FILE" ] && /bin/echo -e "$@" | strip_esc >> $LOG_FILE
>  }
>  catlog() { #file
>    cat $1
> 

I tried this on the three systems mentioned before, and it worked fine
on all of them.

Tested-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Steven Rostedt Nov. 29, 2018, 4:49 p.m. UTC | #3
On Thu, 29 Nov 2018 10:43:13 -0600
Tom Zanussi <zanussi@kernel.org> wrote:

> I tried this on the three systems mentioned before, and it worked fine
> on all of them.
> 
> Tested-by: Tom Zanussi <tom.zanussi@linux.intel.com>


Shuah,

Can you take this in your tree. I already acked it.

Thanks!

-- Steve
Tom Zanussi March 4, 2019, 8:09 p.m. UTC | #4
On Thu, 2018-11-29 at 11:49 -0500, Steven Rostedt wrote:
> On Thu, 29 Nov 2018 10:43:13 -0600
> Tom Zanussi <zanussi@kernel.org> wrote:
> 
> > I tried this on the three systems mentioned before, and it worked
> > fine
> > on all of them.
> > 
> > Tested-by: Tom Zanussi <tom.zanussi@linux.intel.com>
> 
> 
> Shuah,
> 
> Can you take this in your tree. I already acked it.
> 

Ping...


> Thanks!
> 
> -- Steve
diff mbox series

Patch

diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest
index 75244db70331..ba670b452bdb 100755
--- a/tools/testing/selftests/ftrace/ftracetest
+++ b/tools/testing/selftests/ftrace/ftracetest
@@ -173,8 +173,8 @@  strip_esc() {
 }
 
 prlog() { # messages
-  echo -e "$@"
-  [ "$LOG_FILE" ] && echo -e "$@" | strip_esc >> $LOG_FILE
+  /bin/echo -e "$@"
+  [ "$LOG_FILE" ] && /bin/echo -e "$@" | strip_esc >> $LOG_FILE
 }
 catlog() { #file
   cat $1