1 # SPDX-License-Identifier: GPL-2.0
8 TARGETS
+= capabilities
14 TARGETS
+= cpu-hotplug
16 TARGETS
+= dmabuf-heaps
17 TARGETS
+= drivers
/dma-buf
18 TARGETS
+= drivers
/s390x
/uvdevice
19 TARGETS
+= drivers
/net
/bonding
20 TARGETS
+= drivers
/net
/team
25 TARGETS
+= filesystems
26 TARGETS
+= filesystems
/binderfs
27 TARGETS
+= filesystems
/epoll
28 TARGETS
+= filesystems
/fat
29 TARGETS
+= filesystems
/overlayfs
30 TARGETS
+= filesystems
/statmount
37 TARGETS
+= intel_pstate
51 TARGETS
+= memory-hotplug
54 TARGETS
+= mount_setattr
55 TARGETS
+= move_mount_set_group
59 TARGETS
+= net
/af_unix
60 TARGETS
+= net
/forwarding
63 TARGETS
+= net
/openvswitch
67 TARGETS
+= perf_events
69 TARGETS
+= pid_namespace
70 TARGETS
+= power_supply
85 TARGETS
+= sigaltstack
89 TARGETS
+= static_keys
91 TARGETS
+= syscall_user_dispatch
95 TARGETS
+= thermal
/intel
/power_floor
96 TARGETS
+= thermal
/intel
/workload_hint
98 ifneq (1, $(quicktest
))
106 TARGETS
+= user_events
111 #Please keep the TARGETS list alphabetically sorted
112 # Run "make quicktest=1 run_tests" or
113 # "make quicktest=1 kselftest" from top level Makefile
115 TARGETS_HOTPLUG
= cpu-hotplug
116 TARGETS_HOTPLUG
+= memory-hotplug
118 # User can optionally provide a TARGETS skiplist. By default we skip
119 # BPF since it has cutting edge build time dependencies which require
120 # more effort to install.
122 ifneq ($(SKIP_TARGETS
),)
123 TMP
:= $(filter-out $(SKIP_TARGETS
), $(TARGETS
))
124 override TARGETS
:= $(TMP
)
127 # User can set FORCE_TARGETS to 1 to require all targets to be successfully
128 # built; make will fail if any of the targets cannot be built. If
129 # FORCE_TARGETS is not set (the default), make will succeed if at least one
130 # of the targets gets built.
133 # Clear LDFLAGS and MAKEFLAGS when implicit rules are missing. This provides
134 # implicit rules to sub-test Makefiles which avoids build failures in test
135 # Makefile that don't have explicit build rules.
141 # Append kselftest to KBUILD_OUTPUT and O to avoid cluttering
142 # KBUILD_OUTPUT with selftest objects and headers installed
143 # by selftests Makefile or lib.mk.
144 ifdef building_out_of_srctree
148 top_srcdir ?
= ..
/..
/..
150 ifeq ("$(origin O)", "command line")
151 KBUILD_OUTPUT
:= $(O
)
154 ifneq ($(KBUILD_OUTPUT
),)
155 # Make's built-in functions such as $(abspath ...), $(realpath ...) cannot
156 # expand a shell special character '~'. We use a somewhat tedious way here.
157 abs_objtree
:= $(shell cd
$(top_srcdir
) && mkdir
-p
$(KBUILD_OUTPUT
) && cd
$(KBUILD_OUTPUT
) && pwd
)
158 $(if
$(abs_objtree
),, \
159 $(error failed to create output directory
"$(KBUILD_OUTPUT)"))
160 # $(realpath ...) resolves symlinks
161 abs_objtree
:= $(realpath
$(abs_objtree
))
162 BUILD
:= $(abs_objtree
)/kselftest
163 KHDR_INCLUDES
:= -isystem
${abs_objtree}/usr
/include
166 abs_srctree
:= $(shell cd
$(top_srcdir
) && pwd
)
167 KHDR_INCLUDES
:= -isystem
${abs_srctree}/usr
/include
168 DEFAULT_INSTALL_HDR_PATH
:= 1
171 # Prepare for headers install
172 include $(top_srcdir
)/scripts
/subarch.
include
177 # set default goal to all, so make without a target runs all, even when
178 # all isn't the first target in the file.
183 for TARGET in
$(TARGETS
); do \
184 BUILD_TARGET
=$$BUILD/$$TARGET; \
185 mkdir
$$BUILD_TARGET -p
; \
186 $(MAKE
) OUTPUT
=$$BUILD_TARGET -C
$$TARGET \
188 $(if
$(FORCE_TARGETS
),|| exit
); \
189 ret
=$$((ret
* $$?
)); \
193 @for TARGET in
$(TARGETS
); do \
194 BUILD_TARGET
=$$BUILD/$$TARGET; \
195 $(MAKE
) OUTPUT
=$$BUILD_TARGET -C
$$TARGET run_tests \
196 SRC_PATH
=$(shell readlink
-e
$$(pwd
)) \
202 @for TARGET in
$(TARGETS_HOTPLUG
); do \
203 BUILD_TARGET
=$$BUILD/$$TARGET; \
204 $(MAKE
) OUTPUT
=$$BUILD_TARGET -C
$$TARGET;\
208 @for TARGET in
$(TARGETS_HOTPLUG
); do \
209 BUILD_TARGET
=$$BUILD/$$TARGET; \
210 $(MAKE
) OUTPUT
=$$BUILD_TARGET -C
$$TARGET run_full_test
;\
214 @for TARGET in
$(TARGETS_HOTPLUG
); do \
215 BUILD_TARGET
=$$BUILD/$$TARGET; \
216 $(MAKE
) OUTPUT
=$$BUILD_TARGET -C
$$TARGET clean;\
220 $(MAKE
) -C pstore run_crash
222 # Use $BUILD as the default install root. $BUILD points to the
223 # right output location for the following cases:
224 # 1. output_dir=kernel_src
225 # 2. a separate output directory is specified using O= KBUILD_OUTPUT
226 # 3. a separate output directory is specified using KBUILD_OUTPUT
227 # Avoid conflict with INSTALL_PATH set by the main Makefile
229 KSFT_INSTALL_PATH ?
= $(BUILD
)/kselftest_install
230 KSFT_INSTALL_PATH
:= $(abspath
$(KSFT_INSTALL_PATH
))
231 # Avoid changing the rest of the logic here and lib.mk.
232 INSTALL_PATH
:= $(KSFT_INSTALL_PATH
)
233 ALL_SCRIPT
:= $(INSTALL_PATH
)/run_kselftest.sh
234 TEST_LIST
:= $(INSTALL_PATH
)/kselftest-list.txt
238 @
# Ask all targets to install their files
239 mkdir
-p
$(INSTALL_PATH
)/kselftest
240 install -m
744 kselftest
/module.sh
$(INSTALL_PATH
)/kselftest
/
241 install -m
744 kselftest
/runner.sh
$(INSTALL_PATH
)/kselftest
/
242 install -m
744 kselftest
/prefix.pl
$(INSTALL_PATH
)/kselftest
/
243 install -m
744 kselftest
/ktap_helpers.sh
$(INSTALL_PATH
)/kselftest
/
244 install -m
744 run_kselftest.sh
$(INSTALL_PATH
)/
247 for TARGET in
$(TARGETS
); do \
248 BUILD_TARGET
=$$BUILD/$$TARGET; \
249 $(MAKE
) OUTPUT
=$$BUILD_TARGET -C
$$TARGET install \
250 INSTALL_PATH
=$(INSTALL_PATH
)/$$TARGET \
251 SRC_PATH
=$(shell readlink
-e
$$(pwd
)) \
252 OBJ_PATH
=$(INSTALL_PATH
) \
254 $(if
$(FORCE_TARGETS
),|| exit
); \
255 ret
=$$((ret
* $$?
)); \
259 @
# Ask all targets to emit their test scripts
260 @
# While building kselftest-list.text skip also non-existent TARGET dirs:
261 @
# they could be the result of a build failure and should NOT be
262 @
# included in the generated runlist.
263 for TARGET in
$(TARGETS
); do \
264 BUILD_TARGET
=$$BUILD/$$TARGET; \
265 [ ! -d
$(INSTALL_PATH
)/$$TARGET ] && printf
"Skipping non-existent dir: $$TARGET\n" && continue
; \
266 printf
"Emit Tests for $$TARGET\n"; \
267 $(MAKE
) -s
--no-print-directory OUTPUT
=$$BUILD_TARGET COLLECTION
=$$TARGET \
268 -C
$$TARGET emit_tests
>> $(TEST_LIST
); \
271 $(error Error
: set INSTALL_PATH to use
install)
275 TAR_PATH
= $(abspath
${INSTALL_PATH}/kselftest-packages
/kselftest.
tar${FORMAT})
277 @mkdir
-p
${INSTALL_PATH}/kselftest-packages
/
278 @
tar caf
${TAR_PATH} --exclude
=kselftest-packages
-C
${INSTALL_PATH} .
279 @echo
"Created ${TAR_PATH}"
282 @for TARGET in
$(TARGETS
); do \
283 BUILD_TARGET
=$$BUILD/$$TARGET; \
284 $(MAKE
) OUTPUT
=$$BUILD_TARGET -C
$$TARGET clean;\
287 .PHONY
: all run_tests hotplug run_hotplug clean_hotplug run_pstore_crash
install clean gen_tar