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