lkml.org 
[lkml]   [2019]   [Feb]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] selftests/ftrace: Make the coloring POSIX compliant
Hi Juerg,

On Wed, 20 Feb 2019 17:13:33 +0100
Juerg Haefliger <juerg.haefliger@canonical.com> wrote:

> echo -e and \e are not POSIX. Depending on what /bin/sh is, we can get
> incorrect output like:
> $ -e -n [1] Basic trace file check
> $ -e [PASS]
>
> Fix that by using \033 instead of \e and printf.

OK, as far as I can check with checkbashisms, echo -e is not acceptable.

$ checkbashisms ./ftracetest
possible bashism in ./ftracetest line 176 (echo -e):
echo -e "$@"
possible bashism in ./ftracetest line 177 (echo -e):
[ "$LOG_FILE" ] && echo -e "$@" | strip_esc >> $LOG_FILE

So it should be fixed, even other shells support it.
(Or, update checkbashisms command...)

However,

> prlog() { # messages
> - echo -e "$@"
> - [ "$LOG_FILE" ] && echo -e "$@" | strip_esc >> $LOG_FILE
> + newline="\n"
> + if [ "$1" = "-n" ] ; then
> + newline=
> + shift
> + fi
> + printf "$@$newline"
> + [ "$LOG_FILE" ] && printf "$@$newline" | strip_esc >> $LOG_FILE

This doesn't work when prlog gets several arguments. (like the summary line)
for example I got below result.

# of passed: # of failed: # of unresolved: # of untested: # of unsupported: # of xfailed: # of undefined(test bug):

Replacing $@ with $* shows correct result. Could you fix it?

Thank you,


--
Masami Hiramatsu <mhiramat@kernel.org>

\
 
 \ /
  Last update: 2019-02-22 01:30    [W:0.117 / U:0.280 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site