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