Skip to contentSkip to conversation

selftests/ftrace: Handle the absence of tput

PATCH Superseded Juerg Haefliger 4 participants 7 messages Feb 20, 2019 – Feb 25, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/ftrace: Handle the absence of tput

In environments where tput is not availbale, 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.
---
 tools/testing/selftests/ftrace/ftracetest | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/ftrace/ftracetest +2 -2
index 75244db70331..fc755e1b50f1 100755
@@ -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="\e[0m"
   color_red="\e[31m"
   color_green="\e[32m"
Signature · 1 line
2.19.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 1 line · On Wed, 20 Feb 2019 16:37:06 +0100 Juerg Haefliger…

In environments where tput is not availbale, we get the following

available

Quoted 6 lines

error

$ ./ftracetest: 163: [: Illegal number:
because ncolors is an empty string. Fix that by setting it to 0 if the
tput command fails.

-- Steve

Quoted 24 lines
---
 tools/testing/selftests/ftrace/ftracetest | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/ftrace/ftracetest +2 -2
index 75244db70331..fc755e1b50f1 100755
@@ -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="\e[0m"
   color_red="\e[31m"
   color_green="\e[32m"
maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Juerg Haefliger
Quoted 7 lines · On Wed, 20 Feb 2019 16:37:06 +0100 Juerg Haefliger…

In environments where tput is not availbale, 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.

Looks good to me.

Thank you!

Quoted 27 lines
---
 tools/testing/selftests/ftrace/ftracetest | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/ftrace/ftracetest +2 -2
index 75244db70331..fc755e1b50f1 100755
@@ -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="\e[0m"
   color_red="\e[31m"
   color_green="\e[32m"
Signature · 1 line
2.19.1
Signature · 1 line
Masami Hiramatsu <[email protected]>
maintainer Acked-by
#3 lore raw
Quoted 9 lines · On Fri, 22 Feb 2019 09:05:34 +0900 Masami Hiramatsu <[email protected]> wrote:
Quoted 6 lines · On Wed, 20 Feb 2019 16:37:06 +0100 Juerg Haefliger…

In environments where tput is not availbale, 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.
Quoted 5 lines
Quoted 1 line

Looks good to me.

Shuah,

Want to take this?

https://lore.kernel.org/lkml/[email protected]/T/#u

-- Steve

Quoted 32 lines

Thank you!

Quoted 27 lines
---
 tools/testing/selftests/ftrace/ftracetest | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/ftrace/ftracetest +2 -2
index 75244db70331..fc755e1b50f1 100755
@@ -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="\e[0m"
   color_red="\e[31m"
   color_green="\e[32m"
Signature · 1 line
2.19.1
#4 lore raw

PATCH RESEND 1/1 selftests/ftrace: Handle the absence of tput

In reply to Juerg Haefliger

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 at goodmis.org>
Acked-by Masami Hiramatsu <mhiramat at kernel.org>
Signed-off-by Juerg Haefliger <juergh at canonical.com>
---
 tools/testing/selftests/ftrace/ftracetest | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/ftrace/ftracetest +2 -2
index 75244db70331..fc755e1b50f1 100755
@@ -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="\e[0m"
   color_red="\e[31m"
   color_green="\e[32m"
Signature · 1 line
2.19.1
maintainer
#5 lore raw
Quoted 24 lines · Juerg Haefliger

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 at goodmis.org>
Acked-by Masami Hiramatsu <mhiramat at kernel.org>
Signed-off-by Juerg Haefliger <juergh at canonical.com>
---
  tools/testing/selftests/ftrace/ftracetest | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/ftrace/ftracetest +1 -1
index 75244db70331..fc755e1b50f1 100755
@@ -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`

tools/testing/selftests/ftrace/ftracetest fi · line 166

Quoted 10 lines
tools/testing/selftests/ftrace/ftracetest +1 -1
  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="\e[0m"
    color_red="\e[31m"
    color_green="\e[32m"

Juerg!

Thanks for the resend. Applied to linux-kselftest next for 5.1-rc1.

Since I applied this patch out of order, I had to resolve minor merge conflict. Please review.

thanks,
-- Shuah

#6 lore raw
Quoted 38 lines · On Mon, 25 Feb 2019 07:51:13 -0700 shuah <[email protected]> wrote:
Quoted 24 lines · Juerg Haefliger

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 at goodmis.org>
Acked-by Masami Hiramatsu <mhiramat at kernel.org>
Signed-off-by Juerg Haefliger <juergh at canonical.com>
---
  tools/testing/selftests/ftrace/ftracetest | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/ftrace/ftracetest +1 -1
index 75244db70331..fc755e1b50f1 100755
@@ -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`

tools/testing/selftests/ftrace/ftracetest fi · line 166

Quoted 10 lines
tools/testing/selftests/ftrace/ftracetest +1 -1
  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="\e[0m"
    color_red="\e[31m"
    color_green="\e[32m"

Juerg!

Quoted 4 lines

Thanks for the resend. Applied to linux-kselftest next for 5.1-rc1.

Since I applied this patch out of order, I had to resolve minor merge conflict. Please review.

Looks good.

Thanks Shuah!
..Juerg

Quoted 2 lines

thanks,
-- Shuah

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.linaro.org/pipermail/linux-kselftest-mirror/attachments/20190225/7ddcf672/attachment-0001.sig>