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