~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/Makefile

Version: ~ [ linux-6.0-rc6 ] ~ [ linux-5.19.10 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.69 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.144 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.214 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.259 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.294 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.329 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.302 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp