Skip to content

Commit

Permalink
selftests/ftrace: Strip escape sequences for log file
Browse files Browse the repository at this point in the history
Strip escape sequences from the stream to the ftracetest
summary log file. Note that all test-case results are
dumped raw in each file.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
  • Loading branch information
Masami Hiramatsu authored and Shuah Khan (Samsung OSG) committed Oct 24, 2018
1 parent 8096fbc commit f73581f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tools/testing/selftests/ftrace/ftracetest
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,18 @@ if [ -t 1 -a "$ncolors" -a "$ncolors" -ge 8 ]; then
color_blue="\e[34m"
fi

strip_esc() {
# busybox sed implementation doesn't accept "\x1B", so use [:cntrl:] instead.
sed -E "s/[[:cntrl:]]\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"
}

prlog() { # messages
[ -z "$LOG_FILE" ] && echo -e "$@" || echo -e "$@" | tee -a $LOG_FILE
echo -e "$@"
[ "$LOG_FILE" ] && echo -e "$@" | strip_esc >> $LOG_FILE
}
catlog() { #file
[ -z "$LOG_FILE" ] && cat $1 || cat $1 | tee -a $LOG_FILE
cat $1
[ "$LOG_FILE" ] && cat $1 | strip_esc >> $LOG_FILE
}
prlog "=== Ftrace unit tests ==="

Expand Down

0 comments on commit f73581f

Please sign in to comment.