blob: 24b9934fb26958c6569e1e211d7be88bfe950b56 [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
Andrew Morton66a01b92013-02-27 17:05:56 -08009TARGETS += efivarfs
Andrew Morton96e869d2014-12-18 16:17:43 -080010TARGETS += exec
Christian Braunerce290a12018-03-13 17:55:27 +010011TARGETS += filesystems
Andrew Morton96e869d2014-12-18 16:17:43 -080012TARGETS += firmware
13TARGETS += ftrace
Darren Hartecac1a72015-05-12 21:07:55 -070014TARGETS += futex
Bamvor Jian Zhang22f65922016-11-21 18:16:11 +080015TARGETS += gpio
Stafford Horne63203032017-01-12 00:16:07 +090016TARGETS += intel_pstate
Bamvor Jian Zhang7e722472015-11-17 22:35:43 +080017TARGETS += ipc
Pavel Emelyanov58c7be82013-04-30 15:27:06 -070018TARGETS += kcmp
Paolo Bonzini783e9e52018-03-27 11:49:19 +020019TARGETS += kvm
Kees Cook317dc342015-11-06 16:30:32 -080020TARGETS += lib
Pranith Kumarb6d97342015-09-11 13:07:42 -070021TARGETS += membarrier
David Herrmann4f5ce5e2014-08-08 14:25:32 -070022TARGETS += memfd
Pavel Emelyanov58c7be82013-04-30 15:27:06 -070023TARGETS += memory-hotplug
Eric W. Biedermandb181ce2014-07-29 15:50:44 -070024TARGETS += mount
Andrew Morton96e869d2014-12-18 16:17:43 -080025TARGETS += mqueue
David S. Millera6f68032013-03-20 15:07:56 -040026TARGETS += net
Florian Westphal25d8bce2018-10-31 18:26:21 +010027TARGETS += netfilter
Willem de Bruijncda261f2018-12-20 16:22:54 -050028TARGETS += networking/timestamping
Andrey Vagin6ad92bf2016-09-06 00:47:16 -070029TARGETS += nsfs
Michael Ellerman0e56dac2013-08-06 17:42:35 +100030TARGETS += powerpc
Alexey Dobriyan9cd65652018-04-10 16:31:45 -070031TARGETS += proc
Hiraku Toyookacc04a462015-10-02 20:46:39 +090032TARGETS += pstore
Andrew Morton96e869d2014-12-18 16:17:43 -080033TARGETS += ptrace
Mathieu Desnoyersccba8b62018-06-02 08:44:08 -040034TARGETS += rseq
Alexandre Bellonia12ab9e2018-04-19 14:50:29 +020035TARGETS += rtc
Kees Cookc99ee512015-06-16 10:54:14 -070036TARGETS += seccomp
Stas Sergeev19fd2862016-04-14 23:20:05 +030037TARGETS += sigaltstack
Tim Bird3ce51052014-12-03 10:42:21 -080038TARGETS += size
Tom Hromatka3c545082018-04-26 10:54:09 -060039TARGETS += sparc64
Al Virob8826e52017-02-18 22:07:24 -050040TARGETS += splice
Bamvor Jian Zhang1087d012015-09-09 21:06:25 +080041TARGETS += static_keys
Emilio López822081602016-10-19 09:49:48 -030042TARGETS += sync
Andrew Morton96e869d2014-12-18 16:17:43 -080043TARGETS += sysctl
Shuah Khan2278e5e2015-06-19 13:13:43 -060044ifneq (1, $(quicktest))
Andrew Morton96e869d2014-12-18 16:17:43 -080045TARGETS += timers
Shuah Khan2278e5e2015-06-19 13:13:43 -060046endif
Andrew Morton96e869d2014-12-18 16:17:43 -080047TARGETS += user
48TARGETS += vm
Andy Lutomirski3f705df2015-04-06 23:11:06 -070049TARGETS += x86
Naresh Kambojuf21fb792015-08-18 12:31:59 +053050TARGETS += zram
Andrew Morton96e869d2014-12-18 16:17:43 -080051#Please keep the TARGETS list alphabetically sorted
Shuah Khan2278e5e2015-06-19 13:13:43 -060052# Run "make quicktest=1 run_tests" or
SeongJae Parkc6a13fa2017-04-14 08:43:16 +090053# "make quicktest=1 kselftest" from top level Makefile
Frederic Weisbecker274343a2012-01-12 17:20:44 -080054
Shuah Khanddddda92014-07-02 09:51:38 -060055TARGETS_HOTPLUG = cpu-hotplug
56TARGETS_HOTPLUG += memory-hotplug
57
Shuah Khan67d87122015-03-18 11:57:39 -060058# 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.
61ifeq (1,$(MAKELEVEL))
Arnaldo Carvalho de Melo60df4642015-05-14 16:55:18 -030062override LDFLAGS =
Shuah Khan67d87122015-03-18 11:57:39 -060063override MAKEFLAGS =
64endif
65
Shuah Khan52fd1d02017-09-07 19:57:43 -060066ifneq ($(KBUILD_SRC),)
67override LDFLAGS =
68endif
69
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +080070BUILD := $(O)
71ifndef BUILD
72 BUILD := $(KBUILD_OUTPUT)
73endif
74ifndef BUILD
75 BUILD := $(shell pwd)
76endif
77
Shuah Khan44f01352018-02-21 17:25:55 -070078# 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.
82export KSFT_TAP_LEVEL=`echo 1`
83
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +080084export BUILD
Frederic Weisbecker274343a2012-01-12 17:20:44 -080085all:
Shuah Khan1ede0532017-09-18 17:30:50 -060086 @for TARGET in $(TARGETS); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +080087 BUILD_TARGET=$$BUILD/$$TARGET; \
88 mkdir $$BUILD_TARGET -p; \
89 make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
Frederic Weisbecker274343a2012-01-12 17:20:44 -080090 done;
91
Andrew Mortoncab6b052012-03-28 14:42:54 -070092run_tests: all
Shuah Khan1ede0532017-09-18 17:30:50 -060093 @for TARGET in $(TARGETS); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +080094 BUILD_TARGET=$$BUILD/$$TARGET; \
95 make OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\
Frederic Weisbeckerf467f712012-03-28 14:42:54 -070096 done;
97
Shuah Khanddddda92014-07-02 09:51:38 -060098hotplug:
Shuah Khan1ede0532017-09-18 17:30:50 -060099 @for TARGET in $(TARGETS_HOTPLUG); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +0800100 BUILD_TARGET=$$BUILD/$$TARGET; \
101 make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
Shuah Khanddddda92014-07-02 09:51:38 -0600102 done;
103
104run_hotplug: hotplug
Shuah Khan1ede0532017-09-18 17:30:50 -0600105 @for TARGET in $(TARGETS_HOTPLUG); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +0800106 BUILD_TARGET=$$BUILD/$$TARGET; \
107 make OUTPUT=$$BUILD_TARGET -C $$TARGET run_full_test;\
Shuah Khanddddda92014-07-02 09:51:38 -0600108 done;
109
110clean_hotplug:
Shuah Khan1ede0532017-09-18 17:30:50 -0600111 @for TARGET in $(TARGETS_HOTPLUG); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +0800112 BUILD_TARGET=$$BUILD/$$TARGET; \
113 make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
Shuah Khanddddda92014-07-02 09:51:38 -0600114 done;
115
Hiraku Toyookaf615e2b2015-10-02 20:46:41 +0900116run_pstore_crash:
117 make -C pstore run_crash
118
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100119INSTALL_PATH ?= install
120INSTALL_PATH := $(abspath $(INSTALL_PATH))
121ALL_SCRIPT := $(INSTALL_PATH)/run_kselftest.sh
122
123install:
124ifdef INSTALL_PATH
125 @# Ask all targets to install their files
126 mkdir -p $(INSTALL_PATH)
Shuah Khan1ede0532017-09-18 17:30:50 -0600127 @for TARGET in $(TARGETS); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +0800128 BUILD_TARGET=$$BUILD/$$TARGET; \
129 make OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100130 done;
131
132 @# Ask all targets to emit their test scripts
Rolf Eike Beera2b1e8a2016-12-14 11:59:34 +0100133 echo "#!/bin/sh" > $(ALL_SCRIPT)
Michael Ellerman14f18892018-01-16 17:10:39 +1100134 echo "BASE_DIR=\$$(realpath \$$(dirname \$$0))" >> $(ALL_SCRIPT)
135 echo "cd \$$BASE_DIR" >> $(ALL_SCRIPT)
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100136 echo "ROOT=\$$PWD" >> $(ALL_SCRIPT)
Michael Ellerman14f18892018-01-16 17:10:39 +1100137 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)
Shuah Khan (Samsung OSG)3df61312018-05-01 12:15:34 -0600143 echo "export KSFT_TAP_LEVEL=1" >> $(ALL_SCRIPT)
144 echo "export skip=4" >> $(ALL_SCRIPT)
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100145
146 for TARGET in $(TARGETS); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +0800147 BUILD_TARGET=$$BUILD/$$TARGET; \
Shuah Khan44f01352018-02-21 17:25:55 -0700148 echo "echo ; echo TAP version 13" >> $(ALL_SCRIPT); \
149 echo "echo Running tests in $$TARGET" >> $(ALL_SCRIPT); \
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100150 echo "echo ========================================" >> $(ALL_SCRIPT); \
Michael Ellerman88893cf2018-03-23 20:44:27 +1100151 echo "[ -w /dev/kmsg ] && echo \"kselftest: Running tests in $$TARGET\" >> /dev/kmsg" >> $(ALL_SCRIPT); \
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100152 echo "cd $$TARGET" >> $(ALL_SCRIPT); \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +0800153 make -s --no-print-directory OUTPUT=$$BUILD_TARGET -C $$TARGET emit_tests >> $(ALL_SCRIPT); \
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100154 echo "cd \$$ROOT" >> $(ALL_SCRIPT); \
155 done;
156
157 chmod u+x $(ALL_SCRIPT)
158else
159 $(error Error: set INSTALL_PATH to use install)
160endif
161
Frederic Weisbecker274343a2012-01-12 17:20:44 -0800162clean:
Shuah Khan1ede0532017-09-18 17:30:50 -0600163 @for TARGET in $(TARGETS); do \
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +0800164 BUILD_TARGET=$$BUILD/$$TARGET; \
165 make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
Frederic Weisbecker274343a2012-01-12 17:20:44 -0800166 done;
Michael Ellerman32dcfba2015-03-11 15:06:00 +1100167
SeongJae Park584f34f2017-04-14 08:44:46 +0900168.PHONY: all run_tests hotplug run_hotplug clean_hotplug run_pstore_crash install clean