Skip to content

Commit 7e47389

Browse files
rbmarliereshuahkh
authored andcommitted
selftests: Preserve subtarget failures in all/install
Track failures explicitly in the top-level selftests all/install loops. The current code multiplies `ret` by each sub-make exit status. For example, with `TARGETS=net`, the implicit `net/lib` dependency runs after `net`, so a failed `net` build can be followed by a successful `net/lib` build and reset the final result to success. Set `ret` to 1 on any non-zero sub-make exit code and keep it sticky, so the top-level make returns failure when any selected selftest target fails. Signed-off-by: Ricardo B. Marlière <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Shuah Khan <[email protected]>
1 parent d6ea9f4 commit 7e47389

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

tools/testing/selftests/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,14 @@ export KHDR_INCLUDES
209209
.DEFAULT_GOAL := all
210210

211211
all:
212-
@ret=1; \
212+
@ret=0; \
213213
for TARGET in $(TARGETS) $(INSTALL_DEP_TARGETS); do \
214214
BUILD_TARGET=$$BUILD/$$TARGET; \
215215
mkdir $$BUILD_TARGET -p; \
216216
$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET \
217217
O=$(abs_objtree) \
218218
$(if $(FORCE_TARGETS),|| exit); \
219-
ret=$$((ret * $$?)); \
219+
[ $$? -eq 0 ] || ret=1; \
220220
done; exit $$ret;
221221

222222
run_tests: all
@@ -274,7 +274,7 @@ ifdef INSTALL_PATH
274274
install -m 744 kselftest/ksft.py $(INSTALL_PATH)/kselftest/
275275
install -m 744 run_kselftest.sh $(INSTALL_PATH)/
276276
rm -f $(TEST_LIST)
277-
@ret=1; \
277+
@ret=0; \
278278
for TARGET in $(TARGETS) $(INSTALL_DEP_TARGETS); do \
279279
BUILD_TARGET=$$BUILD/$$TARGET; \
280280
$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install \
@@ -283,7 +283,7 @@ ifdef INSTALL_PATH
283283
OBJ_PATH=$(INSTALL_PATH) \
284284
O=$(abs_objtree) \
285285
$(if $(FORCE_TARGETS),|| exit); \
286-
ret=$$((ret * $$?)); \
286+
[ $$? -eq 0 ] || ret=1; \
287287
done; exit $$ret;
288288

289289

0 commit comments

Comments
 (0)