1 # SPDX-License-Identifier: GPL-2.0 1 # SPDX-License-Identifier: GPL-2.0 2 TARGETS += acct !! 2 TARGETS = arm64 3 TARGETS += alsa << 4 TARGETS += amd-pstate << 5 TARGETS += arm64 << 6 TARGETS += bpf 3 TARGETS += bpf 7 TARGETS += breakpoints 4 TARGETS += breakpoints 8 TARGETS += cachestat << 9 TARGETS += capabilities 5 TARGETS += capabilities 10 TARGETS += cgroup 6 TARGETS += cgroup 11 TARGETS += clone3 7 TARGETS += clone3 12 TARGETS += connector << 13 TARGETS += core 8 TARGETS += core 14 TARGETS += cpufreq 9 TARGETS += cpufreq 15 TARGETS += cpu-hotplug 10 TARGETS += cpu-hotplug 16 TARGETS += damon << 17 TARGETS += devices/error_logs << 18 TARGETS += devices/probe << 19 TARGETS += dmabuf-heaps << 20 TARGETS += drivers/dma-buf 11 TARGETS += drivers/dma-buf 21 TARGETS += drivers/s390x/uvdevice << 22 TARGETS += drivers/net << 23 TARGETS += drivers/net/bonding << 24 TARGETS += drivers/net/team << 25 TARGETS += drivers/net/virtio_net << 26 TARGETS += drivers/platform/x86/intel/ifs << 27 TARGETS += dt << 28 TARGETS += efivarfs 12 TARGETS += efivarfs 29 TARGETS += exec 13 TARGETS += exec 30 TARGETS += fchmodat2 << 31 TARGETS += filesystems 14 TARGETS += filesystems 32 TARGETS += filesystems/binderfs 15 TARGETS += filesystems/binderfs 33 TARGETS += filesystems/epoll 16 TARGETS += filesystems/epoll 34 TARGETS += filesystems/fat << 35 TARGETS += filesystems/overlayfs << 36 TARGETS += filesystems/statmount << 37 TARGETS += firmware 17 TARGETS += firmware 38 TARGETS += fpu 18 TARGETS += fpu 39 TARGETS += ftrace 19 TARGETS += ftrace 40 TARGETS += futex 20 TARGETS += futex 41 TARGETS += gpio 21 TARGETS += gpio 42 TARGETS += hid << 43 TARGETS += intel_pstate 22 TARGETS += intel_pstate 44 TARGETS += iommu << 45 TARGETS += ipc 23 TARGETS += ipc 46 TARGETS += ir 24 TARGETS += ir 47 TARGETS += kcmp 25 TARGETS += kcmp 48 TARGETS += kexec 26 TARGETS += kexec 49 TARGETS += kvm 27 TARGETS += kvm 50 TARGETS += landlock 28 TARGETS += landlock 51 TARGETS += lib 29 TARGETS += lib 52 TARGETS += livepatch 30 TARGETS += livepatch 53 TARGETS += lkdtm 31 TARGETS += lkdtm 54 TARGETS += lsm << 55 TARGETS += membarrier 32 TARGETS += membarrier 56 TARGETS += memfd 33 TARGETS += memfd 57 TARGETS += memory-hotplug 34 TARGETS += memory-hotplug 58 TARGETS += mincore 35 TARGETS += mincore 59 TARGETS += mount 36 TARGETS += mount 60 TARGETS += mount_setattr 37 TARGETS += mount_setattr 61 TARGETS += move_mount_set_group << 62 TARGETS += mqueue 38 TARGETS += mqueue 63 TARGETS += nci 39 TARGETS += nci 64 TARGETS += net 40 TARGETS += net 65 TARGETS += net/af_unix << 66 TARGETS += net/forwarding 41 TARGETS += net/forwarding 67 TARGETS += net/hsr << 68 TARGETS += net/mptcp 42 TARGETS += net/mptcp 69 TARGETS += net/netfilter !! 43 TARGETS += netfilter 70 TARGETS += net/openvswitch << 71 TARGETS += net/packetdrill << 72 TARGETS += net/rds << 73 TARGETS += net/tcp_ao << 74 TARGETS += nsfs 44 TARGETS += nsfs 75 TARGETS += perf_events << 76 TARGETS += pidfd 45 TARGETS += pidfd 77 TARGETS += pid_namespace 46 TARGETS += pid_namespace 78 TARGETS += power_supply << 79 TARGETS += powerpc 47 TARGETS += powerpc 80 TARGETS += prctl << 81 TARGETS += proc 48 TARGETS += proc 82 TARGETS += pstore 49 TARGETS += pstore 83 TARGETS += ptrace 50 TARGETS += ptrace 84 TARGETS += openat2 51 TARGETS += openat2 85 TARGETS += resctrl << 86 TARGETS += riscv << 87 TARGETS += rlimits << 88 TARGETS += rseq 52 TARGETS += rseq 89 TARGETS += rtc 53 TARGETS += rtc 90 TARGETS += rust << 91 TARGETS += sched_ext << 92 TARGETS += seccomp 54 TARGETS += seccomp 93 TARGETS += sgx 55 TARGETS += sgx 94 TARGETS += sigaltstack 56 TARGETS += sigaltstack 95 TARGETS += size 57 TARGETS += size 96 TARGETS += sparc64 58 TARGETS += sparc64 97 TARGETS += splice 59 TARGETS += splice 98 TARGETS += static_keys 60 TARGETS += static_keys 99 TARGETS += sync 61 TARGETS += sync 100 TARGETS += syscall_user_dispatch 62 TARGETS += syscall_user_dispatch 101 TARGETS += sysctl 63 TARGETS += sysctl 102 TARGETS += tc-testing 64 TARGETS += tc-testing 103 TARGETS += tdx << 104 TARGETS += thermal/intel/power_floor << 105 TARGETS += thermal/intel/workload_hint << 106 TARGETS += timens 65 TARGETS += timens 107 ifneq (1, $(quicktest)) 66 ifneq (1, $(quicktest)) 108 TARGETS += timers 67 TARGETS += timers 109 endif 68 endif 110 TARGETS += tmpfs 69 TARGETS += tmpfs 111 TARGETS += tpm2 70 TARGETS += tpm2 112 TARGETS += tty !! 71 TARGETS += user 113 TARGETS += uevent << 114 TARGETS += user_events << 115 TARGETS += vDSO 72 TARGETS += vDSO 116 TARGETS += mm !! 73 TARGETS += vm 117 TARGETS += x86 74 TARGETS += x86 118 TARGETS += zram 75 TARGETS += zram 119 #Please keep the TARGETS list alphabetically s 76 #Please keep the TARGETS list alphabetically sorted 120 # Run "make quicktest=1 run_tests" or 77 # Run "make quicktest=1 run_tests" or 121 # "make quicktest=1 kselftest" from top level 78 # "make quicktest=1 kselftest" from top level Makefile 122 79 123 TARGETS_HOTPLUG = cpu-hotplug 80 TARGETS_HOTPLUG = cpu-hotplug 124 TARGETS_HOTPLUG += memory-hotplug 81 TARGETS_HOTPLUG += memory-hotplug 125 82 126 # Networking tests want the net/lib target, in !! 83 # User can optionally provide a TARGETS skiplist. By default we skip 127 ifneq ($(filter net drivers/net drivers/net/hw !! 84 # BPF since it has cutting edge build time dependencies which require 128 ifeq ($(filter net/lib,$(TARGETS)),) !! 85 # more effort to install. 129 INSTALL_DEP_TARGETS := net/lib !! 86 SKIP_TARGETS ?= bpf 130 endif << 131 endif << 132 << 133 # User can optionally provide a TARGETS skipli << 134 # targets using BPF since it has cutting edge << 135 # which require more effort to install. << 136 SKIP_TARGETS ?= bpf sched_ext << 137 ifneq ($(SKIP_TARGETS),) 87 ifneq ($(SKIP_TARGETS),) 138 TMP := $(filter-out $(SKIP_TARGETS), $ 88 TMP := $(filter-out $(SKIP_TARGETS), $(TARGETS)) 139 override TARGETS := $(TMP) 89 override TARGETS := $(TMP) 140 endif 90 endif 141 91 142 # User can set FORCE_TARGETS to 1 to require a 92 # User can set FORCE_TARGETS to 1 to require all targets to be successfully 143 # built; make will fail if any of the targets 93 # built; make will fail if any of the targets cannot be built. If 144 # FORCE_TARGETS is not set (the default), make 94 # FORCE_TARGETS is not set (the default), make will succeed if at least one 145 # of the targets gets built. 95 # of the targets gets built. 146 FORCE_TARGETS ?= 96 FORCE_TARGETS ?= 147 97 148 # Clear LDFLAGS and MAKEFLAGS when implicit ru 98 # Clear LDFLAGS and MAKEFLAGS when implicit rules are missing. This provides 149 # implicit rules to sub-test Makefiles which a 99 # implicit rules to sub-test Makefiles which avoids build failures in test 150 # Makefile that don't have explicit build rule 100 # Makefile that don't have explicit build rules. 151 ifeq (,$(LINK.c)) 101 ifeq (,$(LINK.c)) 152 override LDFLAGS = 102 override LDFLAGS = 153 override MAKEFLAGS = 103 override MAKEFLAGS = 154 endif 104 endif 155 105 156 # Append kselftest to KBUILD_OUTPUT and O to a 106 # Append kselftest to KBUILD_OUTPUT and O to avoid cluttering 157 # KBUILD_OUTPUT with selftest objects and head 107 # KBUILD_OUTPUT with selftest objects and headers installed 158 # by selftests Makefile or lib.mk. 108 # by selftests Makefile or lib.mk. 159 ifdef building_out_of_srctree 109 ifdef building_out_of_srctree 160 override LDFLAGS = 110 override LDFLAGS = 161 endif 111 endif 162 112 163 top_srcdir ?= ../../.. !! 113 ifneq ($(O),) 164 !! 114 BUILD := $(O)/kselftest 165 ifeq ("$(origin O)", "command line") << 166 KBUILD_OUTPUT := $(O) << 167 endif << 168 << 169 ifneq ($(KBUILD_OUTPUT),) << 170 # Make's built-in functions such as $(abspat << 171 # expand a shell special character '~'. We u << 172 abs_objtree := $(shell cd $(top_srcdir) && m << 173 $(if $(abs_objtree),, \ << 174 $(error failed to create output directory << 175 # $(realpath ...) resolves symlinks << 176 abs_objtree := $(realpath $(abs_objtree)) << 177 BUILD := $(abs_objtree)/kselftest << 178 KHDR_INCLUDES := -isystem ${abs_objtree}/usr << 179 else 115 else 180 BUILD := $(CURDIR) !! 116 ifneq ($(KBUILD_OUTPUT),) 181 abs_srctree := $(shell cd $(top_srcdir) && p !! 117 BUILD := $(KBUILD_OUTPUT)/kselftest 182 KHDR_INCLUDES := -isystem ${abs_srctree}/usr !! 118 else 183 DEFAULT_INSTALL_HDR_PATH := 1 !! 119 BUILD := $(shell pwd) >> 120 DEFAULT_INSTALL_HDR_PATH := 1 >> 121 endif 184 endif 122 endif 185 123 186 # Prepare for headers install 124 # Prepare for headers install >> 125 top_srcdir ?= ../../.. 187 include $(top_srcdir)/scripts/subarch.include 126 include $(top_srcdir)/scripts/subarch.include 188 ARCH ?= $(SUBARCH) 127 ARCH ?= $(SUBARCH) >> 128 export KSFT_KHDR_INSTALL_DONE := 1 189 export BUILD 129 export BUILD 190 export KHDR_INCLUDES << 191 130 192 # set default goal to all, so make without a t 131 # set default goal to all, so make without a target runs all, even when 193 # all isn't the first target in the file. 132 # all isn't the first target in the file. 194 .DEFAULT_GOAL := all 133 .DEFAULT_GOAL := all 195 134 196 all: !! 135 # Install headers here once for all tests. KSFT_KHDR_INSTALL_DONE >> 136 # is used to avoid running headers_install from lib.mk. >> 137 # Invoke headers install with --no-builtin-rules to avoid circular >> 138 # dependency in "make kselftest" case. In this case, second level >> 139 # make inherits builtin-rules which will use the rule generate >> 140 # Makefile.o and runs into >> 141 # "Circular Makefile.o <- prepare dependency dropped." >> 142 # and headers_install fails and test compile fails. >> 143 # >> 144 # O= KBUILD_OUTPUT cases don't run into this error, since main Makefile >> 145 # invokes them as sub-makes and --no-builtin-rules is not necessary, >> 146 # but doesn't cause any failures. Keep it simple and use the same >> 147 # flags in both cases. >> 148 # Local build cases: "make kselftest", "make -C" - headers are installed >> 149 # in the default INSTALL_HDR_PATH usr/include. >> 150 khdr: >> 151 ifeq (1,$(DEFAULT_INSTALL_HDR_PATH)) >> 152 $(MAKE) --no-builtin-rules ARCH=$(ARCH) -C $(top_srcdir) headers_install >> 153 else >> 154 $(MAKE) --no-builtin-rules INSTALL_HDR_PATH=$$BUILD/usr \ >> 155 ARCH=$(ARCH) -C $(top_srcdir) headers_install >> 156 endif >> 157 >> 158 all: khdr 197 @ret=1; 159 @ret=1; \ 198 for TARGET in $(TARGETS); do 160 for TARGET in $(TARGETS); do \ 199 BUILD_TARGET=$$BUILD/$$TARGET; 161 BUILD_TARGET=$$BUILD/$$TARGET; \ 200 mkdir $$BUILD_TARGET -p; 162 mkdir $$BUILD_TARGET -p; \ 201 $(MAKE) OUTPUT=$$BUILD_TARGET 163 $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET \ 202 O=$(abs_objtre << 203 $(if $(FORCE_T 164 $(if $(FORCE_TARGETS),|| exit); \ 204 ret=$$((ret * $$?)); 165 ret=$$((ret * $$?)); \ 205 done; exit $$ret; 166 done; exit $$ret; 206 167 207 run_tests: all 168 run_tests: all 208 @for TARGET in $(TARGETS); do \ 169 @for TARGET in $(TARGETS); do \ 209 BUILD_TARGET=$$BUILD/$$TARGET; 170 BUILD_TARGET=$$BUILD/$$TARGET; \ 210 $(MAKE) OUTPUT=$$BUILD_TARGET !! 171 $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\ 211 SRC_PATH=$(she << 212 OBJ_PATH=$(BUI << 213 O=$(abs_objtre << 214 done; 172 done; 215 173 216 hotplug: 174 hotplug: 217 @for TARGET in $(TARGETS_HOTPLUG); do 175 @for TARGET in $(TARGETS_HOTPLUG); do \ 218 BUILD_TARGET=$$BUILD/$$TARGET; 176 BUILD_TARGET=$$BUILD/$$TARGET; \ 219 $(MAKE) OUTPUT=$$BUILD_TARGET 177 $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET;\ 220 done; 178 done; 221 179 222 run_hotplug: hotplug 180 run_hotplug: hotplug 223 @for TARGET in $(TARGETS_HOTPLUG); do 181 @for TARGET in $(TARGETS_HOTPLUG); do \ 224 BUILD_TARGET=$$BUILD/$$TARGET; 182 BUILD_TARGET=$$BUILD/$$TARGET; \ 225 $(MAKE) OUTPUT=$$BUILD_TARGET 183 $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_full_test;\ 226 done; 184 done; 227 185 228 clean_hotplug: 186 clean_hotplug: 229 @for TARGET in $(TARGETS_HOTPLUG); do 187 @for TARGET in $(TARGETS_HOTPLUG); do \ 230 BUILD_TARGET=$$BUILD/$$TARGET; 188 BUILD_TARGET=$$BUILD/$$TARGET; \ 231 $(MAKE) OUTPUT=$$BUILD_TARGET 189 $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\ 232 done; 190 done; 233 191 234 run_pstore_crash: 192 run_pstore_crash: 235 $(MAKE) -C pstore run_crash 193 $(MAKE) -C pstore run_crash 236 194 237 # Use $BUILD as the default install root. $BUI 195 # Use $BUILD as the default install root. $BUILD points to the 238 # right output location for the following case 196 # right output location for the following cases: 239 # 1. output_dir=kernel_src 197 # 1. output_dir=kernel_src 240 # 2. a separate output directory is specified 198 # 2. a separate output directory is specified using O= KBUILD_OUTPUT 241 # 3. a separate output directory is specified 199 # 3. a separate output directory is specified using KBUILD_OUTPUT 242 # Avoid conflict with INSTALL_PATH set by the 200 # Avoid conflict with INSTALL_PATH set by the main Makefile 243 # 201 # 244 KSFT_INSTALL_PATH ?= $(BUILD)/kselftest_instal 202 KSFT_INSTALL_PATH ?= $(BUILD)/kselftest_install 245 KSFT_INSTALL_PATH := $(abspath $(KSFT_INSTALL_ 203 KSFT_INSTALL_PATH := $(abspath $(KSFT_INSTALL_PATH)) 246 # Avoid changing the rest of the logic here an 204 # Avoid changing the rest of the logic here and lib.mk. 247 INSTALL_PATH := $(KSFT_INSTALL_PATH) 205 INSTALL_PATH := $(KSFT_INSTALL_PATH) 248 ALL_SCRIPT := $(INSTALL_PATH)/run_kselftest.sh 206 ALL_SCRIPT := $(INSTALL_PATH)/run_kselftest.sh 249 TEST_LIST := $(INSTALL_PATH)/kselftest-list.tx 207 TEST_LIST := $(INSTALL_PATH)/kselftest-list.txt 250 208 251 install: all 209 install: all 252 ifdef INSTALL_PATH 210 ifdef INSTALL_PATH 253 @# Ask all targets to install their fi 211 @# Ask all targets to install their files 254 mkdir -p $(INSTALL_PATH)/kselftest 212 mkdir -p $(INSTALL_PATH)/kselftest 255 install -m 744 kselftest/module.sh $(I 213 install -m 744 kselftest/module.sh $(INSTALL_PATH)/kselftest/ 256 install -m 744 kselftest/runner.sh $(I 214 install -m 744 kselftest/runner.sh $(INSTALL_PATH)/kselftest/ 257 install -m 744 kselftest/prefix.pl $(I 215 install -m 744 kselftest/prefix.pl $(INSTALL_PATH)/kselftest/ 258 install -m 744 kselftest/ktap_helpers. << 259 install -m 744 kselftest/ksft.py $(INS << 260 install -m 744 run_kselftest.sh $(INST 216 install -m 744 run_kselftest.sh $(INSTALL_PATH)/ 261 rm -f $(TEST_LIST) 217 rm -f $(TEST_LIST) 262 @ret=1; \ 218 @ret=1; \ 263 for TARGET in $(TARGETS) $(INSTALL_DEP !! 219 for TARGET in $(TARGETS); do \ 264 BUILD_TARGET=$$BUILD/$$TARGET; 220 BUILD_TARGET=$$BUILD/$$TARGET; \ 265 $(MAKE) OUTPUT=$$BUILD_TARGET !! 221 $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install \ 266 INSTALL_PATH=$ << 267 SRC_PATH=$(she << 268 OBJ_PATH=$(INS << 269 O=$(abs_objtre << 270 $(if $(FORCE_T 222 $(if $(FORCE_TARGETS),|| exit); \ 271 ret=$$((ret * $$?)); 223 ret=$$((ret * $$?)); \ 272 done; exit $$ret; 224 done; exit $$ret; 273 225 274 226 275 @# Ask all targets to emit their test 227 @# Ask all targets to emit their test scripts 276 @# While building kselftest-list.text 228 @# While building kselftest-list.text skip also non-existent TARGET dirs: 277 @# they could be the result of a build 229 @# they could be the result of a build failure and should NOT be 278 @# included in the generated runlist. 230 @# included in the generated runlist. 279 for TARGET in $(TARGETS); do \ 231 for TARGET in $(TARGETS); do \ 280 BUILD_TARGET=$$BUILD/$$TARGET; 232 BUILD_TARGET=$$BUILD/$$TARGET; \ 281 [ ! -d $(INSTALL_PATH)/$$TARGE !! 233 [ ! -d $(INSTALL_PATH)/$$TARGET ] && echo "Skipping non-existent dir: $$TARGET" && continue; \ 282 printf "Emit Tests for $$TARGE !! 234 echo -n "Emit Tests for $$TARGET\n"; \ 283 $(MAKE) -s --no-print-director 235 $(MAKE) -s --no-print-directory OUTPUT=$$BUILD_TARGET COLLECTION=$$TARGET \ 284 -C $$TARGET emit_tests 236 -C $$TARGET emit_tests >> $(TEST_LIST); \ 285 done; 237 done; 286 else 238 else 287 $(error Error: set INSTALL_PATH to use 239 $(error Error: set INSTALL_PATH to use install) 288 endif 240 endif 289 241 290 FORMAT ?= .gz 242 FORMAT ?= .gz 291 TAR_PATH = $(abspath ${INSTALL_PATH}/kselftest 243 TAR_PATH = $(abspath ${INSTALL_PATH}/kselftest-packages/kselftest.tar${FORMAT}) 292 gen_tar: install 244 gen_tar: install 293 @mkdir -p ${INSTALL_PATH}/kselftest-pa 245 @mkdir -p ${INSTALL_PATH}/kselftest-packages/ 294 @tar caf ${TAR_PATH} --exclude=kselfte 246 @tar caf ${TAR_PATH} --exclude=kselftest-packages -C ${INSTALL_PATH} . 295 @echo "Created ${TAR_PATH}" 247 @echo "Created ${TAR_PATH}" 296 248 297 clean: 249 clean: 298 @for TARGET in $(TARGETS); do \ 250 @for TARGET in $(TARGETS); do \ 299 BUILD_TARGET=$$BUILD/$$TARGET; 251 BUILD_TARGET=$$BUILD/$$TARGET; \ 300 $(MAKE) OUTPUT=$$BUILD_TARGET 252 $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\ 301 done; 253 done; 302 254 303 .PHONY: all run_tests hotplug run_hotplug clea !! 255 .PHONY: khdr all run_tests hotplug run_hotplug clean_hotplug run_pstore_crash install clean gen_tar
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.