Makefile 3.3 KB
Newer Older
1
# SPDX-License-Identifier: GPL-2.0
2 3
TARGETS =  bpf
TARGETS += breakpoints
4
TARGETS += capabilities
5
TARGETS += cpufreq
6 7
TARGETS += cpu-hotplug
TARGETS += efivarfs
8 9 10
TARGETS += exec
TARGETS += firmware
TARGETS += ftrace
11
TARGETS += futex
12
TARGETS += gpio
13
TARGETS += intel_pstate
B
Bamvor Jian Zhang 已提交
14
TARGETS += ipc
15
TARGETS += kcmp
K
Kees Cook 已提交
16
TARGETS += lib
17
TARGETS += membarrier
18
TARGETS += memfd
19
TARGETS += memory-hotplug
20
TARGETS += mount
21
TARGETS += mqueue
22
TARGETS += net
23
TARGETS += nsfs
24
TARGETS += powerpc
25
TARGETS += pstore
26
TARGETS += ptrace
K
Kees Cook 已提交
27
TARGETS += seccomp
28
TARGETS += sigaltstack
29
TARGETS += size
30
TARGETS += splice
31
TARGETS += static_keys
32
TARGETS += sync
33
TARGETS += sysctl
S
Shuah Khan 已提交
34
ifneq (1, $(quicktest))
35
TARGETS += timers
S
Shuah Khan 已提交
36
endif
37
TARGETS += user
38
TARGETS += vm
39
TARGETS += x86
40
TARGETS += zram
41
#Please keep the TARGETS list alphabetically sorted
S
Shuah Khan 已提交
42
# Run "make quicktest=1 run_tests" or
43
# "make quicktest=1 kselftest" from top level Makefile
44

45 46 47
TARGETS_HOTPLUG = cpu-hotplug
TARGETS_HOTPLUG += memory-hotplug

48 49 50 51
# 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))
52
override LDFLAGS =
53 54 55
override MAKEFLAGS =
endif

56 57 58 59
ifneq ($(KBUILD_SRC),)
override LDFLAGS =
endif

60 61 62 63 64 65 66 67 68
BUILD := $(O)
ifndef BUILD
  BUILD := $(KBUILD_OUTPUT)
endif
ifndef BUILD
  BUILD := $(shell pwd)
endif

export BUILD
69
all:
70
	@for TARGET in $(TARGETS); do		\
71 72 73
		BUILD_TARGET=$$BUILD/$$TARGET;	\
		mkdir $$BUILD_TARGET  -p;	\
		make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
74 75
	done;

76
run_tests: all
77
	@for TARGET in $(TARGETS); do \
78 79
		BUILD_TARGET=$$BUILD/$$TARGET;	\
		make OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\
80 81
	done;

82
hotplug:
83
	@for TARGET in $(TARGETS_HOTPLUG); do \
84 85
		BUILD_TARGET=$$BUILD/$$TARGET;	\
		make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
86 87 88
	done;

run_hotplug: hotplug
89
	@for TARGET in $(TARGETS_HOTPLUG); do \
90 91
		BUILD_TARGET=$$BUILD/$$TARGET;	\
		make OUTPUT=$$BUILD_TARGET -C $$TARGET run_full_test;\
92 93 94
	done;

clean_hotplug:
95
	@for TARGET in $(TARGETS_HOTPLUG); do \
96 97
		BUILD_TARGET=$$BUILD/$$TARGET;	\
		make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
98 99
	done;

100 101 102
run_pstore_crash:
	make -C pstore run_crash

M
Michael Ellerman 已提交
103 104 105 106 107 108 109 110
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)
111
	@for TARGET in $(TARGETS); do \
112 113
		BUILD_TARGET=$$BUILD/$$TARGET;	\
		make OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
M
Michael Ellerman 已提交
114 115 116
	done;

	@# Ask all targets to emit their test scripts
117
	echo "#!/bin/sh" > $(ALL_SCRIPT)
M
Michael Ellerman 已提交
118 119 120 121
	echo "cd \$$(dirname \$$0)" >> $(ALL_SCRIPT)
	echo "ROOT=\$$PWD" >> $(ALL_SCRIPT)

	for TARGET in $(TARGETS); do \
122
		BUILD_TARGET=$$BUILD/$$TARGET;	\
M
Michael Ellerman 已提交
123 124 125
		echo "echo ; echo Running tests in $$TARGET" >> $(ALL_SCRIPT); \
		echo "echo ========================================" >> $(ALL_SCRIPT); \
		echo "cd $$TARGET" >> $(ALL_SCRIPT); \
126
		make -s --no-print-directory OUTPUT=$$BUILD_TARGET -C $$TARGET emit_tests >> $(ALL_SCRIPT); \
M
Michael Ellerman 已提交
127 128 129 130 131 132 133 134
		echo "cd \$$ROOT" >> $(ALL_SCRIPT); \
	done;

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

135
clean:
136
	@for TARGET in $(TARGETS); do \
137 138
		BUILD_TARGET=$$BUILD/$$TARGET;	\
		make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
139
	done;
M
Michael Ellerman 已提交
140

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