blob: 593fb44c9cd419b2ba01df12b5b4ac04e6bc65cf [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
Pintu Agarwal47a18c42017-11-01 13:00:39 -04002TARGETS = android
3TARGETS += bpf
Daniel Borkmann5aa5bd12016-10-17 14:28:36 +02004TARGETS += breakpoints
Bamvor Jian Zhangf4ecb322015-11-17 22:35:42 +08005TARGETS += capabilities
Viresh Kumare66d5b62017-01-13 12:06:45 +05306TARGETS += cpufreq
Andrew Morton66a01b92013-02-27 17:05:56 -08007TARGETS += cpu-hotplug
Andrew Morton66a01b92013-02-27 17:05:56 -08008TARGETS += efivarfs
Andrew Morton96e869d2014-12-18 16:17:43 -08009TARGETS += exec
Christian Braunerce290a12018-03-13 17:55:27 +010010TARGETS += filesystems
Andrew Morton96e869d2014-12-18 16:17:43 -080011TARGETS += firmware
12TARGETS += ftrace
Darren Hartecac1a72015-05-12 21:07:55 -070013TARGETS += futex
Bamvor Jian Zhang22f65922016-11-21 18:16:11 +080014TARGETS += gpio
Stafford Horne63203032017-01-12 00:16:07 +090015TARGETS += intel_pstate
Bamvor Jian Zhang7e722472015-11-17 22:35:43 +080016TARGETS += ipc
Pavel Emelyanov58c7be82013-04-30 15:27:06 -070017TARGETS += kcmp
Paolo Bonzini783e9e52018-03-27 11:49:19 +020018TARGETS += kvm
Kees Cook317dc342015-11-06 16:30:32 -080019TARGETS += lib
Pranith Kumarb6d97342015-09-11 13:07:42 -070020TARGETS += membarrier
David Herrmann4f5ce5e2014-08-08 14:25:32 -070021TARGETS += memfd
Pavel Emelyanov58c7be82013-04-30 15:27:06 -070022TARGETS += memory-hotplug
Eric W. Biedermandb181ce2014-07-29 15:50:44 -070023TARGETS += mount
Andrew Morton96e869d2014-12-18 16:17:43 -080024TARGETS += mqueue
David S. Millera6f68032013-03-20 15:07:56 -040025TARGETS += net
Andrey Vagin6ad92bf2016-09-06 00:47:16 -070026TARGETS += nsfs
Michael Ellerman0e56dac2013-08-06 17:42:35 +100027TARGETS += powerpc
Alexey Dobriyan9cd65652018-04-10 16:31:45 -070028TARGETS += proc
Hiraku Toyookacc04a462015-10-02 20:46:39 +090029TARGETS += pstore
Andrew Morton96e869d2014-12-18 16:17:43 -080030TARGETS += ptrace
Mathieu Desnoyersccba8b62018-06-02 08:44:08 -040031TARGETS += rseq
Kees Cookc99ee512015-06-16 10:54:14 -070032TARGETS += seccomp
Stas Sergeev19fd2862016-04-14 23:20:05 +030033TARGETS += sigaltstack
Tim Bird3ce51052014-12-03 10:42:21 -080034TARGETS += size
Al Virob8826e52017-02-18 22:07:24 -050035TARGETS += splice
Bamvor Jian Zhang1087d012015-09-09 21:06:25 +080036TARGETS += static_keys
Emilio López822081602016-10-19 09:49:48 -030037TARGETS += sync
Andrew Morton96e869d2014-12-18 16:17:43 -080038TARGETS += sysctl
Shuah Khan2278e5e2015-06-19 13:13:43 -060039ifneq (1, $(quicktest))
Andrew Morton96e869d2014-12-18 16:17:43 -080040TARGETS += timers
Shuah Khan2278e5e2015-06-19 13:13:43 -060041endif
Andrew Morton96e869d2014-12-18 16:17:43 -080042TARGETS += user
43TARGETS += vm
Andy Lutomirski3f705df2015-04-06 23:11:06 -070044TARGETS += x86
Naresh Kambojuf21fb792015-08-18 12:31:59 +053045TARGETS += zram
Andrew Morton96e869d2014-12-18 16:17:43 -080046#Please keep the TARGETS list alphabetically sorted
Shuah Khan2278e5e2015-06-19 13:13:43 -060047# Run "make quicktest=1 run_tests" or
SeongJae Parkc6a13fa2017-04-14 08:43:16 +090048# "make quicktest=1 kselftest" from top level Makefile
Frederic Weisbecker274343a2012-01-12 17:20:44 -080049
Shuah Khanddddda92014-07-02 09:51:38 -060050TARGETS_HOTPLUG = cpu-hotplug
51TARGETS_HOTPLUG += memory-hotplug
52
Shuah Khan67d87122015-03-18 11:57:39 -060053# Clear LDFLAGS and MAKEFLAGS if called from main
54# Makefile to avoid test build failures when test
55# Makefile doesn't have explicit build rules.
56ifeq (1,$(MAKELEVEL))
Arnaldo Carvalho de Melo60df4642015-05-14 16:55:18 -030057override LDFLAGS =
Shuah Khan67d87122015-03-18 11:57:39 -060058override MAKEFLAGS =
59endif
60
Shuah Khan52fd1d02017-09-07 19:57:43 -060061ifneq ($(KBUILD_SRC),)
62override LDFLAGS =
63endif
64
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +080065BUILD := $(O)
66ifndef BUILD
67 BUILD := $(KBUILD_OUTPUT)
68endif
69ifndef BUILD
70 BUILD := $(shell pwd)
71endif
72
Shuah Khan44f01352018-02-21 17:25:55 -070073# KSFT_TAP_LEVEL is used from KSFT framework to prevent nested TAP header
74# printing from tests. Applicable to run_tests case where run_tests adds
75# TAP header prior running tests and when a test program invokes another
76# with system() call. Export it here to cover override RUN_TESTS defines.
77export KSFT_TAP_LEVEL=`echo 1`
78
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +080079export BUILD
Frederic Weisbecker274343a2012-01-12 17:20:44 -080080all:
Shuah Khan1ede0532017-09-18 17:30:50 -060081 @for TARGET in $(TARGETS); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +080082 BUILD_TARGET=$$BUILD/$$TARGET; \
83 mkdir $$BUILD_TARGET -p; \
84 make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
Frederic Weisbecker274343a2012-01-12 17:20:44 -080085 done;
86
Andrew Mortoncab6b052012-03-28 14:42:54 -070087run_tests: all
Shuah Khan1ede0532017-09-18 17:30:50 -060088 @for TARGET in $(TARGETS); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +080089 BUILD_TARGET=$$BUILD/$$TARGET; \
90 make OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\
Frederic Weisbeckerf467f712012-03-28 14:42:54 -070091 done;
92
Shuah Khanddddda92014-07-02 09:51:38 -060093hotplug:
Shuah Khan1ede0532017-09-18 17:30:50 -060094 @for TARGET in $(TARGETS_HOTPLUG); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +080095 BUILD_TARGET=$$BUILD/$$TARGET; \
96 make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
Shuah Khanddddda92014-07-02 09:51:38 -060097 done;
98
99run_hotplug: hotplug
Shuah Khan1ede0532017-09-18 17:30:50 -0600100 @for TARGET in $(TARGETS_HOTPLUG); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +0800101 BUILD_TARGET=$$BUILD/$$TARGET; \
102 make OUTPUT=$$BUILD_TARGET -C $$TARGET run_full_test;\
Shuah Khanddddda92014-07-02 09:51:38 -0600103 done;
104
105clean_hotplug:
Shuah Khan1ede0532017-09-18 17:30:50 -0600106 @for TARGET in $(TARGETS_HOTPLUG); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +0800107 BUILD_TARGET=$$BUILD/$$TARGET; \
108 make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
Shuah Khanddddda92014-07-02 09:51:38 -0600109 done;
110
Hiraku Toyookaf615e2b2015-10-02 20:46:41 +0900111run_pstore_crash:
112 make -C pstore run_crash
113
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100114INSTALL_PATH ?= install
115INSTALL_PATH := $(abspath $(INSTALL_PATH))
116ALL_SCRIPT := $(INSTALL_PATH)/run_kselftest.sh
117
118install:
119ifdef INSTALL_PATH
120 @# Ask all targets to install their files
121 mkdir -p $(INSTALL_PATH)
Shuah Khan1ede0532017-09-18 17:30:50 -0600122 @for TARGET in $(TARGETS); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +0800123 BUILD_TARGET=$$BUILD/$$TARGET; \
124 make OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100125 done;
126
127 @# Ask all targets to emit their test scripts
Rolf Eike Beera2b1e8a2016-12-14 11:59:34 +0100128 echo "#!/bin/sh" > $(ALL_SCRIPT)
Michael Ellerman14f18892018-01-16 17:10:39 +1100129 echo "BASE_DIR=\$$(realpath \$$(dirname \$$0))" >> $(ALL_SCRIPT)
130 echo "cd \$$BASE_DIR" >> $(ALL_SCRIPT)
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100131 echo "ROOT=\$$PWD" >> $(ALL_SCRIPT)
Michael Ellerman14f18892018-01-16 17:10:39 +1100132 echo "if [ \"\$$1\" = \"--summary\" ]; then" >> $(ALL_SCRIPT)
133 echo " OUTPUT=\$$BASE_DIR/output.log" >> $(ALL_SCRIPT)
134 echo " cat /dev/null > \$$OUTPUT" >> $(ALL_SCRIPT)
135 echo "else" >> $(ALL_SCRIPT)
136 echo " OUTPUT=/dev/stdout" >> $(ALL_SCRIPT)
137 echo "fi" >> $(ALL_SCRIPT)
Shuah Khan44f01352018-02-21 17:25:55 -0700138 echo "export KSFT_TAP_LEVEL=`echo 1`" >> $(ALL_SCRIPT)
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100139
140 for TARGET in $(TARGETS); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +0800141 BUILD_TARGET=$$BUILD/$$TARGET; \
Shuah Khan44f01352018-02-21 17:25:55 -0700142 echo "echo ; echo TAP version 13" >> $(ALL_SCRIPT); \
143 echo "echo Running tests in $$TARGET" >> $(ALL_SCRIPT); \
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100144 echo "echo ========================================" >> $(ALL_SCRIPT); \
Michael Ellerman88893cf2018-03-23 20:44:27 +1100145 echo "[ -w /dev/kmsg ] && echo \"kselftest: Running tests in $$TARGET\" >> /dev/kmsg" >> $(ALL_SCRIPT); \
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100146 echo "cd $$TARGET" >> $(ALL_SCRIPT); \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +0800147 make -s --no-print-directory OUTPUT=$$BUILD_TARGET -C $$TARGET emit_tests >> $(ALL_SCRIPT); \
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100148 echo "cd \$$ROOT" >> $(ALL_SCRIPT); \
149 done;
150
151 chmod u+x $(ALL_SCRIPT)
152else
153 $(error Error: set INSTALL_PATH to use install)
154endif
155
Frederic Weisbecker274343a2012-01-12 17:20:44 -0800156clean:
Shuah Khan1ede0532017-09-18 17:30:50 -0600157 @for TARGET in $(TARGETS); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +0800158 BUILD_TARGET=$$BUILD/$$TARGET; \
159 make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
Frederic Weisbecker274343a2012-01-12 17:20:44 -0800160 done;
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100161
SeongJae Park584f34f2017-04-14 08:44:46 +0900162.PHONY: all run_tests hotplug run_hotplug clean_hotplug run_pstore_crash install clean