[v1,3/5] selftests/nolibc: report: align passed, skipped and failed

Message ID 9620a07294e4c099587170e84aba167bf849e841.1688633188.git.falcon@tinylab.org
State New
Headers
Series selftests/nolibc: report: print test status |

Commit Message

Zhangjin Wu July 6, 2023, 9:10 a.m. UTC
  align the test values for different runs and different architectures.

Since the total number of tests is not bigger than 1000 currently, let's
align them with "%03d".

Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
---
 tools/testing/selftests/nolibc/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Willy Tarreau July 9, 2023, 8:51 a.m. UTC | #1
On Thu, Jul 06, 2023 at 05:10:08PM +0800, Zhangjin Wu wrote:
> align the test values for different runs and different architectures.
> 
> Since the total number of tests is not bigger than 1000 currently, let's
> align them with "%03d".

%03d is not great for those who want to use them in scripts because it will
prepend zeroes. Better use %3d. Look for example:

  $ x=$(printf "%03d\n" 19)
  $ echo $x
  019
  $ echo $((x+1))
  -bash: 019: value too great for base (error token is "019")

Instead:

  $ printf "%3d\n" 19
   19
  $ x=$(printf "%3d\n" 19)
  $ echo $x
  19
  $ echo $((x+1))
  20

If you're fine with it I'll change your patch and commit message
accordingly.

Willy
  
Zhangjin Wu July 9, 2023, 6:51 p.m. UTC | #2
Hi, Willy

> On Thu, Jul 06, 2023 at 05:10:08PM +0800, Zhangjin Wu wrote:
> > align the test values for different runs and different architectures.
> > 
> > Since the total number of tests is not bigger than 1000 currently, let's
> > align them with "%03d".
> 
> %03d is not great for those who want to use them in scripts because it will
> prepend zeroes. Better use %3d. Look for example:
> 
>   $ x=$(printf "%03d\n" 19)
>   $ echo $x
>   019
>   $ echo $((x+1))
>   -bash: 019: value too great for base (error token is "019")
>

I have tried both '%03d' and '%3d' locally, but used '%03d' at last.

    190 passed, 021 skipped, 001 failed
    190 passed,  21 skipped,   1 failed

Beside the calculate issue you pointed out, the 0 prefix although align
all of them with 'numbers' but also bring us some noises, filling the
left parts as whitespaces really looks better.

> Instead:
> 
>   $ printf "%3d\n" 19
>    19
>   $ x=$(printf "%3d\n" 19)
>   $ echo $x
>   19
>   $ echo $((x+1))
>   20
> 
> If you're fine with it I'll change your patch and commit message
> accordingly.

Ok, let's use '%3d' instead of '%03d'.

Thanks,
Zhangjin

> 
> Willy
  

Patch

diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile
index a02be8b0a569..2c53bf41967b 100644
--- a/tools/testing/selftests/nolibc/Makefile
+++ b/tools/testing/selftests/nolibc/Makefile
@@ -85,7 +85,7 @@  CFLAGS  ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 \
 LDFLAGS := -s
 
 REPORT  ?= awk '/\[OK\][\r]*$$/{p++} /\[FAIL\][\r]*$$/{f++;print} /\[SKIPPED\][\r]*$$/{s++} \
-		END{ printf("%d test(s): %d passed, %d skipped, %d failed => status: ", p+s+f, p, s, f); \
+		END{ printf("%03d test(s): %03d passed, %03d skipped, %03d failed => status: ", p+s+f, p, s, f); \
 		if (f) printf("failure\n"); else if (s) printf("warning\n"); else printf("success\n");; \
 		printf("See all results in %s\n", ARGV[1]); }'