The arm64 suite builds and installs its subdirectories in shell loops
whose status is that of the last subdirectory. A failure in an earlier
subdirectory is therefore lost unless FORCE_TARGETS is set, while a
failure in the last one fails "make all" and, through "install: all",
drops the installation of every other arm64 test as well.

Make each loop fail only when no subdirectory succeeds, which matches
how the top-level selftests Makefile treats its targets, and keep
stopping at the first failure when FORCE_TARGETS is set. When a build
report is requested, record each subdirectory as arm64/<subdir> so that
a partially built suite is visible even though make succeeds.

Invoke the subdirectories with $(MAKE) rather than make. The command
line variables already reach them through MAKEFLAGS either way, but
$(MAKE) lets them use the parent's jobserver and makes -n, -t and -q
apply to them.

Fixes: 313a4db7f338 ("kselftest: arm64: extend toplevel skeleton Makefile")
Signed-off-by: Sasha Levin <[email protected]>
---
 tools/testing/selftests/arm64/Makefile | 43 +++++++++++++++++---------
 1 file changed, 29 insertions(+), 14 deletions(-)

diff --git a/tools/testing/selftests/arm64/Makefile 
b/tools/testing/selftests/arm64/Makefile
index e456f3b62fa13..c787e848d4718 100644
--- a/tools/testing/selftests/arm64/Makefile
+++ b/tools/testing/selftests/arm64/Makefile
@@ -26,38 +26,53 @@ OUTPUT ?= $(CURDIR)
 export CFLAGS
 export top_srcdir
 
+include $(top_srcdir)/tools/testing/selftests/build_report.mk
+
 all:
-       @for DIR in $(ARM64_SUBTARGETS); do                             \
+       @ret=$(if $(ARM64_SUBTARGETS),1,0);                             \
+       for DIR in $(ARM64_SUBTARGETS); do                              \
                BUILD_TARGET=$(OUTPUT)/$$DIR;                   \
-               mkdir -p $$BUILD_TARGET;                        \
-               make OUTPUT=$$BUILD_TARGET -C $$DIR $@          \
-                       $(if $(FORCE_TARGETS),|| exit); \
-       done
+               mkdir -p $$BUILD_TARGET &&                      \
+               $(MAKE) OUTPUT=$$BUILD_TARGET -C $$DIR $@;      \
+               status=$$?;                                     \
+               $(call ksft_record_build_status,all,arm64/$$DIR); \
+               $(if $(FORCE_TARGETS),[ $$status -eq 0 ] || exit $$status;) \
+               [ $$status -eq 0 ] && ret=0;                    \
+       done; exit $$ret
 
 install: all
-       @for DIR in $(ARM64_SUBTARGETS); do                             \
+       @ret=$(if $(ARM64_SUBTARGETS),1,0);                             \
+       for DIR in $(ARM64_SUBTARGETS); do                              \
                BUILD_TARGET=$(OUTPUT)/$$DIR;                   \
-               make OUTPUT=$$BUILD_TARGET -C $$DIR $@          \
-                       $(if $(FORCE_TARGETS),|| exit); \
-       done
+               $(MAKE) OUTPUT=$$BUILD_TARGET -C $$DIR $@;      \
+               status=$$?;                                     \
+               $(call ksft_record_build_status,install,arm64/$$DIR); \
+               $(if $(FORCE_TARGETS),[ $$status -eq 0 ] || exit $$status;) \
+               [ $$status -eq 0 ] && ret=0;                    \
+       done; exit $$ret
 
 run_tests: all
        @for DIR in $(ARM64_SUBTARGETS); do                             \
                BUILD_TARGET=$(OUTPUT)/$$DIR;                   \
-               make OUTPUT=$$BUILD_TARGET -C $$DIR $@;         \
+               $(MAKE) OUTPUT=$$BUILD_TARGET -C $$DIR $@;      \
        done
 
 # Avoid any output on non arm64 on emit_tests
 emit_tests:
-       @for DIR in $(ARM64_SUBTARGETS); do                             \
+       @ret=$(if $(ARM64_SUBTARGETS),1,0);                             \
+       for DIR in $(ARM64_SUBTARGETS); do                              \
                BUILD_TARGET=$(OUTPUT)/$$DIR;                   \
-               make OUTPUT=$$BUILD_TARGET -C $$DIR $@;         \
-       done
+               $(MAKE) OUTPUT=$$BUILD_TARGET -C $$DIR $@;      \
+               status=$$?;                                     \
+               $(call ksft_record_build_status,install,arm64/$$DIR); \
+               $(if $(FORCE_TARGETS),[ $$status -eq 0 ] || exit $$status;) \
+               [ $$status -eq 0 ] && ret=0;                    \
+       done; exit $$ret
 
 clean:
        @for DIR in $(ARM64_SUBTARGETS); do                             \
                BUILD_TARGET=$(OUTPUT)/$$DIR;                   \
-               make OUTPUT=$$BUILD_TARGET -C $$DIR $@;         \
+               $(MAKE) OUTPUT=$$BUILD_TARGET -C $$DIR $@;      \
        done
 
 .PHONY: all clean install run_tests emit_tests
-- 
2.53.0


Reply via email to