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