blob: cfbc3528e9efbcdabf7039e37627b9b97835028b [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
Roman Gushchin84092dbc2018-05-11 19:03:49 +01006TARGETS += cgroup
Viresh Kumare66d5b62017-01-13 12:06:45 +05307TARGETS += cpufreq
Andrew Morton66a01b92013-02-27 17:05:56 -08008TARGETS += cpu-hotplug
Tom Murphy6edf2e32018-11-27 10:33:08 +00009TARGETS += drivers/dma-buf
Andrew Morton66a01b92013-02-27 17:05:56 -080010TARGETS += efivarfs
Andrew Morton96e869d2014-12-18 16:17:43 -080011TARGETS += exec
Christian Braunerce290a12018-03-13 17:55:27 +010012TARGETS += filesystems
Andrew Morton96e869d2014-12-18 16:17:43 -080013TARGETS += firmware
14TARGETS += ftrace
Darren Hartecac1a72015-05-12 21:07:55 -070015TARGETS += futex
Bamvor Jian Zhang22f65922016-11-21 18:16:11 +080016TARGETS += gpio
Mimi Zohara802ed02018-11-14 12:30:19 -050017TARGETS += ima
Stafford Horne63203032017-01-12 00:16:07 +090018TARGETS += intel_pstate
Bamvor Jian Zhang7e722472015-11-17 22:35:43 +080019TARGETS += ipc
Sean Younge55c8842018-10-16 15:09:31 +010020TARGETS += ir
Pavel Emelyanov58c7be82013-04-30 15:27:06 -070021TARGETS += kcmp
Paolo Bonzini783e9e52018-03-27 11:49:19 +020022TARGETS += kvm
Kees Cook317dc342015-11-06 16:30:32 -080023TARGETS += lib
Pranith Kumarb6d97342015-09-11 13:07:42 -070024TARGETS += membarrier
David Herrmann4f5ce5e2014-08-08 14:25:32 -070025TARGETS += memfd
Pavel Emelyanov58c7be82013-04-30 15:27:06 -070026TARGETS += memory-hotplug
Eric W. Biedermandb181ce2014-07-29 15:50:44 -070027TARGETS += mount
Andrew Morton96e869d2014-12-18 16:17:43 -080028TARGETS += mqueue
David S. Millera6f68032013-03-20 15:07:56 -040029TARGETS += net
Florian Westphal25d8bce2018-10-31 18:26:21 +010030TARGETS += netfilter
Willem de Bruijncda261f2018-12-20 16:22:54 -050031TARGETS += networking/timestamping
Andrey Vagin6ad92bf2016-09-06 00:47:16 -070032TARGETS += nsfs
Christian Brauner575a0ae2018-12-29 22:27:33 +010033TARGETS += pidfd
Michael Ellerman0e56dac2013-08-06 17:42:35 +100034TARGETS += powerpc
Alexey Dobriyan9cd65652018-04-10 16:31:45 -070035TARGETS += proc
Hiraku Toyookacc04a462015-10-02 20:46:39 +090036TARGETS += pstore
Andrew Morton96e869d2014-12-18 16:17:43 -080037TARGETS += ptrace
Mathieu Desnoyersccba8b62018-06-02 08:44:08 -040038TARGETS += rseq
Alexandre Bellonia12ab9e2018-04-19 14:50:29 +020039TARGETS += rtc
Kees Cookc99ee512015-06-16 10:54:14 -070040TARGETS += seccomp
Stas Sergeev19fd2862016-04-14 23:20:05 +030041TARGETS += sigaltstack
Tim Bird3ce51052014-12-03 10:42:21 -080042TARGETS += size
Tom Hromatka3c545082018-04-26 10:54:09 -060043TARGETS += sparc64
Al Virob8826e52017-02-18 22:07:24 -050044TARGETS += splice
Bamvor Jian Zhang1087d012015-09-09 21:06:25 +080045TARGETS += static_keys
Emilio López822081602016-10-19 09:49:48 -030046TARGETS += sync
Andrew Morton96e869d2014-12-18 16:17:43 -080047TARGETS += sysctl
Shuah Khan2278e5e2015-06-19 13:13:43 -060048ifneq (1, $(quicktest))
Andrew Morton96e869d2014-12-18 16:17:43 -080049TARGETS += timers
Shuah Khan2278e5e2015-06-19 13:13:43 -060050endif
Andrew Morton96e869d2014-12-18 16:17:43 -080051TARGETS += user
52TARGETS += vm
Andy Lutomirski3f705df2015-04-06 23:11:06 -070053TARGETS += x86
Naresh Kambojuf21fb792015-08-18 12:31:59 +053054TARGETS += zram
Andrew Morton96e869d2014-12-18 16:17:43 -080055#Please keep the TARGETS list alphabetically sorted
Shuah Khan2278e5e2015-06-19 13:13:43 -060056# Run "make quicktest=1 run_tests" or
SeongJae Parkc6a13fa2017-04-14 08:43:16 +090057# "make quicktest=1 kselftest" from top level Makefile
Frederic Weisbecker274343a2012-01-12 17:20:44 -080058
Shuah Khanddddda92014-07-02 09:51:38 -060059TARGETS_HOTPLUG = cpu-hotplug
60TARGETS_HOTPLUG += memory-hotplug
61
Shuah Khan67d87122015-03-18 11:57:39 -060062# Clear LDFLAGS and MAKEFLAGS if called from main
63# Makefile to avoid test build failures when test
64# Makefile doesn't have explicit build rules.
65ifeq (1,$(MAKELEVEL))
Arnaldo Carvalho de Melo60df4642015-05-14 16:55:18 -030066override LDFLAGS =
Shuah Khan67d87122015-03-18 11:57:39 -060067override MAKEFLAGS =
68endif
69
Shuah Khan52fd1d02017-09-07 19:57:43 -060070ifneq ($(KBUILD_SRC),)
71override LDFLAGS =
72endif
73
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +080074BUILD := $(O)
75ifndef BUILD
76 BUILD := $(KBUILD_OUTPUT)
77endif
78ifndef BUILD
79 BUILD := $(shell pwd)
80endif
81
Shuah Khan44f01352018-02-21 17:25:55 -070082# KSFT_TAP_LEVEL is used from KSFT framework to prevent nested TAP header
83# printing from tests. Applicable to run_tests case where run_tests adds
84# TAP header prior running tests and when a test program invokes another
85# with system() call. Export it here to cover override RUN_TESTS defines.
86export KSFT_TAP_LEVEL=`echo 1`
87
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +080088export BUILD
Frederic Weisbecker274343a2012-01-12 17:20:44 -080089all:
Shuah Khan1ede0532017-09-18 17:30:50 -060090 @for TARGET in $(TARGETS); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +080091 BUILD_TARGET=$$BUILD/$$TARGET; \
92 mkdir $$BUILD_TARGET -p; \
93 make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
Frederic Weisbecker274343a2012-01-12 17:20:44 -080094 done;
95
Andrew Mortoncab6b052012-03-28 14:42:54 -070096run_tests: all
Shuah Khan1ede0532017-09-18 17:30:50 -060097 @for TARGET in $(TARGETS); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +080098 BUILD_TARGET=$$BUILD/$$TARGET; \
99 make OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\
Frederic Weisbeckerf467f712012-03-28 14:42:54 -0700100 done;
101
Shuah Khanddddda92014-07-02 09:51:38 -0600102hotplug:
Shuah Khan1ede0532017-09-18 17:30:50 -0600103 @for TARGET in $(TARGETS_HOTPLUG); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +0800104 BUILD_TARGET=$$BUILD/$$TARGET; \
105 make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
Shuah Khanddddda92014-07-02 09:51:38 -0600106 done;
107
108run_hotplug: hotplug
Shuah Khan1ede0532017-09-18 17:30:50 -0600109 @for TARGET in $(TARGETS_HOTPLUG); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +0800110 BUILD_TARGET=$$BUILD/$$TARGET; \
111 make OUTPUT=$$BUILD_TARGET -C $$TARGET run_full_test;\
Shuah Khanddddda92014-07-02 09:51:38 -0600112 done;
113
114clean_hotplug:
Shuah Khan1ede0532017-09-18 17:30:50 -0600115 @for TARGET in $(TARGETS_HOTPLUG); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +0800116 BUILD_TARGET=$$BUILD/$$TARGET; \
117 make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
Shuah Khanddddda92014-07-02 09:51:38 -0600118 done;
119
Hiraku Toyookaf615e2b2015-10-02 20:46:41 +0900120run_pstore_crash:
121 make -C pstore run_crash
122
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100123INSTALL_PATH ?= install
124INSTALL_PATH := $(abspath $(INSTALL_PATH))
125ALL_SCRIPT := $(INSTALL_PATH)/run_kselftest.sh
126
127install:
128ifdef INSTALL_PATH
129 @# Ask all targets to install their files
130 mkdir -p $(INSTALL_PATH)
Shuah Khan1ede0532017-09-18 17:30:50 -0600131 @for TARGET in $(TARGETS); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +0800132 BUILD_TARGET=$$BUILD/$$TARGET; \
133 make OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100134 done;
135
136 @# Ask all targets to emit their test scripts
Rolf Eike Beera2b1e8a2016-12-14 11:59:34 +0100137 echo "#!/bin/sh" > $(ALL_SCRIPT)
Michael Ellerman14f18892018-01-16 17:10:39 +1100138 echo "BASE_DIR=\$$(realpath \$$(dirname \$$0))" >> $(ALL_SCRIPT)
139 echo "cd \$$BASE_DIR" >> $(ALL_SCRIPT)
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100140 echo "ROOT=\$$PWD" >> $(ALL_SCRIPT)
Michael Ellerman14f18892018-01-16 17:10:39 +1100141 echo "if [ \"\$$1\" = \"--summary\" ]; then" >> $(ALL_SCRIPT)
142 echo " OUTPUT=\$$BASE_DIR/output.log" >> $(ALL_SCRIPT)
143 echo " cat /dev/null > \$$OUTPUT" >> $(ALL_SCRIPT)
144 echo "else" >> $(ALL_SCRIPT)
145 echo " OUTPUT=/dev/stdout" >> $(ALL_SCRIPT)
146 echo "fi" >> $(ALL_SCRIPT)
Shuah Khan (Samsung OSG)3df61312018-05-01 12:15:34 -0600147 echo "export KSFT_TAP_LEVEL=1" >> $(ALL_SCRIPT)
148 echo "export skip=4" >> $(ALL_SCRIPT)
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100149
150 for TARGET in $(TARGETS); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +0800151 BUILD_TARGET=$$BUILD/$$TARGET; \
Shuah Khan44f01352018-02-21 17:25:55 -0700152 echo "echo ; echo TAP version 13" >> $(ALL_SCRIPT); \
153 echo "echo Running tests in $$TARGET" >> $(ALL_SCRIPT); \
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100154 echo "echo ========================================" >> $(ALL_SCRIPT); \
Michael Ellerman88893cf2018-03-23 20:44:27 +1100155 echo "[ -w /dev/kmsg ] && echo \"kselftest: Running tests in $$TARGET\" >> /dev/kmsg" >> $(ALL_SCRIPT); \
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100156 echo "cd $$TARGET" >> $(ALL_SCRIPT); \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +0800157 make -s --no-print-directory OUTPUT=$$BUILD_TARGET -C $$TARGET emit_tests >> $(ALL_SCRIPT); \
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100158 echo "cd \$$ROOT" >> $(ALL_SCRIPT); \
159 done;
160
161 chmod u+x $(ALL_SCRIPT)
162else
163 $(error Error: set INSTALL_PATH to use install)
164endif
165
Frederic Weisbecker274343a2012-01-12 17:20:44 -0800166clean:
Shuah Khan1ede0532017-09-18 17:30:50 -0600167 @for TARGET in $(TARGETS); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +0800168 BUILD_TARGET=$$BUILD/$$TARGET; \
169 make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
Frederic Weisbecker274343a2012-01-12 17:20:44 -0800170 done;
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100171
SeongJae Park584f34f2017-04-14 08:44:46 +0900172.PHONY: all run_tests hotplug run_hotplug clean_hotplug run_pstore_crash install clean