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