Skip to contentSkip to conversation

selftests/ftrace: Add color to the PASS / FAIL results

PATCH In review Steven Rostedt 3 participants 10 messages Oct 13, 2018 – Oct 16, 2018

Subsystems (2)
lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

PATCH 1/1 selftests/ftrace: Add color to the PASS / FAIL results

From: Steven Rostedt (VMware) <[email protected]>

Now that ftracetest has over 80 tests, it is difficult to simply scroll up the console window to find the failed tests when it reports just two tests have failed. In order to make this stand out better, have the color of the word "PASS" be green, "FAIL" and "XFAIL" be red, and all other results be blue. This helps tremendously in quickly spotting the failed tests by just scrolling up the console window.

---

tools/testing/selftests/ftrace/ftracetest +8 -8
index 5c71d58..4946b2e 100755
@@ -153,7 +153,7 @@ else
 fi
 
 prlog() { # messages
-  [ -z "$LOG_FILE" ] && echo "$@" || echo "$@" | tee -a $LOG_FILE
+  [ -z "$LOG_FILE" ] && echo -e "$@" || echo -e "$@" | tee -a $LOG_FILE
 }
 catlog() { #file
   [ -z "$LOG_FILE" ] && cat $1 || cat $1 | tee -a $LOG_FILE
@@ -195,37 +195,37 @@ test_on_instance() { # testfile
 eval_result() { # sigval
   case $1 in
     $PASS)
-      prlog "	[PASS]"
+      prlog "	[\e[32mPASS\e[30m]"
       PASSED_CASES="$PASSED_CASES $CASENO"
       return 0
     ;;
     $FAIL)
-      prlog "	[FAIL]"
+      prlog "	[\e[31mFAIL\e[30m]"
       FAILED_CASES="$FAILED_CASES $CASENO"
       return 1 # this is a bug.
     ;;
     $UNRESOLVED)
-      prlog "	[UNRESOLVED]"
+      prlog "	[\e[34mUNRESOLVED\e[30m]"
       UNRESOLVED_CASES="$UNRESOLVED_CASES $CASENO"
       return 1 # this is a kind of bug.. something happened.
     ;;
     $UNTESTED)
-      prlog "	[UNTESTED]"
+      prlog "	[\e[34mUNTESTED\e[30m]"
       UNTESTED_CASES="$UNTESTED_CASES $CASENO"
       return 0
     ;;
     $UNSUPPORTED)
-      prlog "	[UNSUPPORTED]"
+      prlog "	[\e[34mUNSUPPORTED\e[30m]"
       UNSUPPORTED_CASES="$UNSUPPORTED_CASES $CASENO"
       return $UNSUPPORTED_RESULT # depends on use case
     ;;
     $XFAIL)
-      prlog "	[XFAIL]"
+      prlog "	[\e[31mXFAIL\e[30m]"
       XFAILED_CASES="$XFAILED_CASES $CASENO"
       return 0
     ;;
     *)
-      prlog "	[UNDEFINED]"
+      prlog "	[\e[34mUNDEFINED\e[30m]"
       UNDEFINED_CASES="$UNDEFINED_CASES $CASENO"
       return 1 # this must be a test bug
     ;;
maintainer
#1 lore raw
Quoted 10 lines · Steven Rostedt

From: Steven Rostedt (VMware) <[email protected]>

Now that ftracetest has over 80 tests, it is difficult to simply scroll up the console window to find the failed tests when it reports just two tests have failed. In order to make this stand out better, have the color of the word "PASS" be green, "FAIL" and "XFAIL" be red, and all other results be blue. This helps tremendously in quickly spotting the failed tests by just scrolling up the console window.

Great. Scroll feature is going to be a great help. I will take this for 4.20-rc1

FYI. Please don't use [email protected] address for sending patches. [email protected] will become absolete due Samsung IT changes.

getmaintainers should give you right address.

thanks,
-- Shuah

author maintainer
#2 lore raw
Quoted 10 lines · On Mon, 15 Oct 2018 07:39:13 -0600 Shuah Khan <[email protected]> wrote:
Quoted 9 lines · Steven Rostedt

From: Steven Rostedt (VMware) <[email protected]>

