blob: 3c9c0bbe7dbb669786f6700c8418f35edc74b6b6 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
Daniel Borkmann5aa5bd12016-10-17 14:28:36 +02002TARGETS = bpf
3TARGETS += breakpoints
Bamvor Jian Zhangf4ecb322015-11-17 22:35:42 +08004TARGETS += capabilities
Viresh Kumare66d5b62017-01-13 12:06:45 +05305TARGETS += cpufreq
Andrew Morton66a01b92013-02-27 17:05:56 -08006TARGETS += cpu-hotplug
Andrew Morton66a01b92013-02-27 17:05:56 -08007TARGETS += efivarfs
Andrew Morton96e869d2014-12-18 16:17:43 -08008TARGETS += exec
9TARGETS += firmware
10TARGETS += ftrace
Darren Hartecac1a72015-05-12 21:07:55 -070011TARGETS += futex
Bamvor Jian Zhang22f65922016-11-21 18:16:11 +080012TARGETS += gpio
Stafford Horne63203032017-01-12 00:16:07 +090013TARGETS += intel_pstate
Bamvor Jian Zhang7e722472015-11-17 22:35:43 +080014TARGETS += ipc
Pavel Emelyanov58c7be82013-04-30 15:27:06 -070015TARGETS += kcmp
Kees Cook317dc342015-11-06 16:30:32 -080016TARGETS += lib
Pranith Kumarb6d97342015-09-11 13:07:42 -070017TARGETS += membarrier
David Herrmann4f5ce5e2014-08-08 14:25:32 -070018TARGETS += memfd
Pavel Emelyanov58c7be82013-04-30 15:27:06 -070019TARGETS += memory-hotplug
Eric W. Biedermandb181ce2014-07-29 15:50:44 -070020TARGETS += mount
Andrew Morton96e869d2014-12-18 16:17:43 -080021TARGETS += mqueue
David S. Millera6f68032013-03-20 15:07:56 -040022TARGETS += net
Andrey Vagin6ad92bf2016-09-06 00:47:16 -070023TARGETS += nsfs
Michael Ellerman0e56dac2013-08-06 17:42:35 +100024TARGETS += powerpc
Hiraku Toyookacc04a462015-10-02 20:46:39 +090025TARGETS += pstore
Andrew Morton96e869d2014-12-18 16:17:43 -080026TARGETS += ptrace
Kees Cookc99ee512015-06-16 10:54:14 -070027TARGETS += seccomp
Stas Sergeev19fd2862016-04-14 23:20:05 +030028TARGETS += sigaltstack
Tim Bird3ce51052014-12-03 10:42:21 -080029TARGETS += size
Al Virob8826e52017-02-18 22:07:24 -050030TARGETS += splice
Bamvor Jian Zhang1087d012015-09-09 21:06:25 +080031TARGETS += static_keys
Emilio López822081602016-10-19 09:49:48 -030032TARGETS += sync
Andrew Morton96e869d2014-12-18 16:17:43 -080033TARGETS += sysctl
Shuah Khan2278e5e2015-06-19 13:13:43 -060034ifneq (1, $(quicktest))
Andrew Morton96e869d2014-12-18 16:17:43 -080035TARGETS += timers
Shuah Khan2278e5e2015-06-19 13:13:43 -060036endif
Andrew Morton96e869d2014-12-18 16:17:43 -080037TARGETS += user
38TARGETS += vm
Andy Lutomirski3f705df2015-04-06 23:11:06 -070039TARGETS += x86
Naresh Kambojuf21fb792015-08-18 12:31:59 +053040TARGETS += zram
Andrew Morton96e869d2014-12-18 16:17:43 -080041#Please keep the TARGETS list alphabetically sorted
Shuah Khan2278e5e2015-06-19 13:13:43 -060042# Run "make quicktest=1 run_tests" or
SeongJae Parkc6a13fa2017-04-14 08:43:16 +090043# "make quicktest=1 kselftest" from top level Makefile
Frederic Weisbecker274343a2012-01-12 17:20:44 -080044
Shuah Khanddddda92014-07-02 09:51:38 -060045TARGETS_HOTPLUG = cpu-hotplug
46TARGETS_HOTPLUG += memory-hotplug
47
Shuah Khan67d87122015-03-18 11:57:39 -060048# Clear LDFLAGS and MAKEFLAGS if called from main
49# Makefile to avoid test build failures when test
50# Makefile doesn't have explicit build rules.
51ifeq (1,$(MAKELEVEL))
Arnaldo Carvalho de Melo60df4642015-05-14 16:55:18 -030052override LDFLAGS =
Shuah Khan67d87122015-03-18 11:57:39 -060053override MAKEFLAGS =
54endif
55
Shuah Khan52fd1d02017-09-07 19:57:43 -060056ifneq ($(KBUILD_SRC),)
57override LDFLAGS =
58endif
59
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +080060BUILD := $(O)
61ifndef BUILD
62 BUILD := $(KBUILD_OUTPUT)
63endif
64ifndef BUILD
65 BUILD := $(shell pwd)
66endif
67
68export BUILD
Frederic Weisbecker274343a2012-01-12 17:20:44 -080069all:
Shuah Khan1ede0532017-09-18 17:30:50 -060070 @for TARGET in $(TARGETS); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +080071 BUILD_TARGET=$$BUILD/$$TARGET; \
72 mkdir $$BUILD_TARGET -p; \
73 make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
Frederic Weisbecker274343a2012-01-12 17:20:44 -080074 done;
75
Andrew Mortoncab6b052012-03-28 14:42:54 -070076run_tests: all
Shuah Khan1ede0532017-09-18 17:30:50 -060077 @for TARGET in $(TARGETS); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +080078 BUILD_TARGET=$$BUILD/$$TARGET; \
79 make OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\
Frederic Weisbeckerf467f712012-03-28 14:42:54 -070080 done;
81
Shuah Khanddddda92014-07-02 09:51:38 -060082hotplug:
Shuah Khan1ede0532017-09-18 17:30:50 -060083 @for TARGET in $(TARGETS_HOTPLUG); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +080084 BUILD_TARGET=$$BUILD/$$TARGET; \
85 make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
Shuah Khanddddda92014-07-02 09:51:38 -060086 done;
87
88run_hotplug: hotplug
Shuah Khan1ede0532017-09-18 17:30:50 -060089 @for TARGET in $(TARGETS_HOTPLUG); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +080090 BUILD_TARGET=$$BUILD/$$TARGET; \
91 make OUTPUT=$$BUILD_TARGET -C $$TARGET run_full_test;\
Shuah Khanddddda92014-07-02 09:51:38 -060092 done;
93
94clean_hotplug:
Shuah Khan1ede0532017-09-18 17:30:50 -060095 @for TARGET in $(TARGETS_HOTPLUG); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +080096 BUILD_TARGET=$$BUILD/$$TARGET; \
97 make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
Shuah Khanddddda92014-07-02 09:51:38 -060098 done;
99
Hiraku Toyookaf615e2b2015-10-02 20:46:41 +0900100run_pstore_crash:
101 make -C pstore run_crash
102
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100103INSTALL_PATH ?= install
104INSTALL_PATH := $(abspath $(INSTALL_PATH))
105ALL_SCRIPT := $(INSTALL_PATH)/run_kselftest.sh
106
107install:
108ifdef INSTALL_PATH
109 @# Ask all targets to install their files
110 mkdir -p $(INSTALL_PATH)
Shuah Khan1ede0532017-09-18 17:30:50 -0600111 @for TARGET in $(TARGETS); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +0800112 BUILD_TARGET=$$BUILD/$$TARGET; \
113 make OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100114 done;
115
116 @# Ask all targets to emit their test scripts
Rolf Eike Beera2b1e8a2016-12-14 11:59:34 +0100117 echo "#!/bin/sh" > $(ALL_SCRIPT)
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100118 echo "cd \$$(dirname \$$0)" >> $(ALL_SCRIPT)
119 echo "ROOT=\$$PWD" >> $(ALL_SCRIPT)
120
121 for TARGET in $(TARGETS); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +0800122 BUILD_TARGET=$$BUILD/$$TARGET; \
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100123 echo "echo ; echo Running tests in $$TARGET" >> $(ALL_SCRIPT); \
124 echo "echo ========================================" >> $(ALL_SCRIPT); \
125 echo "cd $$TARGET" >> $(ALL_SCRIPT); \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +0800126 make -s --no-print-directory OUTPUT=$$BUILD_TARGET -C $$TARGET emit_tests >> $(ALL_SCRIPT); \
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100127 echo "cd \$$ROOT" >> $(ALL_SCRIPT); \
128 done;
129
130 chmod u+x $(ALL_SCRIPT)
131else
132 $(error Error: set INSTALL_PATH to use install)
133endif
134
Frederic Weisbecker274343a2012-01-12 17:20:44 -0800135clean:
Shuah Khan1ede0532017-09-18 17:30:50 -0600136 @for TARGET in $(TARGETS); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +0800137 BUILD_TARGET=$$BUILD/$$TARGET; \
138 make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
Frederic Weisbecker274343a2012-01-12 17:20:44 -0800139 done;
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100140
SeongJae Park584f34f2017-04-14 08:44:46 +0900141.PHONY: all run_tests hotplug run_hotplug clean_hotplug run_pstore_crash install clean