Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1# SPDX-License-Identifier: GPL-2.0
2TARGETS += acct
3TARGETS += alsa
4TARGETS += amd-pstate
5TARGETS += arm64
6TARGETS += bpf
7TARGETS += breakpoints
8TARGETS += cachestat
9TARGETS += capabilities
10TARGETS += cgroup
11TARGETS += clone3
12TARGETS += connector
13TARGETS += core
14TARGETS += cpufreq
15TARGETS += cpu-hotplug
16TARGETS += damon
17TARGETS += devices/error_logs
18TARGETS += devices/probe
19TARGETS += dmabuf-heaps
20TARGETS += drivers/dma-buf
21TARGETS += drivers/s390x/uvdevice
22TARGETS += drivers/net
23TARGETS += drivers/net/bonding
24TARGETS += drivers/net/team
25TARGETS += drivers/net/virtio_net
26TARGETS += drivers/platform/x86/intel/ifs
27TARGETS += dt
28TARGETS += efivarfs
29TARGETS += exec
30TARGETS += fchmodat2
31TARGETS += filesystems
32TARGETS += filesystems/binderfs
33TARGETS += filesystems/epoll
34TARGETS += filesystems/fat
35TARGETS += filesystems/overlayfs
36TARGETS += filesystems/statmount
37TARGETS += firmware
38TARGETS += fpu
39TARGETS += ftrace
40TARGETS += futex
41TARGETS += gpio
42TARGETS += hid
43TARGETS += intel_pstate
44TARGETS += iommu
45TARGETS += ipc
46TARGETS += ir
47TARGETS += kcmp
48TARGETS += kexec
49TARGETS += kvm
50TARGETS += landlock
51TARGETS += lib
52TARGETS += livepatch
53TARGETS += lkdtm
54TARGETS += lsm
55TARGETS += membarrier
56TARGETS += memfd
57TARGETS += memory-hotplug
58TARGETS += mincore
59TARGETS += mount
60TARGETS += mount_setattr
61TARGETS += move_mount_set_group
62TARGETS += mqueue
63TARGETS += nci
64TARGETS += net
65TARGETS += net/af_unix
66TARGETS += net/forwarding
67TARGETS += net/hsr
68TARGETS += net/mptcp
69TARGETS += net/netfilter
70TARGETS += net/openvswitch
71TARGETS += net/packetdrill
72TARGETS += net/rds
73TARGETS += net/tcp_ao
74TARGETS += nsfs
75TARGETS += perf_events
76TARGETS += pidfd
77TARGETS += pid_namespace
78TARGETS += power_supply
79TARGETS += powerpc
80TARGETS += prctl
81TARGETS += proc
82TARGETS += pstore
83TARGETS += ptrace
84TARGETS += openat2
85TARGETS += resctrl
86TARGETS += riscv
87TARGETS += rlimits
88TARGETS += rseq
89TARGETS += rtc
90TARGETS += rust
91TARGETS += sched_ext
92TARGETS += seccomp
93TARGETS += sgx
94TARGETS += sigaltstack
95TARGETS += size
96TARGETS += sparc64
97TARGETS += splice
98TARGETS += static_keys
99TARGETS += sync
100TARGETS += syscall_user_dispatch
101TARGETS += sysctl
102TARGETS += tc-testing
103TARGETS += tdx
104TARGETS += thermal/intel/power_floor
105TARGETS += thermal/intel/workload_hint
106TARGETS += timens
107ifneq (1, $(quicktest))
108TARGETS += timers
109endif
110TARGETS += tmpfs
111TARGETS += tpm2
112TARGETS += tty
113TARGETS += uevent
114TARGETS += user_events
115TARGETS += vDSO
116TARGETS += mm
117TARGETS += x86
118TARGETS += zram
119#Please keep the TARGETS list alphabetically sorted
120# Run "make quicktest=1 run_tests" or
121# "make quicktest=1 kselftest" from top level Makefile
122
123TARGETS_HOTPLUG = cpu-hotplug
124TARGETS_HOTPLUG += memory-hotplug
125
126# Networking tests want the net/lib target, include it automatically
127ifneq ($(filter net drivers/net drivers/net/hw,$(TARGETS)),)
128ifeq ($(filter net/lib,$(TARGETS)),)
129 INSTALL_DEP_TARGETS := net/lib
130endif
131endif
132
133# User can optionally provide a TARGETS skiplist. By default we skip
134# targets using BPF since it has cutting edge build time dependencies
135# which require more effort to install.
136SKIP_TARGETS ?= bpf sched_ext
137ifneq ($(SKIP_TARGETS),)
138 TMP := $(filter-out $(SKIP_TARGETS), $(TARGETS))
139 override TARGETS := $(TMP)
140endif
141
142# User can set FORCE_TARGETS to 1 to require all targets to be successfully
143# built; make will fail if any of the targets cannot be built. If
144# FORCE_TARGETS is not set (the default), make will succeed if at least one
145# of the targets gets built.
146FORCE_TARGETS ?=
147
148# Clear LDFLAGS and MAKEFLAGS when implicit rules are missing. This provides
149# implicit rules to sub-test Makefiles which avoids build failures in test
150# Makefile that don't have explicit build rules.
151ifeq (,$(LINK.c))
152override LDFLAGS =
153override MAKEFLAGS =
154endif
155
156# Append kselftest to KBUILD_OUTPUT and O to avoid cluttering
157# KBUILD_OUTPUT with selftest objects and headers installed
158# by selftests Makefile or lib.mk.
159ifdef building_out_of_srctree
160override LDFLAGS =
161endif
162
163top_srcdir ?= ../../..
164
165ifeq ("$(origin O)", "command line")
166 KBUILD_OUTPUT := $(O)
167endif
168
169ifneq ($(KBUILD_OUTPUT),)
170 # Make's built-in functions such as $(abspath ...), $(realpath ...) cannot
171 # expand a shell special character '~'. We use a somewhat tedious way here.
172 abs_objtree := $(shell cd $(top_srcdir) && mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) && pwd)
173 $(if $(abs_objtree),, \
174 $(error failed to create output directory "$(KBUILD_OUTPUT)"))
175 # $(realpath ...) resolves symlinks
176 abs_objtree := $(realpath $(abs_objtree))
177 BUILD := $(abs_objtree)/kselftest
178 KHDR_INCLUDES := -isystem ${abs_objtree}/usr/include
179else
180 BUILD := $(CURDIR)
181 abs_srctree := $(shell cd $(top_srcdir) && pwd)
182 KHDR_INCLUDES := -isystem ${abs_srctree}/usr/include
183 DEFAULT_INSTALL_HDR_PATH := 1
184endif
185
186# Prepare for headers install
187include $(top_srcdir)/scripts/subarch.include
188ARCH ?= $(SUBARCH)
189export BUILD
190export KHDR_INCLUDES
191
192# set default goal to all, so make without a target runs all, even when
193# all isn't the first target in the file.
194.DEFAULT_GOAL := all
195
196all:
197 @ret=1; \
198 for TARGET in $(TARGETS); do \
199 BUILD_TARGET=$$BUILD/$$TARGET; \
200 mkdir $$BUILD_TARGET -p; \
201 $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET \
202 O=$(abs_objtree) \
203 $(if $(FORCE_TARGETS),|| exit); \
204 ret=$$((ret * $$?)); \
205 done; exit $$ret;
206
207run_tests: all
208 @for TARGET in $(TARGETS); do \
209 BUILD_TARGET=$$BUILD/$$TARGET; \
210 $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests \
211 SRC_PATH=$(shell readlink -e $$(pwd)) \
212 OBJ_PATH=$(BUILD) \
213 O=$(abs_objtree); \
214 done;
215
216hotplug:
217 @for TARGET in $(TARGETS_HOTPLUG); do \
218 BUILD_TARGET=$$BUILD/$$TARGET; \
219 $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET;\
220 done;
221
222run_hotplug: hotplug
223 @for TARGET in $(TARGETS_HOTPLUG); do \
224 BUILD_TARGET=$$BUILD/$$TARGET; \
225 $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_full_test;\
226 done;
227
228clean_hotplug:
229 @for TARGET in $(TARGETS_HOTPLUG); do \
230 BUILD_TARGET=$$BUILD/$$TARGET; \
231 $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
232 done;
233
234run_pstore_crash:
235 $(MAKE) -C pstore run_crash
236
237# Use $BUILD as the default install root. $BUILD points to the
238# right output location for the following cases:
239# 1. output_dir=kernel_src
240# 2. a separate output directory is specified using O= KBUILD_OUTPUT
241# 3. a separate output directory is specified using KBUILD_OUTPUT
242# Avoid conflict with INSTALL_PATH set by the main Makefile
243#
244KSFT_INSTALL_PATH ?= $(BUILD)/kselftest_install
245KSFT_INSTALL_PATH := $(abspath $(KSFT_INSTALL_PATH))
246# Avoid changing the rest of the logic here and lib.mk.
247INSTALL_PATH := $(KSFT_INSTALL_PATH)
248ALL_SCRIPT := $(INSTALL_PATH)/run_kselftest.sh
249TEST_LIST := $(INSTALL_PATH)/kselftest-list.txt
250
251install: all
252ifdef INSTALL_PATH
253 @# Ask all targets to install their files
254 mkdir -p $(INSTALL_PATH)/kselftest
255 install -m 744 kselftest/module.sh $(INSTALL_PATH)/kselftest/
256 install -m 744 kselftest/runner.sh $(INSTALL_PATH)/kselftest/
257 install -m 744 kselftest/prefix.pl $(INSTALL_PATH)/kselftest/
258 install -m 744 kselftest/ktap_helpers.sh $(INSTALL_PATH)/kselftest/
259 install -m 744 kselftest/ksft.py $(INSTALL_PATH)/kselftest/
260 install -m 744 run_kselftest.sh $(INSTALL_PATH)/
261 rm -f $(TEST_LIST)
262 @ret=1; \
263 for TARGET in $(TARGETS) $(INSTALL_DEP_TARGETS); do \
264 BUILD_TARGET=$$BUILD/$$TARGET; \
265 $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install \
266 INSTALL_PATH=$(INSTALL_PATH)/$$TARGET \
267 SRC_PATH=$(shell readlink -e $$(pwd)) \
268 OBJ_PATH=$(INSTALL_PATH) \
269 O=$(abs_objtree) \
270 $(if $(FORCE_TARGETS),|| exit); \
271 ret=$$((ret * $$?)); \
272 done; exit $$ret;
273
274
275 @# Ask all targets to emit their test scripts
276 @# While building kselftest-list.text skip also non-existent TARGET dirs:
277 @# they could be the result of a build failure and should NOT be
278 @# included in the generated runlist.
279 for TARGET in $(TARGETS); do \
280 BUILD_TARGET=$$BUILD/$$TARGET; \
281 [ ! -d $(INSTALL_PATH)/$$TARGET ] && printf "Skipping non-existent dir: $$TARGET\n" && continue; \
282 printf "Emit Tests for $$TARGET\n"; \
283 $(MAKE) -s --no-print-directory OUTPUT=$$BUILD_TARGET COLLECTION=$$TARGET \
284 -C $$TARGET emit_tests >> $(TEST_LIST); \
285 done;
286else
287 $(error Error: set INSTALL_PATH to use install)
288endif
289
290FORMAT ?= .gz
291TAR_PATH = $(abspath ${INSTALL_PATH}/kselftest-packages/kselftest.tar${FORMAT})
292gen_tar: install
293 @mkdir -p ${INSTALL_PATH}/kselftest-packages/
294 @tar caf ${TAR_PATH} --exclude=kselftest-packages -C ${INSTALL_PATH} .
295 @echo "Created ${TAR_PATH}"
296
297clean:
298 @for TARGET in $(TARGETS); do \
299 BUILD_TARGET=$$BUILD/$$TARGET; \
300 $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
301 done;
302
303.PHONY: all run_tests hotplug run_hotplug clean_hotplug run_pstore_crash install clean gen_tar