integrity: Remove references to module keyring
[sfrench/cifs-2.6.git] / tools / testing / selftests / Makefile
1 # SPDX-License-Identifier: GPL-2.0
2 TARGETS = android
3 TARGETS += bpf
4 TARGETS += breakpoints
5 TARGETS += capabilities
6 TARGETS += cgroup
7 TARGETS += cpufreq
8 TARGETS += cpu-hotplug
9 TARGETS += efivarfs
10 TARGETS += exec
11 TARGETS += filesystems
12 TARGETS += firmware
13 TARGETS += ftrace
14 TARGETS += futex
15 TARGETS += gpio
16 TARGETS += ima
17 TARGETS += intel_pstate
18 TARGETS += ipc
19 TARGETS += kcmp
20 TARGETS += kvm
21 TARGETS += lib
22 TARGETS += membarrier
23 TARGETS += memfd
24 TARGETS += memory-hotplug
25 TARGETS += mount
26 TARGETS += mqueue
27 TARGETS += net
28 TARGETS += netfilter
29 TARGETS += nsfs
30 TARGETS += powerpc
31 TARGETS += proc
32 TARGETS += pstore
33 TARGETS += ptrace
34 TARGETS += rseq
35 TARGETS += rtc
36 TARGETS += seccomp
37 TARGETS += sigaltstack
38 TARGETS += size
39 TARGETS += sparc64
40 TARGETS += splice
41 TARGETS += static_keys
42 TARGETS += sync
43 TARGETS += sysctl
44 ifneq (1, $(quicktest))
45 TARGETS += timers
46 endif
47 TARGETS += user
48 TARGETS += vm
49 TARGETS += x86
50 TARGETS += zram
51 #Please keep the TARGETS list alphabetically sorted
52 # Run "make quicktest=1 run_tests" or
53 # "make quicktest=1 kselftest" from top level Makefile
54
55 TARGETS_HOTPLUG = cpu-hotplug
56 TARGETS_HOTPLUG += memory-hotplug
57
58 # Clear LDFLAGS and MAKEFLAGS if called from main
59 # Makefile to avoid test build failures when test
60 # Makefile doesn't have explicit build rules.
61 ifeq (1,$(MAKELEVEL))
62 override LDFLAGS =
63 override MAKEFLAGS =
64 endif
65
66 ifneq ($(KBUILD_SRC),)
67 override LDFLAGS =
68 endif
69
70 BUILD := $(O)
71 ifndef BUILD
72   BUILD := $(KBUILD_OUTPUT)
73 endif
74 ifndef BUILD
75   BUILD := $(shell pwd)
76 endif
77
78 # KSFT_TAP_LEVEL is used from KSFT framework to prevent nested TAP header
79 # printing from tests. Applicable to run_tests case where run_tests adds
80 # TAP header prior running tests and when a test program invokes another
81 # with system() call. Export it here to cover override RUN_TESTS defines.
82 export KSFT_TAP_LEVEL=`echo 1`
83
84 export BUILD
85 all:
86         @for TARGET in $(TARGETS); do           \
87                 BUILD_TARGET=$$BUILD/$$TARGET;  \
88                 mkdir $$BUILD_TARGET  -p;       \
89                 make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
90         done;
91
92 run_tests: all
93         @for TARGET in $(TARGETS); do \
94                 BUILD_TARGET=$$BUILD/$$TARGET;  \
95                 make OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\
96         done;
97
98 hotplug:
99         @for TARGET in $(TARGETS_HOTPLUG); do \
100                 BUILD_TARGET=$$BUILD/$$TARGET;  \
101                 make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
102         done;
103
104 run_hotplug: hotplug
105         @for TARGET in $(TARGETS_HOTPLUG); do \
106                 BUILD_TARGET=$$BUILD/$$TARGET;  \
107                 make OUTPUT=$$BUILD_TARGET -C $$TARGET run_full_test;\
108         done;
109
110 clean_hotplug:
111         @for TARGET in $(TARGETS_HOTPLUG); do \
112                 BUILD_TARGET=$$BUILD/$$TARGET;  \
113                 make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
114         done;
115
116 run_pstore_crash:
117         make -C pstore run_crash
118
119 INSTALL_PATH ?= install
120 INSTALL_PATH := $(abspath $(INSTALL_PATH))
121 ALL_SCRIPT := $(INSTALL_PATH)/run_kselftest.sh
122
123 install:
124 ifdef INSTALL_PATH
125         @# Ask all targets to install their files
126         mkdir -p $(INSTALL_PATH)
127         @for TARGET in $(TARGETS); do \
128                 BUILD_TARGET=$$BUILD/$$TARGET;  \
129                 make OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
130         done;
131
132         @# Ask all targets to emit their test scripts
133         echo "#!/bin/sh" > $(ALL_SCRIPT)
134         echo "BASE_DIR=\$$(realpath \$$(dirname \$$0))" >> $(ALL_SCRIPT)
135         echo "cd \$$BASE_DIR" >> $(ALL_SCRIPT)
136         echo "ROOT=\$$PWD" >> $(ALL_SCRIPT)
137         echo "if [ \"\$$1\" = \"--summary\" ]; then" >> $(ALL_SCRIPT)
138         echo "  OUTPUT=\$$BASE_DIR/output.log" >> $(ALL_SCRIPT)
139         echo "  cat /dev/null > \$$OUTPUT" >> $(ALL_SCRIPT)
140         echo "else" >> $(ALL_SCRIPT)
141         echo "  OUTPUT=/dev/stdout" >> $(ALL_SCRIPT)
142         echo "fi" >> $(ALL_SCRIPT)
143         echo "export KSFT_TAP_LEVEL=1" >> $(ALL_SCRIPT)
144         echo "export skip=4" >> $(ALL_SCRIPT)
145
146         for TARGET in $(TARGETS); do \
147                 BUILD_TARGET=$$BUILD/$$TARGET;  \
148                 echo "echo ; echo TAP version 13" >> $(ALL_SCRIPT);     \
149                 echo "echo Running tests in $$TARGET" >> $(ALL_SCRIPT); \
150                 echo "echo ========================================" >> $(ALL_SCRIPT); \
151                 echo "[ -w /dev/kmsg ] && echo \"kselftest: Running tests in $$TARGET\" >> /dev/kmsg" >> $(ALL_SCRIPT); \
152                 echo "cd $$TARGET" >> $(ALL_SCRIPT); \
153                 make -s --no-print-directory OUTPUT=$$BUILD_TARGET -C $$TARGET emit_tests >> $(ALL_SCRIPT); \
154                 echo "cd \$$ROOT" >> $(ALL_SCRIPT); \
155         done;
156
157         chmod u+x $(ALL_SCRIPT)
158 else
159         $(error Error: set INSTALL_PATH to use install)
160 endif
161
162 clean:
163         @for TARGET in $(TARGETS); do \
164                 BUILD_TARGET=$$BUILD/$$TARGET;  \
165                 make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
166         done;
167
168 .PHONY: all run_tests hotplug run_hotplug clean_hotplug run_pstore_crash install clean