Skip to content

Commit 9d235a5

Browse files
Jiri Bencshuahkh
authored andcommitted
selftests: allow detection of build failures
Commit 5f70bde ("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 <[email protected]> Signed-off-by: Jiri Benc <[email protected]> Reviewed-by: Cristian Marussi <[email protected]> Tested-by: Cristian Marussi <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent b32694c commit 9d235a5

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

tools/testing/selftests/Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ ifneq ($(SKIP_TARGETS),)
7777
override TARGETS := $(TMP)
7878
endif
7979

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+
8086
# Clear LDFLAGS and MAKEFLAGS if called from main
8187
# Makefile to avoid test build failures when test
8288
# Makefile doesn't have explicit build rules.
@@ -151,7 +157,8 @@ all: khdr
151157
for TARGET in $(TARGETS); do \
152158
BUILD_TARGET=$$BUILD/$$TARGET; \
153159
mkdir $$BUILD_TARGET -p; \
154-
$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET; \
160+
$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET \
161+
$(if $(FORCE_TARGETS),|| exit); \
155162
ret=$$((ret * $$?)); \
156163
done; exit $$ret;
157164

@@ -205,7 +212,8 @@ ifdef INSTALL_PATH
205212
@ret=1; \
206213
for TARGET in $(TARGETS); do \
207214
BUILD_TARGET=$$BUILD/$$TARGET; \
208-
$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
215+
$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install \
216+
$(if $(FORCE_TARGETS),|| exit); \
209217
ret=$$((ret * $$?)); \
210218
done; exit $$ret;
211219

0 commit comments

Comments
 (0)