diff mbox series

[D,SRU,1/1] selftests/ftrace: Handle the absence of tput

Message ID 20190530083809.28313-2-po-hsu.lin@canonical.com
State New
Headers show
Series [D,SRU,1/1] selftests/ftrace: Handle the absence of tput | expand

Commit Message

Po-Hsu Lin May 30, 2019, 8:38 a.m. UTC
From: Juerg Haefliger <juerg.haefliger@canonical.com>

BugLink: https://bugs.launchpad.net/bugs/1828989

In environments where tput is not available, we get the following
error
$ ./ftracetest: 163: [: Illegal number:
because ncolors is an empty string. Fix that by setting it to 0 if the
tput command fails.

Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Juerg Haefliger <juergh@canonical.com>
Signed-off-by: Shuah Khan <shuah@kernel.org>
(cherry picked from commit 0e27ded1159f62ab1a4e723796246bd5b1793b93)
Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
---
 tools/testing/selftests/ftrace/ftracetest | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Connor Kuehl June 11, 2019, 8:19 p.m. UTC | #1
On 5/30/19 1:38 AM, Po-Hsu Lin wrote:
> From: Juerg Haefliger <juerg.haefliger@canonical.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1828989
> 
> In environments where tput is not available, we get the following
> error
> $ ./ftracetest: 163: [: Illegal number:
> because ncolors is an empty string. Fix that by setting it to 0 if the
> tput command fails.
> 
> Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
> Signed-off-by: Juerg Haefliger <juergh@canonical.com>
> Signed-off-by: Shuah Khan <shuah@kernel.org>
> (cherry picked from commit 0e27ded1159f62ab1a4e723796246bd5b1793b93)
> Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com
Acked-by: Connor Kuehl <connor.kuehl@canonical.com>

> ---
>  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 384972b..eda42c1 100755
> --- a/tools/testing/selftests/ftrace/ftracetest
> +++ b/tools/testing/selftests/ftrace/ftracetest
> @@ -154,13 +154,13 @@ fi
>  
>  # Define text colors
>  # Check available colors on the terminal, if any
> -ncolors=`tput colors 2>/dev/null`
> +ncolors=`tput colors 2>/dev/null || echo 0`
>  color_reset=
>  color_red=
>  color_green=
>  color_blue=
>  # If stdout exists and number of colors is eight or more, use them
> -if [ -t 1 -a "$ncolors" -a "$ncolors" -ge 8 ]; then
> +if [ -t 1 -a "$ncolors" -ge 8 ]; then
>    color_reset="\033[0m"
>    color_red="\033[31m"
>    color_green="\033[32m"
>
Kleber Sacilotto de Souza June 26, 2019, 4:33 p.m. UTC | #2
On 5/30/19 10:38 AM, Po-Hsu Lin wrote:
> From: Juerg Haefliger <juerg.haefliger@canonical.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1828989
> 
> In environments where tput is not available, we get the following
> error
> $ ./ftracetest: 163: [: Illegal number:
> because ncolors is an empty string. Fix that by setting it to 0 if the
> tput command fails.
> 
> Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
> Signed-off-by: Juerg Haefliger <juergh@canonical.com>
> Signed-off-by: Shuah Khan <shuah@kernel.org>
> (cherry picked from commit 0e27ded1159f62ab1a4e723796246bd5b1793b93)
> Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>

Clean cherry-pick, limited to selftests.

Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>

Thank you,
Kleber
> ---
>  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 384972b..eda42c1 100755
> --- a/tools/testing/selftests/ftrace/ftracetest
> +++ b/tools/testing/selftests/ftrace/ftracetest
> @@ -154,13 +154,13 @@ fi
>  
>  # Define text colors
>  # Check available colors on the terminal, if any
> -ncolors=`tput colors 2>/dev/null`
> +ncolors=`tput colors 2>/dev/null || echo 0`
>  color_reset=
>  color_red=
>  color_green=
>  color_blue=
>  # If stdout exists and number of colors is eight or more, use them
> -if [ -t 1 -a "$ncolors" -a "$ncolors" -ge 8 ]; then
> +if [ -t 1 -a "$ncolors" -ge 8 ]; then
>    color_reset="\033[0m"
>    color_red="\033[31m"
>    color_green="\033[32m"
>
diff mbox series

Patch

diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest
index 384972b..eda42c1 100755
--- a/tools/testing/selftests/ftrace/ftracetest
+++ b/tools/testing/selftests/ftrace/ftracetest
@@ -154,13 +154,13 @@  fi
 
 # Define text colors
 # Check available colors on the terminal, if any
-ncolors=`tput colors 2>/dev/null`
+ncolors=`tput colors 2>/dev/null || echo 0`
 color_reset=
 color_red=
 color_green=
 color_blue=
 # If stdout exists and number of colors is eight or more, use them
-if [ -t 1 -a "$ncolors" -a "$ncolors" -ge 8 ]; then
+if [ -t 1 -a "$ncolors" -ge 8 ]; then
   color_reset="\033[0m"
   color_red="\033[31m"
   color_green="\033[32m"