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