blob: eaf599dc2137b85c18dbb09b80465528ca07c7b0 [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
10TARGETS += firmware
11TARGETS += ftrace
Darren Hartecac1a72015-05-12 21:07:55 -070012TARGETS += futex
Bamvor Jian Zhang22f65922016-11-21 18:16:11 +080013TARGETS += gpio
Stafford Horne63203032017-01-12 00:16:07 +090014TARGETS += intel_pstate
Bamvor Jian Zhang7e722472015-11-17 22:35:43 +080015TARGETS += ipc
Pavel Emelyanov58c7be82013-04-30 15:27:06 -070016TARGETS += kcmp
Kees Cook317dc342015-11-06 16:30:32 -080017TARGETS += lib
Pranith Kumarb6d97342015-09-11 13:07:42 -070018TARGETS += membarrier
David Herrmann4f5ce5e2014-08-08 14:25:32 -070019TARGETS += memfd
Pavel Emelyanov58c7be82013-04-30 15:27:06 -070020TARGETS += memory-hotplug
Eric W. Biedermandb181ce2014-07-29 15:50:44 -070021TARGETS += mount
Andrew Morton96e869d2014-12-18 16:17:43 -080022TARGETS += mqueue
David S. Millera6f68032013-03-20 15:07:56 -040023TARGETS += net
Andrey Vagin6ad92bf2016-09-06 00:47:16 -070024TARGETS += nsfs
Michael Ellerman0e56dac2013-08-06 17:42:35 +100025TARGETS += powerpc
Hiraku Toyookacc04a462015-10-02 20:46:39 +090026TARGETS += pstore
Andrew Morton96e869d2014-12-18 16:17:43 -080027TARGETS += ptrace
Kees Cookc99ee512015-06-16 10:54:14 -070028TARGETS += seccomp
Stas Sergeev19fd2862016-04-14 23:20:05 +030029TARGETS += sigaltstack
Tim Bird3ce51052014-12-03 10:42:21 -080030TARGETS += size
Al Virob8826e52017-02-18 22:07:24 -050031TARGETS += splice
Bamvor Jian Zhang1087d012015-09-09 21:06:25 +080032TARGETS += static_keys
Emilio López822081602016-10-19 09:49:48 -030033TARGETS += sync
Andrew Morton96e869d2014-12-18 16:17:43 -080034TARGETS += sysctl
Shuah Khan2278e5e2015-06-19 13:13:43 -060035ifneq (1, $(quicktest))
Andrew Morton96e869d2014-12-18 16:17:43 -080036TARGETS += timers
Shuah Khan2278e5e2015-06-19 13:13:43 -060037endif
Andrew Morton96e869d2014-12-18 16:17:43 -080038TARGETS += user
39TARGETS += vm
Andy Lutomirski3f705df2015-04-06 23:11:06 -070040TARGETS += x86
Naresh Kambojuf21fb792015-08-18 12:31:59 +053041TARGETS += zram
Andrew Morton96e869d2014-12-18 16:17:43 -080042#Please keep the TARGETS list alphabetically sorted
Shuah Khan2278e5e2015-06-19 13:13:43 -060043# Run "make quicktest=1 run_tests" or
SeongJae Parkc6a13fa2017-04-14 08:43:16 +090044# "make quicktest=1 kselftest" from top level Makefile
Frederic Weisbecker274343a2012-01-12 17:20:44 -080045
Shuah Khanddddda92014-07-02 09:51:38 -060046TARGETS_HOTPLUG = cpu-hotplug
47TARGETS_HOTPLUG += memory-hotplug
48
Shuah Khan67d87122015-03-18 11:57:39 -060049# Clear LDFLAGS and MAKEFLAGS if called from main
50# Makefile to avoid test build failures when test
51# Makefile doesn't have explicit build rules.
52ifeq (1,$(MAKELEVEL))
Arnaldo Carvalho de Melo60df4642015-05-14 16:55:18 -030053override LDFLAGS =
Shuah Khan67d87122015-03-18 11:57:39 -060054override MAKEFLAGS =
55endif
56
Shuah Khan52fd1d02017-09-07 19:57:43 -060057ifneq ($(KBUILD_SRC),)
58override LDFLAGS =
59endif
60
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +080061BUILD := $(O)
62ifndef BUILD
63 BUILD := $(KBUILD_OUTPUT)
64endif
65ifndef BUILD
66 BUILD := $(shell pwd)
67endif
68
69export BUILD
Frederic Weisbecker274343a2012-01-12 17:20:44 -080070all:
Shuah Khan1ede0532017-09-18 17:30:50 -060071 @for TARGET in $(TARGETS); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +080072 BUILD_TARGET=$$BUILD/$$TARGET; \
73 mkdir $$BUILD_TARGET -p; \
74 make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
Frederic Weisbecker274343a2012-01-12 17:20:44 -080075 done;
76
Andrew Mortoncab6b052012-03-28 14:42:54 -070077run_tests: all
Shuah Khan1ede0532017-09-18 17:30:50 -060078 @for TARGET in $(TARGETS); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +080079 BUILD_TARGET=$$BUILD/$$TARGET; \
80 make OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\
Frederic Weisbeckerf467f712012-03-28 14:42:54 -070081 done;
82
Shuah Khanddddda92014-07-02 09:51:38 -060083hotplug:
Shuah Khan1ede0532017-09-18 17:30:50 -060084 @for TARGET in $(TARGETS_HOTPLUG); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +080085 BUILD_TARGET=$$BUILD/$$TARGET; \
86 make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
Shuah Khanddddda92014-07-02 09:51:38 -060087 done;
88
89run_hotplug: hotplug
Shuah Khan1ede0532017-09-18 17:30:50 -060090 @for TARGET in $(TARGETS_HOTPLUG); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +080091 BUILD_TARGET=$$BUILD/$$TARGET; \
92 make OUTPUT=$$BUILD_TARGET -C $$TARGET run_full_test;\
Shuah Khanddddda92014-07-02 09:51:38 -060093 done;
94
95clean_hotplug:
Shuah Khan1ede0532017-09-18 17:30:50 -060096 @for TARGET in $(TARGETS_HOTPLUG); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +080097 BUILD_TARGET=$$BUILD/$$TARGET; \
98 make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
Shuah Khanddddda92014-07-02 09:51:38 -060099 done;
100
Hiraku Toyookaf615e2b2015-10-02 20:46:41 +0900101run_pstore_crash:
102 make -C pstore run_crash
103
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100104INSTALL_PATH ?= install
105INSTALL_PATH := $(abspath $(INSTALL_PATH))
106ALL_SCRIPT := $(INSTALL_PATH)/run_kselftest.sh
107
108install:
109ifdef INSTALL_PATH
110 @# Ask all targets to install their files
111 mkdir -p $(INSTALL_PATH)
Shuah Khan1ede0532017-09-18 17:30:50 -0600112 @for TARGET in $(TARGETS); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +0800113 BUILD_TARGET=$$BUILD/$$TARGET; \
114 make OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100115 done;
116
117 @# Ask all targets to emit their test scripts
Rolf Eike Beera2b1e8a2016-12-14 11:59:34 +0100118 echo "#!/bin/sh" > $(ALL_SCRIPT)
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100119 echo "cd \$$(dirname \$$0)" >> $(ALL_SCRIPT)
120 echo "ROOT=\$$PWD" >> $(ALL_SCRIPT)
121
122 for TARGET in $(TARGETS); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +0800123 BUILD_TARGET=$$BUILD/$$TARGET; \
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100124 echo "echo ; echo Running tests in $$TARGET" >> $(ALL_SCRIPT); \
125 echo "echo ========================================" >> $(ALL_SCRIPT); \
126 echo "cd $$TARGET" >> $(ALL_SCRIPT); \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +0800127 make -s --no-print-directory OUTPUT=$$BUILD_TARGET -C $$TARGET emit_tests >> $(ALL_SCRIPT); \
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100128 echo "cd \$$ROOT" >> $(ALL_SCRIPT); \
129 done;
130
131 chmod u+x $(ALL_SCRIPT)
132else
133 $(error Error: set INSTALL_PATH to use install)
134endif
135
Frederic Weisbecker274343a2012-01-12 17:20:44 -0800136clean:
Shuah Khan1ede0532017-09-18 17:30:50 -0600137 @for TARGET in $(TARGETS); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +0800138 BUILD_TARGET=$$BUILD/$$TARGET; \
139 make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
Frederic Weisbecker274343a2012-01-12 17:20:44 -0800140 done;
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100141
SeongJae Park584f34f2017-04-14 08:44:46 +0900142.PHONY: all run_tests hotplug run_hotplug clean_hotplug run_pstore_crash install clean