[PATCH v1 21/22] selftests/nolibc: allow run tests on all targets

From: Zhangjin Wu
Date: Sun Jun 25 2023 - 12:44:26 EST


This lists all of the supported architectures and allow testing for all
of them.

These targets are supported:

- run-user-all: testing run-user for all architectures
- run-all / run-default-all: testing run-default for all architectures
- run-tiny-all: testing run-tiny for all architectures

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

diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile
index 3e7e51bd7082..470923dc10e1 100644
--- a/tools/testing/selftests/nolibc/Makefile
+++ b/tools/testing/selftests/nolibc/Makefile
@@ -164,6 +164,18 @@ ifeq (run-default, $(MAKECMDGOALS))
AUTOCONFIG ?= defconfig
endif

+# allow run tests on all architectures: run-user-all, run-all (=run-default-all), run-tiny-all
+ARCHS ?= $(shell sed -ne 's/^DEFCONFIG_\([^ ]*\) .*/\1/p' $(CURDIR)/Makefile)
+GOALS ?= run-user run-tiny run-default
+RUN_ALL ?= _t=$@; t=$${_t%-all}; [ "$$t" = "run" ] && t=run-default; \
+ if echo $(GOALS) | grep -wq "$$t"; then \
+ for a in $(ARCHS); do echo "Testing $$t for $${a}:"; make $$t ARCH=$$a; cp $(CURDIR)/run.out $(CURDIR)/run-$$a.out; done; \
+ echo "\n\nTesting summary of $$t:\n"; \
+ for a in $(ARCHS); do echo $${a}:; echo; $(REPORT) $(CURDIR)/run-$$a.out; echo; done; \
+ else \
+ echo "Ignoring unknown target: $$t, available targets: $(GOALS)"; \
+ fi
+
# allow switch nolibc headers include method: 1 for sysroot, 0 for nolibc.h
SYSROOT ?= 1

@@ -255,6 +267,10 @@ rerun:
$(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(srctree)/$(IMAGE)" -serial stdio $(QEMU_ARGS) $(LOG_OUTPUT)
$(Q)$(REPORT) $(CURDIR)/run.out

+# test for all architectures
+%-all:
+ $(Q)$(RUN_ALL)
+
clean:
$(call QUIET_CLEAN, sysroot)
$(Q)rm -rf sysroot
--
2.25.1