xref: /openbmc/linux/tools/testing/selftests/Makefile (revision 1c2dd16a)
1TARGETS =  bpf
2TARGETS += breakpoints
3TARGETS += capabilities
4TARGETS += cpufreq
5TARGETS += cpu-hotplug
6TARGETS += efivarfs
7TARGETS += exec
8TARGETS += firmware
9TARGETS += ftrace
10TARGETS += futex
11TARGETS += gpio
12TARGETS += intel_pstate
13TARGETS += ipc
14TARGETS += kcmp
15TARGETS += lib
16TARGETS += membarrier
17TARGETS += memfd
18TARGETS += memory-hotplug
19TARGETS += mount
20TARGETS += mqueue
21TARGETS += net
22TARGETS += nsfs
23TARGETS += powerpc
24TARGETS += pstore
25TARGETS += ptrace
26TARGETS += seccomp
27TARGETS += sigaltstack
28TARGETS += size
29TARGETS += splice
30TARGETS += static_keys
31TARGETS += sync
32TARGETS += sysctl
33ifneq (1, $(quicktest))
34TARGETS += timers
35endif
36TARGETS += user
37TARGETS += vm
38TARGETS += x86
39TARGETS += zram
40#Please keep the TARGETS list alphabetically sorted
41# Run "make quicktest=1 run_tests" or
42# "make quicktest=1 kselftest from top level Makefile
43
44TARGETS_HOTPLUG = cpu-hotplug
45TARGETS_HOTPLUG += memory-hotplug
46
47# Clear LDFLAGS and MAKEFLAGS if called from main
48# Makefile to avoid test build failures when test
49# Makefile doesn't have explicit build rules.
50ifeq (1,$(MAKELEVEL))
51override LDFLAGS =
52override MAKEFLAGS =
53endif
54
55BUILD := $(O)
56ifndef BUILD
57  BUILD := $(KBUILD_OUTPUT)
58endif
59ifndef BUILD
60  BUILD := $(shell pwd)
61endif
62
63export BUILD
64all:
65	for TARGET in $(TARGETS); do		\
66		BUILD_TARGET=$$BUILD/$$TARGET;	\
67		mkdir $$BUILD_TARGET  -p;	\
68		make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
69	done;
70
71run_tests: all
72	for TARGET in $(TARGETS); do \
73		BUILD_TARGET=$$BUILD/$$TARGET;	\
74		make OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\
75	done;
76
77hotplug:
78	for TARGET in $(TARGETS_HOTPLUG); do \
79		BUILD_TARGET=$$BUILD/$$TARGET;	\
80		make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
81	done;
82
83run_hotplug: hotplug
84	for TARGET in $(TARGETS_HOTPLUG); do \
85		BUILD_TARGET=$$BUILD/$$TARGET;	\
86		make OUTPUT=$$BUILD_TARGET -C $$TARGET run_full_test;\
87	done;
88
89clean_hotplug:
90	for TARGET in $(TARGETS_HOTPLUG); do \
91		BUILD_TARGET=$$BUILD/$$TARGET;	\
92		make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
93	done;
94
95run_pstore_crash:
96	make -C pstore run_crash
97
98INSTALL_PATH ?= install
99INSTALL_PATH := $(abspath $(INSTALL_PATH))
100ALL_SCRIPT := $(INSTALL_PATH)/run_kselftest.sh
101
102install:
103ifdef INSTALL_PATH
104	@# Ask all targets to install their files
105	mkdir -p $(INSTALL_PATH)
106	for TARGET in $(TARGETS); do \
107		BUILD_TARGET=$$BUILD/$$TARGET;	\
108		make OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
109	done;
110
111	@# Ask all targets to emit their test scripts
112	echo "#!/bin/sh" > $(ALL_SCRIPT)
113	echo "cd \$$(dirname \$$0)" >> $(ALL_SCRIPT)
114	echo "ROOT=\$$PWD" >> $(ALL_SCRIPT)
115
116	for TARGET in $(TARGETS); do \
117		BUILD_TARGET=$$BUILD/$$TARGET;	\
118		echo "echo ; echo Running tests in $$TARGET" >> $(ALL_SCRIPT); \
119		echo "echo ========================================" >> $(ALL_SCRIPT); \
120		echo "cd $$TARGET" >> $(ALL_SCRIPT); \
121		make -s --no-print-directory OUTPUT=$$BUILD_TARGET -C $$TARGET emit_tests >> $(ALL_SCRIPT); \
122		echo "cd \$$ROOT" >> $(ALL_SCRIPT); \
123	done;
124
125	chmod u+x $(ALL_SCRIPT)
126else
127	$(error Error: set INSTALL_PATH to use install)
128endif
129
130clean:
131	for TARGET in $(TARGETS); do \
132		BUILD_TARGET=$$BUILD/$$TARGET;	\
133		make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
134	done;
135
136.PHONY: install
137