xref: /openbmc/linux/tools/testing/selftests/Makefile (revision 8ee90c5c)
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
55ifneq ($(KBUILD_SRC),)
56override LDFLAGS =
57endif
58
59BUILD := $(O)
60ifndef BUILD
61  BUILD := $(KBUILD_OUTPUT)
62endif
63ifndef BUILD
64  BUILD := $(shell pwd)
65endif
66
67export BUILD
68all:
69	@for TARGET in $(TARGETS); do		\
70		BUILD_TARGET=$$BUILD/$$TARGET;	\
71		mkdir $$BUILD_TARGET  -p;	\
72		make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
73	done;
74
75run_tests: all
76	@for TARGET in $(TARGETS); do \
77		BUILD_TARGET=$$BUILD/$$TARGET;	\
78		make OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\
79	done;
80
81hotplug:
82	@for TARGET in $(TARGETS_HOTPLUG); do \
83		BUILD_TARGET=$$BUILD/$$TARGET;	\
84		make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
85	done;
86
87run_hotplug: hotplug
88	@for TARGET in $(TARGETS_HOTPLUG); do \
89		BUILD_TARGET=$$BUILD/$$TARGET;	\
90		make OUTPUT=$$BUILD_TARGET -C $$TARGET run_full_test;\
91	done;
92
93clean_hotplug:
94	@for TARGET in $(TARGETS_HOTPLUG); do \
95		BUILD_TARGET=$$BUILD/$$TARGET;	\
96		make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
97	done;
98
99run_pstore_crash:
100	make -C pstore run_crash
101
102INSTALL_PATH ?= install
103INSTALL_PATH := $(abspath $(INSTALL_PATH))
104ALL_SCRIPT := $(INSTALL_PATH)/run_kselftest.sh
105
106install:
107ifdef INSTALL_PATH
108	@# Ask all targets to install their files
109	mkdir -p $(INSTALL_PATH)
110	@for TARGET in $(TARGETS); do \
111		BUILD_TARGET=$$BUILD/$$TARGET;	\
112		make OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
113	done;
114
115	@# Ask all targets to emit their test scripts
116	echo "#!/bin/sh" > $(ALL_SCRIPT)
117	echo "cd \$$(dirname \$$0)" >> $(ALL_SCRIPT)
118	echo "ROOT=\$$PWD" >> $(ALL_SCRIPT)
119
120	for TARGET in $(TARGETS); do \
121		BUILD_TARGET=$$BUILD/$$TARGET;	\
122		echo "echo ; echo Running tests in $$TARGET" >> $(ALL_SCRIPT); \
123		echo "echo ========================================" >> $(ALL_SCRIPT); \
124		echo "cd $$TARGET" >> $(ALL_SCRIPT); \
125		make -s --no-print-directory OUTPUT=$$BUILD_TARGET -C $$TARGET emit_tests >> $(ALL_SCRIPT); \
126		echo "cd \$$ROOT" >> $(ALL_SCRIPT); \
127	done;
128
129	chmod u+x $(ALL_SCRIPT)
130else
131	$(error Error: set INSTALL_PATH to use install)
132endif
133
134clean:
135	@for TARGET in $(TARGETS); do \
136		BUILD_TARGET=$$BUILD/$$TARGET;	\
137		make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
138	done;
139
140.PHONY: all run_tests hotplug run_hotplug clean_hotplug run_pstore_crash install clean
141