Makefile 4.5 KB
Newer Older
1
# SPDX-License-Identifier: GPL-2.0
2 3
TARGETS = android
TARGETS += bpf
4
TARGETS += breakpoints
5
TARGETS += capabilities
6
TARGETS += cgroup
7
TARGETS += cpufreq
8
TARGETS += cpu-hotplug
T
Tom Murphy 已提交
9
TARGETS += drivers/dma-buf
10
TARGETS += efivarfs
11
TARGETS += exec
12
TARGETS += filesystems
13
TARGETS += filesystems/binderfs
14 15
TARGETS += firmware
TARGETS += ftrace
16
TARGETS += futex
17
TARGETS += gpio
18
TARGETS += intel_pstate
B
Bamvor Jian Zhang 已提交
19
TARGETS += ipc
20
TARGETS += ir
21
TARGETS += kcmp
22
TARGETS += kexec
23
TARGETS += kvm
K
Kees Cook 已提交
24
TARGETS += lib
25
TARGETS += livepatch
26
TARGETS += membarrier
27
TARGETS += memfd
28
TARGETS += memory-hotplug
29
TARGETS += mount
30
TARGETS += mqueue
31
TARGETS += net
32
TARGETS += netfilter
33
TARGETS += networking/timestamping
34
TARGETS += nsfs
35
TARGETS += pidfd
36
TARGETS += powerpc
A
Alexey Dobriyan 已提交
37
TARGETS += proc
38
TARGETS += pstore
39
TARGETS += ptrace
40
TARGETS += rseq
41
TARGETS += rtc
K
Kees Cook 已提交
42
TARGETS += seccomp
43
TARGETS += sigaltstack
44
TARGETS += size
45
TARGETS += sparc64
46
TARGETS += splice
47
TARGETS += static_keys
48
TARGETS += sync
49
TARGETS += sysctl
S
Shuah Khan 已提交
50
ifneq (1, $(quicktest))
51
TARGETS += timers
S
Shuah Khan 已提交
52
endif
53
TARGETS += tmpfs
J
Jarkko Sakkinen 已提交
54
TARGETS += tpm2
55
TARGETS += user
56
TARGETS += vm
57
TARGETS += x86
58
TARGETS += zram
59
#Please keep the TARGETS list alphabetically sorted
S
Shuah Khan 已提交
60
# Run "make quicktest=1 run_tests" or
61
# "make quicktest=1 kselftest" from top level Makefile
62

63 64 65
TARGETS_HOTPLUG = cpu-hotplug
TARGETS_HOTPLUG += memory-hotplug

66 67 68 69
# Clear LDFLAGS and MAKEFLAGS if called from main
# Makefile to avoid test build failures when test
# Makefile doesn't have explicit build rules.
ifeq (1,$(MAKELEVEL))
70
override LDFLAGS =
71 72 73
override MAKEFLAGS =
endif

74 75 76 77
ifneq ($(KBUILD_SRC),)
override LDFLAGS =
endif

78 79 80 81 82 83 84 85
BUILD := $(O)
ifndef BUILD
  BUILD := $(KBUILD_OUTPUT)
endif
ifndef BUILD
  BUILD := $(shell pwd)
endif

86 87 88 89 90 91
# KSFT_TAP_LEVEL is used from KSFT framework to prevent nested TAP header
# printing from tests. Applicable to run_tests case where run_tests adds
# TAP header prior running tests and when a test program invokes another
# with system() call. Export it here to cover override RUN_TESTS defines.
export KSFT_TAP_LEVEL=`echo 1`

92
export BUILD
93
all:
94
	@for TARGET in $(TARGETS); do		\
95 96 97
		BUILD_TARGET=$$BUILD/$$TARGET;	\
		mkdir $$BUILD_TARGET  -p;	\
		make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
98 99
	done;

100
run_tests: all
101
	@for TARGET in $(TARGETS); do \
102 103
		BUILD_TARGET=$$BUILD/$$TARGET;	\
		make OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\
104 105
	done;

106
hotplug:
107
	@for TARGET in $(TARGETS_HOTPLUG); do \
