public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
From: "Ricardo B. Marlière" <rbm@suse.com>
To: Shuah Khan <shuah@kernel.org>,
	Nathan Chancellor <nathan@kernel.org>,
	 Nicolas Schier <nsc@kernel.org>
Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kbuild@vger.kernel.org,
	"Ricardo B. Marlière" <rbm@suse.com>
Subject: [PATCH 5/6] selftests: Preserve subtarget failures in all/install
Date: Fri, 20 Mar 2026 15:29:20 -0300	[thread overview]
Message-ID: <20260320-selftests-fixes-v1-5-79144f76be01@suse.com> (raw)
In-Reply-To: <20260320-selftests-fixes-v1-0-79144f76be01@suse.com>

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>
---
 tools/testing/selftests/Makefile | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 450f13ba4cca..0949f370ad78 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -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;
 
 

-- 
2.53.0


  parent reply	other threads:[~2026-03-20 18:29 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-20 18:29 [PATCH 0/6] selftests: run_kselftest.sh cleanup and fixes Ricardo B. Marlière
2026-03-20 18:29 ` [PATCH 1/6] selftests/run_kselftest.sh: Remove unused $ROOT Ricardo B. Marlière
2026-03-20 18:29 ` [PATCH 2/6] selftests/run_kselftest.sh: Add missing quotes Ricardo B. Marlière
2026-03-20 18:29 ` [PATCH 3/6] selftests/run_kselftest.sh: Resolve BASE_DIR with pwd -P Ricardo B. Marlière
2026-03-20 18:29 ` [PATCH 4/6] selftests/run_kselftest.sh: Allow choosing per-test log directory Ricardo B. Marlière
2026-03-20 18:29 ` Ricardo B. Marlière [this message]
2026-04-15 13:58   ` [PATCH 5/6] selftests: Preserve subtarget failures in all/install Mark Brown
2026-04-15 15:40     ` Shuah Khan
2026-04-15 15:42       ` Ricardo B. Marlière
2026-04-15 15:52         ` Shuah Khan
2026-04-15 15:53           ` Ricardo B. Marlière
2026-04-15 16:25       ` Mark Brown
2026-04-15 16:39         ` Shuah Khan
2026-03-20 18:29 ` [PATCH 6/6] kbuild: remove kselftest output in mrproper Ricardo B. Marlière
2026-04-10 19:19   ` Shuah Khan
2026-04-11 12:49     ` Ricardo B. Marlière
2026-04-13 15:58       ` Shuah Khan
2026-04-13 16:22         ` Ricardo B. Marlière
2026-03-31 22:43 ` [PATCH 0/6] selftests: run_kselftest.sh cleanup and fixes Shuah Khan
2026-04-01 11:45   ` Ricardo B. Marlière

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260320-selftests-fixes-v1-5-79144f76be01@suse.com \
    --to=rbm@suse.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=nathan@kernel.org \
    --cc=nsc@kernel.org \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox