]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests: Preserve subtarget failures in all/install
authorRicardo B. Marlière <rbm@suse.com>
Fri, 20 Mar 2026 18:29:20 +0000 (15:29 -0300)
committerShuah Khan <skhan@linuxfoundation.org>
Mon, 13 Apr 2026 17:05:39 +0000 (11:05 -0600)
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 <rbm@suse.com>
Link: https://lore.kernel.org/r/20260320-selftests-fixes-v1-5-79144f76be01@suse.com
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/Makefile

index 450f13ba4cca98836bc8a2fe18a2eb43ce14b2d5..0949f370ad7866e8eb2af68099619c2ca3c75df8 100644 (file)
@@ -209,14 +209,14 @@ export KHDR_INCLUDES
 .DEFAULT_GOAL := all
 
 all:
-       @ret=1;                                                 \
+       @ret=0;                                                 \
        for TARGET in $(TARGETS) $(INSTALL_DEP_TARGETS); do     \
                BUILD_TARGET=$$BUILD/$$TARGET;                  \
                mkdir $$BUILD_TARGET  -p;                       \
                $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET       \
                                O=$(abs_objtree)                \
                                $(if $(FORCE_TARGETS),|| exit); \
-               ret=$$((ret * $$?));                            \
+               [ $$? -eq 0 ] || ret=1;                 \
        done; exit $$ret;
 
 run_tests: all
@@ -274,7 +274,7 @@ ifdef INSTALL_PATH
        install -m 744 kselftest/ksft.py $(INSTALL_PATH)/kselftest/
        install -m 744 run_kselftest.sh $(INSTALL_PATH)/
        rm -f $(TEST_LIST)
-       @ret=1; \
+       @ret=0; \
        for TARGET in $(TARGETS) $(INSTALL_DEP_TARGETS); do \
                BUILD_TARGET=$$BUILD/$$TARGET;  \
                $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install \
@@ -283,7 +283,7 @@ ifdef INSTALL_PATH
                                OBJ_PATH=$(INSTALL_PATH) \
                                O=$(abs_objtree)                \
                                $(if $(FORCE_TARGETS),|| exit); \
-               ret=$$((ret * $$?));            \
+               [ $$? -eq 0 ] || ret=1;         \
        done; exit $$ret;