Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: fix build behaviour on targets' failures

Currently, when some of the KSFT subsystems fails to build, the toplevel
KSFT Makefile just keeps carrying on with the build process.

This behaviour is expected and desirable especially in the context of a CI
system running KSelfTest, since it is not always easy to guarantee that the
most recent and esoteric dependencies are respected across all KSFT TARGETS
in a timely manner.

Unfortunately, as of now, this holds true only if the very last of the
built subsystems could have been successfully compiled: if the last of
those subsystem instead failed to build, such failure is taken as the whole
outcome of the Makefile target and the complete build/install process halts
even though many other preceding subsytems were in fact already built
successfully.

Fix the KSFT Makefile behaviour related to all/install targets in order
to fail as a whole only when the all/install targets have failed for all
of the requested TARGETS, while succeeding when at least one of TARGETS
has been successfully built.

Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Cristian Marussi and committed by
Shuah Khan
5f70bde2 c79f46a2

+11 -7
+11 -7
tools/testing/selftests/Makefile
··· 143 143 endif 144 144 145 145 all: khdr 146 - @for TARGET in $(TARGETS); do \ 147 - BUILD_TARGET=$$BUILD/$$TARGET; \ 148 - mkdir $$BUILD_TARGET -p; \ 149 - $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET;\ 150 - done; 146 + @ret=1; \ 147 + for TARGET in $(TARGETS); do \ 148 + BUILD_TARGET=$$BUILD/$$TARGET; \ 149 + mkdir $$BUILD_TARGET -p; \ 150 + $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET; \ 151 + ret=$$((ret * $$?)); \ 152 + done; exit $$ret; 151 153 152 154 run_tests: all 153 155 @for TARGET in $(TARGETS); do \ ··· 198 196 install -m 744 kselftest/module.sh $(INSTALL_PATH)/kselftest/ 199 197 install -m 744 kselftest/runner.sh $(INSTALL_PATH)/kselftest/ 200 198 install -m 744 kselftest/prefix.pl $(INSTALL_PATH)/kselftest/ 201 - @for TARGET in $(TARGETS); do \ 199 + @ret=1; \ 200 + for TARGET in $(TARGETS); do \ 202 201 BUILD_TARGET=$$BUILD/$$TARGET; \ 203 202 $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \ 204 - done; 203 + ret=$$((ret * $$?)); \ 204 + done; exit $$ret; 205 205 206 206 @# Ask all targets to emit their test scripts 207 207 echo "#!/bin/sh" > $(ALL_SCRIPT)