Commit | Line | Data |
---|---|---|
b2441318 | 1 | # SPDX-License-Identifier: GPL-2.0 |
47a18c42 PA |
2 | TARGETS = android |
3 | TARGETS += bpf | |
5aa5bd14 | 4 | TARGETS += breakpoints |
f4ecb322 | 5 | TARGETS += capabilities |
84092dbc | 6 | TARGETS += cgroup |
e66d5b67 | 7 | TARGETS += cpufreq |
58c7be84 | 8 | TARGETS += cpu-hotplug |
6edf2e37 | 9 | TARGETS += drivers/dma-buf |
58c7be84 | 10 | TARGETS += efivarfs |
96e869d8 | 11 | TARGETS += exec |
ce290a19 | 12 | TARGETS += filesystems |
75abec73 | 13 | TARGETS += filesystems/binderfs |
96e869d8 AM |
14 | TARGETS += firmware |
15 | TARGETS += ftrace | |
ecac1a75 | 16 | TARGETS += futex |
22f6592b | 17 | TARGETS += gpio |
6320303f | 18 | TARGETS += intel_pstate |
7e722473 | 19 | TARGETS += ipc |
e55c884e | 20 | TARGETS += ir |
66a01b96 | 21 | TARGETS += kcmp |
c3c0e811 | 22 | TARGETS += kexec |
783e9e51 | 23 | TARGETS += kvm |
317dc34a | 24 | TARGETS += lib |
a2818ee4 | 25 | TARGETS += livepatch |
b6d97344 | 26 | TARGETS += membarrier |
4f5ce5e8 | 27 | TARGETS += memfd |
58c7be84 | 28 | TARGETS += memory-hotplug |
db181ce0 | 29 | TARGETS += mount |
96e869d8 | 30 | TARGETS += mqueue |
a6f68034 | 31 | TARGETS += net |
25d8bced | 32 | TARGETS += netfilter |
cda261f4 | 33 | TARGETS += networking/timestamping |
6ad92bf6 | 34 | TARGETS += nsfs |
575a0ae9 | 35 | TARGETS += pidfd |
96e869d8 | 36 | TARGETS += powerpc |
9cd65655 | 37 | TARGETS += proc |
cc04a46f | 38 | TARGETS += pstore |
17afab1d | 39 | TARGETS += ptrace |
ccba8b64 | 40 | TARGETS += rseq |
a12ab9e1 | 41 | TARGETS += rtc |
c99ee51a | 42 | TARGETS += seccomp |
19fd2868 | 43 | TARGETS += sigaltstack |
96e869d8 | 44 | TARGETS += size |
3c545084 | 45 | TARGETS += sparc64 |
b8826e50 | 46 | TARGETS += splice |
1087d019 | 47 | TARGETS += static_keys |
82208160 | 48 | TARGETS += sync |
96e869d8 | 49 | TARGETS += sysctl |
2278e5ed | 50 | ifneq (1, $(quicktest)) |
0bc4b0cf | 51 | TARGETS += timers |
2278e5ed | 52 | endif |
a3322868 | 53 | TARGETS += tmpfs |
6ea3dfe1 | 54 | TARGETS += tpm2 |
3e2a4c18 | 55 | TARGETS += user |
96e869d8 | 56 | TARGETS += vm |
3f705dfd | 57 | TARGETS += x86 |
f21fb798 | 58 | TARGETS += zram |
96e869d8 | 59 | #Please keep the TARGETS list alphabetically sorted |
2278e5ed | 60 | # Run "make quicktest=1 run_tests" or |
c6a13faf | 61 | # "make quicktest=1 kselftest" from top level Makefile |
274343ad | 62 | |
ddddda9b SK |
63 | TARGETS_HOTPLUG = cpu-hotplug |
64 | TARGETS_HOTPLUG += memory-hotplug | |
65 | ||
67d8712d SK |
66 | # Clear LDFLAGS and MAKEFLAGS if called from main |
67 | # Makefile to avoid test build failures when test | |
68 | # Makefile doesn't have explicit build rules. | |
69 | ifeq (1,$(MAKELEVEL)) | |
60df4642 | 70 | override LDFLAGS = |
67d8712d SK |
71 | override MAKEFLAGS = |
72 | endif | |
73 | ||
61c2018c SK |
74 | # Append kselftest to KBUILD_OUTPUT to avoid cluttering |
75 | # KBUILD_OUTPUT with selftest objects and headers installed | |
76 | # by selftests Makefile or lib.mk. | |
051f278e | 77 | ifdef building_out_of_srctree |
52fd1d08 SK |
78 | override LDFLAGS = |
79 | endif | |
80 | ||
8ce72dc3 SK |
81 | ifneq ($(O),) |
82 | BUILD := $(O) | |
83 | else | |
84 | ifneq ($(KBUILD_OUTPUT),) | |
61c2018c | 85 | BUILD := $(KBUILD_OUTPUT)/kselftest |
8ce72dc3 SK |
86 | else |
87 | BUILD := $(shell pwd) | |
88 | DEFAULT_INSTALL_HDR_PATH := 1 | |
89 | endif | |
a8ba798b | 90 | endif |
91 | ||
8ce72dc3 SK |
92 | # Prepare for headers install |
93 | top_srcdir ?= ../../.. | |
94 | include $(top_srcdir)/scripts/subarch.include | |
95 | ARCH ?= $(SUBARCH) | |
96 | export KSFT_KHDR_INSTALL_DONE := 1 | |
a8ba798b | 97 | export BUILD |
8ce72dc3 | 98 | |
d917fb87 SK |
99 | # build and run gpio when output directory is the src dir. |
100 | # gpio has dependency on tools/gpio and builds tools/gpio | |
101 | # objects in the src directory in all cases making the src | |
102 | # repo dirty even when objects are relocated. | |
103 | ifneq (1,$(DEFAULT_INSTALL_HDR_PATH)) | |
104 | TMP := $(filter-out gpio, $(TARGETS)) | |
105 | TARGETS := $(TMP) | |
106 | endif | |
107 | ||
8ce72dc3 SK |
108 | # set default goal to all, so make without a target runs all, even when |
109 | # all isn't the first target in the file. | |
110 | .DEFAULT_GOAL := all | |
111 | ||
112 | # Install headers here once for all tests. KSFT_KHDR_INSTALL_DONE | |
113 | # is used to avoid running headers_install from lib.mk. | |
114 | # Invoke headers install with --no-builtin-rules to avoid circular | |
115 | # dependency in "make kselftest" case. In this case, second level | |
116 | # make inherits builtin-rules which will use the rule generate | |
117 | # Makefile.o and runs into | |
118 | # "Circular Makefile.o <- prepare dependency dropped." | |
119 | # and headers_install fails and test compile fails. | |
120 | # | |
121 | # O= KBUILD_OUTPUT cases don't run into this error, since main Makefile | |
122 | # invokes them as sub-makes and --no-builtin-rules is not necessary, | |
123 | # but doesn't cause any failures. Keep it simple and use the same | |
124 | # flags in both cases. | |
125 | # Local build cases: "make kselftest", "make -C" - headers are installed | |
126 | # in the default INSTALL_HDR_PATH usr/include. | |
127 | khdr: | |
128 | ifeq (1,$(DEFAULT_INSTALL_HDR_PATH)) | |
129 | make --no-builtin-rules ARCH=$(ARCH) -C $(top_srcdir) headers_install | |
130 | else | |
131 | make --no-builtin-rules INSTALL_HDR_PATH=$$BUILD/usr \ | |
132 | ARCH=$(ARCH) -C $(top_srcdir) headers_install | |
133 | endif | |
134 | ||
135 | all: khdr | |
1ede0536 | 136 | @for TARGET in $(TARGETS); do \ |
a8ba798b | 137 | BUILD_TARGET=$$BUILD/$$TARGET; \ |
138 | mkdir $$BUILD_TARGET -p; \ | |
139 | make OUTPUT=$$BUILD_TARGET -C $$TARGET;\ | |
274343ad FW |
140 | done; |
141 | ||
cab6b056 | 142 | run_tests: all |
1ede0536 | 143 | @for TARGET in $(TARGETS); do \ |
a8ba798b | 144 | BUILD_TARGET=$$BUILD/$$TARGET; \ |
145 | make OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\ | |
f467f714 FW |
146 | done; |
147 | ||
ddddda9b | 148 | hotplug: |
1ede0536 | 149 | @for TARGET in $(TARGETS_HOTPLUG); do \ |
a8ba798b | 150 | BUILD_TARGET=$$BUILD/$$TARGET; \ |
151 | make OUTPUT=$$BUILD_TARGET -C $$TARGET;\ | |
ddddda9b SK |
152 | done; |
153 | ||
154 | run_hotplug: hotplug | |
1ede0536 | 155 | @for TARGET in $(TARGETS_HOTPLUG); do \ |
a8ba798b | 156 | BUILD_TARGET=$$BUILD/$$TARGET; \ |
157 | make OUTPUT=$$BUILD_TARGET -C $$TARGET run_full_test;\ | |
ddddda9b SK |
158 | done; |
159 | ||
160 | clean_hotplug: | |
1ede0536 | 161 | @for TARGET in $(TARGETS_HOTPLUG); do \ |
a8ba798b | 162 | BUILD_TARGET=$$BUILD/$$TARGET; \ |
163 | make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\ | |
ddddda9b SK |
164 | done; |
165 | ||
f615e2bb HT |
166 | run_pstore_crash: |
167 | make -C pstore run_crash | |
168 | ||
c3c59928 SK |
169 | # Use $BUILD as the default install root. $BUILD points to the |
170 | # right output location for the following cases: | |
171 | # 1. output_dir=kernel_src | |
172 | # 2. a separate output directory is specified using O= KBUILD_OUTPUT | |
173 | # 3. a separate output directory is specified using KBUILD_OUTPUT | |
174 | # | |
175 | INSTALL_PATH ?= $(BUILD)/install | |
32dcfba6 ME |
176 | INSTALL_PATH := $(abspath $(INSTALL_PATH)) |
177 | ALL_SCRIPT := $(INSTALL_PATH)/run_kselftest.sh | |
178 | ||
c3c59928 | 179 | install: all |
32dcfba6 ME |
180 | ifdef INSTALL_PATH |
181 | @# Ask all targets to install their files | |
d4e59a53 KC |
182 | mkdir -p $(INSTALL_PATH)/kselftest |
183 | install -m 744 kselftest/runner.sh $(INSTALL_PATH)/kselftest/ | |
5c069b6d | 184 | install -m 744 kselftest/prefix.pl $(INSTALL_PATH)/kselftest/ |
1ede0536 | 185 | @for TARGET in $(TARGETS); do \ |
a8ba798b | 186 | BUILD_TARGET=$$BUILD/$$TARGET; \ |
187 | make OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \ | |
32dcfba6 ME |
188 | done; |
189 | ||
190 | @# Ask all targets to emit their test scripts | |
a2b1e8a2 | 191 | echo "#!/bin/sh" > $(ALL_SCRIPT) |
14f1889f ME |
192 | echo "BASE_DIR=\$$(realpath \$$(dirname \$$0))" >> $(ALL_SCRIPT) |
193 | echo "cd \$$BASE_DIR" >> $(ALL_SCRIPT) | |
d4e59a53 | 194 | echo ". ./kselftest/runner.sh" >> $(ALL_SCRIPT) |
32dcfba6 | 195 | echo "ROOT=\$$PWD" >> $(ALL_SCRIPT) |
14f1889f | 196 | echo "if [ \"\$$1\" = \"--summary\" ]; then" >> $(ALL_SCRIPT) |
d4e59a53 KC |
197 | echo " logfile=\$$BASE_DIR/output.log" >> $(ALL_SCRIPT) |
198 | echo " cat /dev/null > \$$logfile" >> $(ALL_SCRIPT) | |
14f1889f | 199 | echo "fi" >> $(ALL_SCRIPT) |
32dcfba6 ME |
200 | |
201 | for TARGET in $(TARGETS); do \ | |
a8ba798b | 202 | BUILD_TARGET=$$BUILD/$$TARGET; \ |
88893cf7 | 203 | echo "[ -w /dev/kmsg ] && echo \"kselftest: Running tests in $$TARGET\" >> /dev/kmsg" >> $(ALL_SCRIPT); \ |
32dcfba6 | 204 | echo "cd $$TARGET" >> $(ALL_SCRIPT); \ |
bf660782 | 205 | echo -n "run_many" >> $(ALL_SCRIPT); \ |
a8ba798b | 206 | make -s --no-print-directory OUTPUT=$$BUILD_TARGET -C $$TARGET emit_tests >> $(ALL_SCRIPT); \ |
bf660782 | 207 | echo "" >> $(ALL_SCRIPT); \ |
32dcfba6 ME |
208 | echo "cd \$$ROOT" >> $(ALL_SCRIPT); \ |
209 | done; | |
210 | ||
211 | chmod u+x $(ALL_SCRIPT) | |
212 | else | |
213 | $(error Error: set INSTALL_PATH to use install) | |
214 | endif | |
215 | ||
274343ad | 216 | clean: |
1ede0536 | 217 | @for TARGET in $(TARGETS); do \ |
a8ba798b | 218 | BUILD_TARGET=$$BUILD/$$TARGET; \ |
219 | make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\ | |
274343ad | 220 | done; |
32dcfba6 | 221 | |
8ce72dc3 | 222 | .PHONY: khdr all run_tests hotplug run_hotplug clean_hotplug run_pstore_crash install clean |