The futex suite builds its tests in the functional subdirectory and then
copies run.sh into the output directory. The copy is the last command of
the loop, so its status replaces that of the build, and "make all"
succeeds even when the functional tests fail to compile.
Fold the copy into the status of the subdirectory, count a failure to
create the output directory as well, and let the build and installation
loops return failure when no subdirectory succeeds, which matches how the
top-level selftests Makefile treats its targets, or as soon as one fails
when FORCE_TARGETS is set. When a build report is requested, record each
subdirectory as futex/<subdir> so that a failure is visible even when
make itself succeeds.
Fixes: 9c3340ea7f5d ("selftests: futex: copy sub-dir test scripts for make
O=dir run")
Fixes: 9705315b7562 ("selftests/futex: Update Makefile to use lib.mk")
Signed-off-by: Sasha Levin <[email protected]>
---
tools/testing/selftests/futex/Makefile | 32 +++++++++++++++++---------
1 file changed, 21 insertions(+), 11 deletions(-)
diff --git a/tools/testing/selftests/futex/Makefile
b/tools/testing/selftests/futex/Makefile
index 78ab2cd111f60..d6923775b8d49 100644
--- a/tools/testing/selftests/futex/Makefile
+++ b/tools/testing/selftests/futex/Makefile
@@ -4,26 +4,36 @@ SUBDIRS := functional
TEST_PROGS := run.sh
include ../lib.mk
+include $(selfdir)/build_report.mk
all:
- @for DIR in $(SUBDIRS); do \
- BUILD_TARGET=$(OUTPUT)/$$DIR; \
- mkdir $$BUILD_TARGET -p; \
- $(MAKE) OUTPUT=$$BUILD_TARGET -C $$DIR $@;\
- if [ -e $$DIR/$(TEST_PROGS) ]; then \
- rsync -a $$DIR/$(TEST_PROGS) $$BUILD_TARGET/; \
- fi \
- done
+ @ret=$(if $(SUBDIRS),1,0); for DIR in $(SUBDIRS); do \
+ BUILD_TARGET=$(OUTPUT)/$$DIR; \
+ mkdir -p $$BUILD_TARGET && \
+ $(MAKE) OUTPUT=$$BUILD_TARGET -C $$DIR $@; \
+ status=$$?; \
+ if [ -e $$DIR/$(TEST_PROGS) ]; then \
+ rsync -a $$DIR/$(TEST_PROGS) $$BUILD_TARGET/ || \
+ [ $$status -ne 0 ] || status=1; \
+ fi; \
+ $(call ksft_record_build_status,all,futex/$$DIR); \
+ $(if $(FORCE_TARGETS),[ $$status -eq 0 ] || exit $$status;) \
+ [ $$status -eq 0 ] && ret=0; \
+ done; exit $$ret
override define INSTALL_RULE
mkdir -p $(INSTALL_PATH)
install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED)
$(TEST_FILES)
- @for SUBDIR in $(SUBDIRS); do \
+ @ret=$(if $(SUBDIRS),1,0); for SUBDIR in $(SUBDIRS); do \
BUILD_TARGET=$(OUTPUT)/$$SUBDIR; \
- mkdir $$BUILD_TARGET -p; \
+ mkdir -p $$BUILD_TARGET && \
$(MAKE) OUTPUT=$$BUILD_TARGET -C $$SUBDIR
INSTALL_PATH=$(INSTALL_PATH)/$$SUBDIR install; \
- done;
+ status=$$?; \
+ $(call ksft_record_build_status,install,futex/$$SUBDIR); \
+ $(if $(FORCE_TARGETS),[ $$status -eq 0 ] || exit $$status;) \
+ [ $$status -eq 0 ] && ret=0; \
+ done; exit $$ret
endef
override define CLEAN
--
2.53.0