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

selftests: allow detection of build failures

Commit 5f70bde26a48 ("selftests: fix build behaviour on targets' failures")
added a logic to track failure of builds of individual targets. However, it
does exactly the opposite of what a distro kernel needs: we create a RPM
package with a selected set of selftests and we need the build to fail if
build of any of the targets fail.

Both use cases are valid. A distribution kernel is in control of what is
included in the kernel and what is being built; any error needs to be
flagged and acted upon. A CI system that tries to build as many tests as
possible on the best effort basis is not really interested in a failure here
and there.

Support both use cases by introducing a FORCE_TARGETS variable. It is
switched off by default to make life for CI systems easier, distributions
can easily switch it on while building their packages.

Reported-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
Signed-off-by: Jiri Benc <jbenc@redhat.com>
Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
Tested-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Jiri Benc and committed by
Shuah Khan
9d235a55 b32694cd

+10 -2
+10 -2
tools/testing/selftests/Makefile
··· 77 77 override TARGETS := $(TMP) 78 78 endif 79 79 80 + # User can set FORCE_TARGETS to 1 to require all targets to be successfully 81 + # built; make will fail if any of the targets cannot be built. If 82 + # FORCE_TARGETS is not set (the default), make will succeed if at least one 83 + # of the targets gets built. 84 + FORCE_TARGETS ?= 85 + 80 86 # Clear LDFLAGS and MAKEFLAGS if called from main 81 87 # Makefile to avoid test build failures when test 82 88 # Makefile doesn't have explicit build rules. ··· 157 151 for TARGET in $(TARGETS); do \ 158 152 BUILD_TARGET=$$BUILD/$$TARGET; \ 159 153 mkdir $$BUILD_TARGET -p; \ 160 - $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET; \ 154 + $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET \ 155 + $(if $(FORCE_TARGETS),|| exit); \ 161 156 ret=$$((ret * $$?)); \ 162 157 done; exit $$ret; 163 158 ··· 212 205 @ret=1; \ 213 206 for TARGET in $(TARGETS); do \ 214 207 BUILD_TARGET=$$BUILD/$$TARGET; \ 215 - $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \ 208 + $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install \ 209 + $(if $(FORCE_TARGETS),|| exit); \ 216 210 ret=$$((ret * $$?)); \ 217 211 done; exit $$ret; 218 212