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