Now that ftracetest has over 80 tests, it is difficult to simply scroll up the console window to find the failed tests when it reports just two tests have failed. In order to make this stand out better, have the color of the word "PASS" be green, "FAIL" and "XFAIL" be red, and all other results be blue. This helps tremendously in quickly spotting the failed tests by just scrolling up the console window.

Quoted 4 lines
Quoted 1 line

Great. Scroll feature is going to be a great help. I will take this for 4.20-rc1

Great.

Quoted 6 lines

FYI. Please don't use [email protected] address for sending patches. [email protected] will become absolete due Samsung IT changes.

getmaintainers should give you right address.

OK, Thanks for the update. I have to update my address book (as that's what I used).

-- Steve

maintainer Acked-by on v1 1/1
#5 lore raw
In reply to Steven Rostedt
Quoted 9 lines · On Fri, 12 Oct 2018 22:21:06 -0400 Steven Rostedt <[email protected]> wrote:

From: Steven Rostedt (VMware) <[email protected]>

Now that ftracetest has over 80 tests, it is difficult to simply scroll up the console window to find the failed tests when it reports just two tests have failed. In order to make this stand out better, have the color of the word "PASS" be green, "FAIL" and "XFAIL" be red, and all other results be blue. This helps tremendously in quickly spotting the failed tests by just scrolling up the console window.

Looks good to me.

Thanks!

Quoted 60 lines

---

tools/testing/selftests/ftrace/ftracetest +8 -8
index 5c71d58..4946b2e 100755
@@ -153,7 +153,7 @@ else
 fi
 
 prlog() { # messages
-  [ -z "$LOG_FILE" ] && echo "$@" || echo "$@" | tee -a $LOG_FILE
+  [ -z "$LOG_FILE" ] && echo -e "$@" || echo -e "$@" | tee -a $LOG_FILE
 }
 catlog() { #file
   [ -z "$LOG_FILE" ] && cat $1 || cat $1 | tee -a $LOG_FILE
@@ -195,37 +195,37 @@ test_on_instance() { # testfile
 eval_result() { # sigval
   case $1 in
     $PASS)
-      prlog "	[PASS]"
+      prlog "	[\e[32mPASS\e[30m]"
       PASSED_CASES="$PASSED_CASES $CASENO"
       return 0
     ;;
     $FAIL)
-      prlog "	[FAIL]"
+      prlog "	[\e[31mFAIL\e[30m]"
       FAILED_CASES="$FAILED_CASES $CASENO"
       return 1 # this is a bug.
     ;;
     $UNRESOLVED)
-      prlog "	[UNRESOLVED]"
+      prlog "	[\e[34mUNRESOLVED\e[30m]"
       UNRESOLVED_CASES="$UNRESOLVED_CASES $CASENO"
       return 1 # this is a kind of bug.. something happened.
     ;;
     $UNTESTED)
-      prlog "	[UNTESTED]"
+      prlog "	[\e[34mUNTESTED\e[30m]"
       UNTESTED_CASES="$UNTESTED_CASES $CASENO"
       return 0
     ;;
     $UNSUPPORTED)
-      prlog "	[UNSUPPORTED]"
+      prlog "	[\e[34mUNSUPPORTED\e[30m]"
       UNSUPPORTED_CASES="$UNSUPPORTED_CASES $CASENO"
       return $UNSUPPORTED_RESULT # depends on use case
     ;;
     $XFAIL)
-      prlog "	[XFAIL]"
+      prlog "	[\e[31mXFAIL\e[30m]"
       XFAILED_CASES="$XFAILED_CASES $CASENO"
       return 0
     ;;
     *)
-      prlog "	[UNDEFINED]"
+      prlog "	[\e[34mUNDEFINED\e[30m]"
       UNDEFINED_CASES="$UNDEFINED_CASES $CASENO"
       return 1 # this must be a test bug
     ;;
Signature · 1 line
Masami Hiramatsu <[email protected]>
maintainer
#6 lore raw
Quoted 13 lines · On Mon, 15 Oct 2018 23:42:31 +0900 Masami Hiramatsu <[email protected]> wrote:
Quoted 9 lines · On Fri, 12 Oct 2018 22:21:06 -0400 Steven Rostedt <[email protected]> wrote:

