Makefile 4.4 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 14
TARGETS += firmware
TARGETS += ftrace
15
TARGETS += futex
16
TARGETS += gpio
17
TARGETS += ima
18
TARGETS += intel_pstate
B
Bamvor Jian Zhang 已提交
19
TARGETS += ipc
20
TARGETS += ir
21
TARGETS += kcmp
22
TARGETS += kvm
K
Kees Cook 已提交
23
TARGETS += lib
24
TARGETS += membarrier
25
TARGETS += memfd
26
TARGETS += memory-hotplug
27
TARGETS += mount
28
TARGETS += mqueue
29
TARGETS += net
30
TARGETS += netfilter
31
TARGETS += networking/timestamping
32
TARGETS += nsfs
33
TARGETS += pidfd
34
TARGETS += powerpc
A
Alexey Dobriyan 已提交
35
TARGETS += proc
36
TARGETS += pstore
37
TARGETS += ptrace
38
TARGETS += rseq
39
TARGETS += rtc
K
Kees Cook 已提交
40
TARGETS += seccomp
41
TARGETS += sigaltstack
42
TARGETS += size
43
TARGETS += sparc64
44
TARGETS += splice
45
TARGETS += static_keys
46
TARGETS += sync
47
TARGETS += sysctl
S
Shuah Khan 已提交
48
ifneq (1, $(quicktest))
49
TARGETS += timers
S
Shuah Khan 已提交
50
endif
51
TARGETS += user
52
TARGETS += vm
53
TARGETS += x86
54
TARGETS += zram
55
#Please keep the TARGETS list alphabetically sorted
S
Shuah Khan 已提交
56
# Run "make quicktest=1 run_tests" or
57
# "make quicktest=1 kselftest" from top level Makefile
58

59 60 61
TARGETS_HOTPLUG = cpu-hotplug
TARGETS_HOTPLUG += memory-hotplug

62 63 64 65
# 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))
66
override LDFLAGS =
67 68 69
override MAKEFLAGS =
endif

70 71 72 73
ifneq ($(KBUILD_SRC),)
override LDFLAGS =
endif

74 75 76 77 78 79 80 81
BUILD := $(O)
ifndef BUILD
  BUILD := $(KBUILD_OUTPUT)
endif
ifndef BUILD
  BUILD := $(shell pwd)
endif

82 83 84 85 86 87
# 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`

88
export BUILD
89
all:
90
	@for TARGET in $(TARGETS); do		\
91 92 93
		BUILD_TARGET=$$BUILD/$$TARGET;	\
		mkdir $$BUILD_TARGET  -p;	\
		make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
94 95
	done;

96
run_tests: all
97
	@for TARGET in $(TARGETS); do \
98 99
		BUILD_TARGET=$$BUILD/$$TARGET;	\
		make OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\
100 101
	done;

102
hotplug:
103
	@for TARGET in $(TARGETS_HOTPLUG); do \
104 105
		BUILD_TARGET=$$BUILD/$$TARGET;	\
		make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
106 107 108
	done;

run_hotplug: hotplug
109
	@for TARGET in $(TARGETS_HOTPLUG); do \
110 111
		BUILD_TARGET=$$BUILD/$$TARGET;	\
		make OUTPUT=$$BUILD_TARGET -C $$TARGET run_full_test;\
112 113 114
	done;

clean_hotplug:
115
	@for TARGET in $(TARGETS_HOTPLUG); do \
116 117
		BUILD_TARGET=$$BUILD/$$TARGET;	\
		make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
118 119
	done;

120 121 122
run_pstore_crash:
	make -C pstore run_crash

M
Michael Ellerman 已提交
123 124 125 126 127 128 129 130
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)
131
	@for TARGET in $(TARGETS); do \
132 133
		BUILD_TARGET=$$BUILD/$$TARGET;	\
		make OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
M
Michael Ellerman 已提交
134 135 136
	done;

	@# Ask all targets to emit their test scripts
137
	echo "#!/bin/sh" > $(ALL_SCRIPT)
138 139
	echo "BASE_DIR=\$$(realpath \$$(dirname \$$0))" >> $(ALL_SCRIPT)
	echo "cd \$$BASE_DIR" >> $(ALL_SCRIPT)
M
Michael Ellerman 已提交
140
	echo "ROOT=\$$PWD" >> $(ALL_SCRIPT)
141 142 143 144 145 146
	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)
147 148
	echo "export KSFT_TAP_LEVEL=1" >> $(ALL_SCRIPT)
	echo "export skip=4" >> $(ALL_SCRIPT)
M
Michael Ellerman 已提交
149 150

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

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

166
clean:
167
	@for TARGET in $(TARGETS); do \
168 169
		BUILD_TARGET=$$BUILD/$$TARGET;	\
		make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
170
	done;
M
Michael Ellerman 已提交
171

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