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