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