[PATCH v1 02/22] selftests/nolibc: print result to the screen too

From: Zhangjin Wu
Date: Sun Jun 25 2023 - 12:13:52 EST


printing the running log to the screen helps users to learn what
happens, especially to find potential issues immediately.

If want to silence a lot, simply pass a QUIET_RUN=1 is enough.

Signed-off-by: Zhangjin Wu <falcon@xxxxxxxxxxx>
---
tools/testing/selftests/nolibc/Makefile | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile
index 0b66b7a79cea..3300b5ab7de3 100644
--- a/tools/testing/selftests/nolibc/Makefile
+++ b/tools/testing/selftests/nolibc/Makefile
@@ -98,6 +98,14 @@ CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 \
$(CFLAGS_$(ARCH)) $(CFLAGS_STACKPROTECTOR)
LDFLAGS := -s

+# allow silence the running test log
+QUIET_RUN ?= 0
+ifeq ($(QUIET_RUN),0)
+LOG_OUTPUT = | tee "$(CURDIR)/run.out"
+else
+LOG_OUTPUT = > "$(CURDIR)/run.out"
+endif
+
REPORT ?= awk '/\[OK\][\r]*$$/{p++} /\[FAIL\][\r]*$$/{f++;print} /\[SKIPPED\][\r]*$$/{s++} \
END{ printf("%d test(s) passed, %d skipped, %d failed.\n", p, s, f); \
printf("See all results in %s\n", ARGV[1]); }'
@@ -157,7 +165,7 @@ libc-test: nolibc-test.c

# qemu user-land test
run-user: nolibc-test
- $(Q)qemu-$(QEMU_ARCH) ./nolibc-test > "$(CURDIR)/run.out" || :
+ $(Q)qemu-$(QEMU_ARCH) ./nolibc-test $(LOG_OUTPUT) || :
$(Q)$(REPORT) $(CURDIR)/run.out

initramfs: nolibc-test
@@ -173,12 +181,12 @@ kernel: initramfs

# run the tests after building the kernel
run: kernel
- $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(srctree)/$(IMAGE)" -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out"
+ $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(srctree)/$(IMAGE)" -serial stdio $(QEMU_ARGS) $(LOG_OUTPUT)
$(Q)$(REPORT) $(CURDIR)/run.out

# re-run the tests from an existing kernel
rerun:
- $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(srctree)/$(IMAGE)" -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out"
+ $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(srctree)/$(IMAGE)" -serial stdio $(QEMU_ARGS) $(LOG_OUTPUT)
$(Q)$(REPORT) $(CURDIR)/run.out

clean:
--
2.25.1