From: Steven Rostedt (VMware) <[email protected]>

Now that ftracetest has over 80 tests, it is difficult to simply scroll up the console window to find the failed tests when it reports just two tests have failed. In order to make this stand out better, have the color of the word "PASS" be green, "FAIL" and "XFAIL" be red, and all other results be blue. This helps tremendously in quickly spotting the failed tests by just scrolling up the console window.

Quoted 3 lines

Looks good to me.

Oops, I found some problems.

Quoted 12 lines

Thanks!

Quoted 9 lines

---

tools/testing/selftests/ftrace/ftracetest +0 -0
index 5c71d58..4946b2e 100755
@@ -153,7 +153,7 @@ else
 fi
 
Quoted 3 lines

tools/testing/selftests/ftrace/ftracetest else · line 156

Quoted 3 lines
tools/testing/selftests/ftrace/ftracetest +1 -1
 prlog() { # messages
-  [ -z "$LOG_FILE" ] && echo "$@" || echo "$@" | tee -a $LOG_FILE
+  [ -z "$LOG_FILE" ] && echo -e "$@" || echo -e "$@" | tee -a $LOG_FILE

I think we should strip escape-sequences from log files, like below;

strip_esc() {
sed -E "s/[[:cntrl:]]\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"
}

  [ -z "$LOG_FILE" ] && echo -e "$@" || echo -e "$@" | strip_esc | tee -a $LOG_FILE
Quoted 9 lines

tools/testing/selftests/ftrace/ftracetest test_on_instance() { # testfile · line 198

Quoted 9 lines
tools/testing/selftests/ftrace/ftracetest +1 -1
 }
 catlog() { #file
   [ -z "$LOG_FILE" ] && cat $1 || cat $1 | tee -a $LOG_FILE
@@ -195,37 +195,37 @@ test_on_instance() { # testfile
 eval_result() { # sigval
   case $1 in
     $PASS)
-      prlog "	[PASS]"
+      prlog "	[\e[32mPASS\e[30m]"

The last one should be "\e[0m" (reset), "\e[30m" just set the color "black". That doesn't work on my terminal, which is "white on black".

Thank you,

Signature · 1 line
Masami Hiramatsu
author maintainer
#7 lore raw
Quoted 47 lines · On Wed, 17 Oct 2018 00:26:32 +0900 Masami Hiramatsu <[email protected]> wrote:
Quoted 13 lines · On Mon, 15 Oct 2018 23:42:31 +0900 Masami Hiramatsu <[email protected]> wrote:
Quoted 9 lines · On Fri, 12 Oct 2018 22:21:06 -0400 Steven Rostedt <[email protected]> wrote:

From: Steven Rostedt (VMware) <[email protected]>

Now that ftracetest has over 80 tests, it is difficult to simply scroll up the console window to find the failed tests when it reports just two tests have failed. In order to make this stand out better, have the color of the word "PASS" be green, "FAIL" and "XFAIL" be red, and all other results be blue. This helps tremendously in quickly spotting the failed tests by just scrolling up the console window.

Quoted 3 lines

Looks good to me.

Oops, I found some problems.

Quoted 12 lines

Thanks!

Quoted 9 lines

---

tools/testing/selftests/ftrace/ftracetest +0 -0
index 5c71d58..4946b2e 100755
@@ -153,7 +153,7 @@ else
 fi
 
Quoted 3 lines

tools/testing/selftests/ftrace/ftracetest else · line 156

Quoted 3 lines
tools/testing/selftests/ftrace/ftracetest +1 -1
 prlog() { # messages
-  [ -z "$LOG_FILE" ] && echo "$@" || echo "$@" | tee -a $LOG_FILE
+  [ -z "$LOG_FILE" ] && echo -e "$@" || echo -e "$@" | tee -a $LOG_FILE  

I think we should strip escape-sequences from log files, like below;

strip_esc() {
sed -E "s/[[:cntrl:]]\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"
}

  [ -z "$LOG_FILE" ] && echo -e "$@" || echo -e "$@" | strip_esc | tee -a $LOG_FILE
Quoted 14 lines
Quoted 9 lines

tools/testing/selftests/ftrace/ftracetest test_on_instance() { # testfile · line 198

Quoted 9 lines
tools/testing/selftests/ftrace/ftracetest +1 -1
 }
 catlog() { #file
   [ -z "$LOG_FILE" ] && cat $1 || cat $1 | tee -a $LOG_FILE
@@ -195,37 +195,37 @@ test_on_instance() { # testfile
 eval_result() { # sigval
   case $1 in
     $PASS)
-      prlog "	[PASS]"
+      prlog "	[\e[32mPASS\e[30m]"  

The last one should be "\e[0m" (reset), "\e[30m" just set the color "black". That doesn't work on my terminal, which is "white on black".

Ah thanks for the feedback. Want to write a patch on top, that Shuah can add?

-- Steve

maintainer
#8 lore raw
Quoted 65 lines · Steven Rostedt
Quoted 47 lines · On Wed, 17 Oct 2018 00:26:32 +0900 Masami Hiramatsu <[email protected]> wrote:
Quoted 13 lines · On Mon, 15 Oct 2018 23:42:31 +0900 Masami Hiramatsu <[email protected]> wrote:
Quoted 9 lines · On Fri, 12 Oct 2018 22:21:06 -0400 Steven Rostedt <[email protected]> wrote:

From: Steven Rostedt (VMware) <[email protected]>

Now that ftracetest has over 80 tests, it is difficult to simply scroll up the console window to find the failed tests when it reports just two tests have failed. In order to make this stand out better, have the color of the word "PASS" be green, "FAIL" and "XFAIL" be red, and all other results be blue. This helps tremendously in quickly spotting the failed tests by just scrolling up the console window.

Quoted 3 lines

Looks good to me.

Oops, I found some problems.

Quoted 12 lines

Thanks!

Quoted 9 lines

---

tools/testing/selftests/ftrace/ftracetest +0 -0
index 5c71d58..4946b2e 100755
@@ -153,7 +153,7 @@ else
 fi
 
Quoted 3 lines

tools/testing/selftests/ftrace/ftracetest else · line 156

Quoted 3 lines
tools/testing/selftests/ftrace/ftracetest +1 -1
 prlog() { # messages
-  [ -z "$LOG_FILE" ] && echo "$@" || echo "$@" | tee -a $LOG_FILE
+  [ -z "$LOG_FILE" ] && echo -e "$@" || echo -e "$@" | tee -a $LOG_FILE  

I think we should strip escape-sequences from log files, like below;

strip_esc() {
sed -E "s/[[:cntrl:]]\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"
}

  [ -z "$LOG_FILE" ] && echo -e "$@" || echo -e "$@" | strip_esc | tee -a $LOG_FILE
Quoted 14 lines
Quoted 9 lines

tools/testing/selftests/ftrace/ftracetest test_on_instance() { # testfile · line 198

Quoted 9 lines
tools/testing/selftests/ftrace/ftracetest +1 -1
 }
 catlog() { #file
   [ -z "$LOG_FILE" ] && cat $1 || cat $1 | tee -a $LOG_FILE
@@ -195,37 +195,37 @@ test_on_instance() { # testfile
 eval_result() { # sigval
   case $1 in
     $PASS)
-      prlog "	[PASS]"
+      prlog "	[\e[32mPASS\e[30m]"  

The last one should be "\e[0m" (reset), "\e[30m" just set the color "black". That doesn't work on my terminal, which is "white on black".

Quoted 5 lines

Ah thanks for the feedback. Want to write a patch on top, that Shuah can add?

-- Steve

That will be great. I can apply the updated patch with Masami's Reviewed-by perhaps.

thanks,
-- Shuah

author maintainer
#9 lore raw
Quoted 5 lines · On Tue, 16 Oct 2018 10:40:55 -0600 Shuah Khan <[email protected]> wrote:
Quoted 5 lines
Quoted 4 lines

The last one should be "\e[0m" (reset), "\e[30m" just set the color "black". That doesn't work on my terminal, which is "white on black".

Quoted 8 lines
Quoted 5 lines

Ah thanks for the feedback. Want to write a patch on top, that Shuah can add?

-- Steve

That will be great. I can apply the updated patch with Masami's Reviewed-by perhaps.

I was hoping that Masami could write the patch ;-)

-- Steve