108 109
		BUILD_TARGET=$$BUILD/$$TARGET;	\
		make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
110 111 112
	done;

run_hotplug: hotplug
113
	@for TARGET in $(TARGETS_HOTPLUG); do \
114 115
		BUILD_TARGET=$$BUILD/$$TARGET;	\
		make OUTPUT=$$BUILD_TARGET -C $$TARGET run_full_test;\
116 117 118
	done;

clean_hotplug:
119
	@for TARGET in $(TARGETS_HOTPLUG); do \
120 121
		BUILD_TARGET=$$BUILD/$$TARGET;	\
		make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
122 123
	done;

124 125 126
run_pstore_crash:
	make -C pstore run_crash

M
Michael Ellerman 已提交
127 128 129 130 131 132 133 134
INSTALL_PATH ?= install
INSTALL_PATH := $(abspath $(INSTALL_PATH))
ALL_SCRIPT := $(INSTALL_PATH)/run_kselftest.sh

install:
ifdef INSTALL_PATH
	@# Ask all targets to install their files
	mkdir -p $(INSTALL_PATH)
135
	@for TARGET in $(TARGETS); do \
136 137
		BUILD_TARGET=$$BUILD/$$TARGET;	\
		make OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
M
Michael Ellerman 已提交
138 139 140
	done;

	@# Ask all targets to emit their test scripts
141
	echo "#!/bin/sh" > $(ALL_SCRIPT)
142 143
	echo "BASE_DIR=\$$(realpath \$$(dirname \$$0))" >> $(ALL_SCRIPT)
	echo "cd \$$BASE_DIR" >> $(ALL_SCRIPT)
M
Michael Ellerman 已提交
144
	echo "ROOT=\$$PWD" >> $(ALL_SCRIPT)
145 146 147 148 149 150
	echo "if [ \"\$$1\" = \"--summary\" ]; then" >> $(ALL_SCRIPT)
	echo "  OUTPUT=\$$BASE_DIR/output.log" >> $(ALL_SCRIPT)
	echo "  cat /dev/null > \$$OUTPUT" >> $(ALL_SCRIPT)
	echo "else" >> $(ALL_SCRIPT)
	echo "  OUTPUT=/dev/stdout" >> $(ALL_SCRIPT)
	echo "fi" >> $(ALL_SCRIPT)
151 152
	echo "export KSFT_TAP_LEVEL=1" >> $(ALL_SCRIPT)
	echo "export skip=4" >> $(ALL_SCRIPT)
M
Michael Ellerman 已提交
153 154

	for TARGET in $(TARGETS); do \
155
		BUILD_TARGET=$$BUILD/$$TARGET;	\
156 157
		echo "echo ; echo TAP version 13" >> $(ALL_SCRIPT);	\
		echo "echo Running tests in $$TARGET" >> $(ALL_SCRIPT); \
M
Michael Ellerman 已提交
158
		echo "echo ========================================" >> $(ALL_SCRIPT); \
159
		echo "[ -w /dev/kmsg ] && echo \"kselftest: Running tests in $$TARGET\" >> /dev/kmsg" >> $(ALL_SCRIPT); \
M
Michael Ellerman 已提交
160
		echo "cd $$TARGET" >> $(ALL_SCRIPT); \
161
		make -s --no-print-directory OUTPUT=$$BUILD_TARGET -C $$TARGET emit_tests >> $(ALL_SCRIPT); \
M
Michael Ellerman 已提交
162 163 164 165 166 167 168 169
		echo "cd \$$ROOT" >> $(ALL_SCRIPT); \
	done;

	chmod u+x $(ALL_SCRIPT)
else
	$(error Error: set INSTALL_PATH to use install)
endif

170
clean:
171
	@for TARGET in $(TARGETS); do \
172 173
		BUILD_TARGET=$$BUILD/$$TARGET;	\
		make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
174
	done;
M
Michael Ellerman 已提交
175

176
.PHONY: all run_tests hotplug run_hotplug clean_hotplug run_pstore_crash install clean