1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0 247a18c42SPintu AgarwalTARGETS = android 347a18c42SPintu AgarwalTARGETS += bpf 45aa5bd14SDaniel BorkmannTARGETS += breakpoints 5f4ecb322SBamvor Jian ZhangTARGETS += capabilities 684092dbcSRoman GushchinTARGETS += cgroup 7e66d5b67SViresh KumarTARGETS += cpufreq 866a01b96SAndrew MortonTARGETS += cpu-hotplug 96edf2e37STom MurphyTARGETS += drivers/dma-buf 1066a01b96SAndrew MortonTARGETS += efivarfs 1196e869d8SAndrew MortonTARGETS += exec 12ce290a19SChristian BraunerTARGETS += filesystems 1375abec73SChristian BraunerTARGETS += filesystems/binderfs 1496e869d8SAndrew MortonTARGETS += firmware 1596e869d8SAndrew MortonTARGETS += ftrace 16ecac1a75SDarren HartTARGETS += futex 1722f6592bSBamvor Jian ZhangTARGETS += gpio 186320303fSStafford HorneTARGETS += intel_pstate 197e722473SBamvor Jian ZhangTARGETS += ipc 20e55c884eSSean YoungTARGETS += ir 2158c7be84SPavel EmelyanovTARGETS += kcmp 22c3c0e811SMimi ZoharTARGETS += kexec 23783e9e51SPaolo BonziniTARGETS += kvm 24317dc34aSKees CookTARGETS += lib 25a2818ee4SJoe LawrenceTARGETS += livepatch 26b6d97344SPranith KumarTARGETS += membarrier 274f5ce5e8SDavid HerrmannTARGETS += memfd 2858c7be84SPavel EmelyanovTARGETS += memory-hotplug 29db181ce0SEric W. BiedermanTARGETS += mount 3096e869d8SAndrew MortonTARGETS += mqueue 31a6f68034SDavid S. MillerTARGETS += net 3225d8bcedSFlorian WestphalTARGETS += netfilter 33cda261f4SWillem de BruijnTARGETS += networking/timestamping 346ad92bf6SAndrey VaginTARGETS += nsfs 35575a0ae9SChristian BraunerTARGETS += pidfd 360e56dacdSMichael EllermanTARGETS += powerpc 379cd65655SAlexey DobriyanTARGETS += proc 38cc04a46fSHiraku ToyookaTARGETS += pstore 3996e869d8SAndrew MortonTARGETS += ptrace 40ccba8b64SMathieu DesnoyersTARGETS += rseq 41a12ab9e1SAlexandre BelloniTARGETS += rtc 42c99ee51aSKees CookTARGETS += seccomp 4319fd2868SStas SergeevTARGETS += sigaltstack 443ce51050STim BirdTARGETS += size 453c545084STom HromatkaTARGETS += sparc64 46b8826e50SAl ViroTARGETS += splice 471087d019SBamvor Jian ZhangTARGETS += static_keys 4882208160SEmilio LópezTARGETS += sync 4996e869d8SAndrew MortonTARGETS += sysctl 502278e5edSShuah Khanifneq (1, $(quicktest)) 5196e869d8SAndrew MortonTARGETS += timers 522278e5edSShuah Khanendif 53a3322868SAlexey DobriyanTARGETS += tmpfs 546ea3dfe1SJarkko SakkinenTARGETS += tpm2 5596e869d8SAndrew MortonTARGETS += user 5696e869d8SAndrew MortonTARGETS += vm 573f705dfdSAndy LutomirskiTARGETS += x86 58f21fb798SNaresh KambojuTARGETS += zram 5996e869d8SAndrew Morton#Please keep the TARGETS list alphabetically sorted 602278e5edSShuah Khan# Run "make quicktest=1 run_tests" or 61c6a13fafSSeongJae Park# "make quicktest=1 kselftest" from top level Makefile 62274343adSFrederic Weisbecker 63ddddda9bSShuah KhanTARGETS_HOTPLUG = cpu-hotplug 64ddddda9bSShuah KhanTARGETS_HOTPLUG += memory-hotplug 65ddddda9bSShuah Khan 6667d8712dSShuah Khan# Clear LDFLAGS and MAKEFLAGS if called from main 6767d8712dSShuah Khan# Makefile to avoid test build failures when test 6867d8712dSShuah Khan# Makefile doesn't have explicit build rules. 6967d8712dSShuah Khanifeq (1,$(MAKELEVEL)) 7060df4642SArnaldo Carvalho de Melooverride LDFLAGS = 7167d8712dSShuah Khanoverride MAKEFLAGS = 7267d8712dSShuah Khanendif 7367d8712dSShuah Khan 7452fd1d08SShuah Khanifneq ($(KBUILD_SRC),) 7552fd1d08SShuah Khanoverride LDFLAGS = 7652fd1d08SShuah Khanendif 7752fd1d08SShuah Khan 788ce72dc3SShuah Khanifneq ($(O),) 79a8ba798bSbamvor.zhangjian@huawei.com BUILD := $(O) 808ce72dc3SShuah Khanelse 818ce72dc3SShuah Khan ifneq ($(KBUILD_OUTPUT),) 82a8ba798bSbamvor.zhangjian@huawei.com BUILD := $(KBUILD_OUTPUT) 838ce72dc3SShuah Khan else 84a8ba798bSbamvor.zhangjian@huawei.com BUILD := $(shell pwd) 858ce72dc3SShuah Khan DEFAULT_INSTALL_HDR_PATH := 1 868ce72dc3SShuah Khan endif 87a8ba798bSbamvor.zhangjian@huawei.comendif 88a8ba798bSbamvor.zhangjian@huawei.com 8944f01352SShuah Khan# KSFT_TAP_LEVEL is used from KSFT framework to prevent nested TAP header 9044f01352SShuah Khan# printing from tests. Applicable to run_tests case where run_tests adds 9144f01352SShuah Khan# TAP header prior running tests and when a test program invokes another 9244f01352SShuah Khan# with system() call. Export it here to cover override RUN_TESTS defines. 9344f01352SShuah Khanexport KSFT_TAP_LEVEL=`echo 1` 9444f01352SShuah Khan 958ce72dc3SShuah Khan# Prepare for headers install 968ce72dc3SShuah Khantop_srcdir ?= ../../.. 978ce72dc3SShuah Khaninclude $(top_srcdir)/scripts/subarch.include 988ce72dc3SShuah KhanARCH ?= $(SUBARCH) 998ce72dc3SShuah Khanexport KSFT_KHDR_INSTALL_DONE := 1 100a8ba798bSbamvor.zhangjian@huawei.comexport BUILD 1018ce72dc3SShuah Khan 102d917fb87SShuah Khan# build and run gpio when output directory is the src dir. 103d917fb87SShuah Khan# gpio has dependency on tools/gpio and builds tools/gpio 104d917fb87SShuah Khan# objects in the src directory in all cases making the src 105d917fb87SShuah Khan# repo dirty even when objects are relocated. 106d917fb87SShuah Khanifneq (1,$(DEFAULT_INSTALL_HDR_PATH)) 107d917fb87SShuah Khan TMP := $(filter-out gpio, $(TARGETS)) 108d917fb87SShuah Khan TARGETS := $(TMP) 109d917fb87SShuah Khanendif 110d917fb87SShuah Khan 1118ce72dc3SShuah Khan# set default goal to all, so make without a target runs all, even when 1128ce72dc3SShuah Khan# all isn't the first target in the file. 1138ce72dc3SShuah Khan.DEFAULT_GOAL := all 1148ce72dc3SShuah Khan 1158ce72dc3SShuah Khan# Install headers here once for all tests. KSFT_KHDR_INSTALL_DONE 1168ce72dc3SShuah Khan# is used to avoid running headers_install from lib.mk. 1178ce72dc3SShuah Khan# Invoke headers install with --no-builtin-rules to avoid circular 1188ce72dc3SShuah Khan# dependency in "make kselftest" case. In this case, second level 1198ce72dc3SShuah Khan# make inherits builtin-rules which will use the rule generate 1208ce72dc3SShuah Khan# Makefile.o and runs into 1218ce72dc3SShuah Khan# "Circular Makefile.o <- prepare dependency dropped." 1228ce72dc3SShuah Khan# and headers_install fails and test compile fails. 1238ce72dc3SShuah Khan# 1248ce72dc3SShuah Khan# O= KBUILD_OUTPUT cases don't run into this error, since main Makefile 1258ce72dc3SShuah Khan# invokes them as sub-makes and --no-builtin-rules is not necessary, 1268ce72dc3SShuah Khan# but doesn't cause any failures. Keep it simple and use the same 1278ce72dc3SShuah Khan# flags in both cases. 1288ce72dc3SShuah Khan# Local build cases: "make kselftest", "make -C" - headers are installed 1298ce72dc3SShuah Khan# in the default INSTALL_HDR_PATH usr/include. 1308ce72dc3SShuah Khankhdr: 1318ce72dc3SShuah Khanifeq (1,$(DEFAULT_INSTALL_HDR_PATH)) 1328ce72dc3SShuah Khan make --no-builtin-rules ARCH=$(ARCH) -C $(top_srcdir) headers_install 1338ce72dc3SShuah Khanelse 1348ce72dc3SShuah Khan make --no-builtin-rules INSTALL_HDR_PATH=$$BUILD/usr \ 1358ce72dc3SShuah Khan ARCH=$(ARCH) -C $(top_srcdir) headers_install 1368ce72dc3SShuah Khanendif 1378ce72dc3SShuah Khan 1388ce72dc3SShuah Khanall: khdr 1391ede0536SShuah Khan @for TARGET in $(TARGETS); do \ 140a8ba798bSbamvor.zhangjian@huawei.com BUILD_TARGET=$$BUILD/$$TARGET; \ 141a8ba798bSbamvor.zhangjian@huawei.com mkdir $$BUILD_TARGET -p; \ 142a8ba798bSbamvor.zhangjian@huawei.com make OUTPUT=$$BUILD_TARGET -C $$TARGET;\ 143274343adSFrederic Weisbecker done; 144274343adSFrederic Weisbecker 145cab6b056SAndrew Mortonrun_tests: all 1461ede0536SShuah Khan @for TARGET in $(TARGETS); do \ 147a8ba798bSbamvor.zhangjian@huawei.com BUILD_TARGET=$$BUILD/$$TARGET; \ 148a8ba798bSbamvor.zhangjian@huawei.com make OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\ 149f467f714SFrederic Weisbecker done; 150f467f714SFrederic Weisbecker 151ddddda9bSShuah Khanhotplug: 1521ede0536SShuah Khan @for TARGET in $(TARGETS_HOTPLUG); do \ 153a8ba798bSbamvor.zhangjian@huawei.com BUILD_TARGET=$$BUILD/$$TARGET; \ 154a8ba798bSbamvor.zhangjian@huawei.com make OUTPUT=$$BUILD_TARGET -C $$TARGET;\ 155ddddda9bSShuah Khan done; 156ddddda9bSShuah Khan 157ddddda9bSShuah Khanrun_hotplug: hotplug 1581ede0536SShuah Khan @for TARGET in $(TARGETS_HOTPLUG); do \ 159a8ba798bSbamvor.zhangjian@huawei.com BUILD_TARGET=$$BUILD/$$TARGET; \ 160a8ba798bSbamvor.zhangjian@huawei.com make OUTPUT=$$BUILD_TARGET -C $$TARGET run_full_test;\ 161ddddda9bSShuah Khan done; 162ddddda9bSShuah Khan 163ddddda9bSShuah Khanclean_hotplug: 1641ede0536SShuah Khan @for TARGET in $(TARGETS_HOTPLUG); do \ 165a8ba798bSbamvor.zhangjian@huawei.com BUILD_TARGET=$$BUILD/$$TARGET; \ 166a8ba798bSbamvor.zhangjian@huawei.com make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\ 167ddddda9bSShuah Khan done; 168ddddda9bSShuah Khan 169f615e2bbSHiraku Toyookarun_pstore_crash: 170f615e2bbSHiraku Toyooka make -C pstore run_crash 171f615e2bbSHiraku Toyooka 17232dcfba6SMichael EllermanINSTALL_PATH ?= install 17332dcfba6SMichael EllermanINSTALL_PATH := $(abspath $(INSTALL_PATH)) 17432dcfba6SMichael EllermanALL_SCRIPT := $(INSTALL_PATH)/run_kselftest.sh 17532dcfba6SMichael Ellerman 17632dcfba6SMichael Ellermaninstall: 17732dcfba6SMichael Ellermanifdef INSTALL_PATH 17832dcfba6SMichael Ellerman @# Ask all targets to install their files 179d4e59a53SKees Cook mkdir -p $(INSTALL_PATH)/kselftest 180d4e59a53SKees Cook install -m 744 kselftest/runner.sh $(INSTALL_PATH)/kselftest/ 181*5c069b6dSKees Cook install -m 744 kselftest/prefix.pl $(INSTALL_PATH)/kselftest/ 1821ede0536SShuah Khan @for TARGET in $(TARGETS); do \ 183a8ba798bSbamvor.zhangjian@huawei.com BUILD_TARGET=$$BUILD/$$TARGET; \ 184a8ba798bSbamvor.zhangjian@huawei.com make OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \ 18532dcfba6SMichael Ellerman done; 18632dcfba6SMichael Ellerman 18732dcfba6SMichael Ellerman @# Ask all targets to emit their test scripts 188a2b1e8a2SRolf Eike Beer echo "#!/bin/sh" > $(ALL_SCRIPT) 18914f1889fSMichael Ellerman echo "BASE_DIR=\$$(realpath \$$(dirname \$$0))" >> $(ALL_SCRIPT) 19014f1889fSMichael Ellerman echo "cd \$$BASE_DIR" >> $(ALL_SCRIPT) 191d4e59a53SKees Cook echo ". ./kselftest/runner.sh" >> $(ALL_SCRIPT) 19232dcfba6SMichael Ellerman echo "ROOT=\$$PWD" >> $(ALL_SCRIPT) 19314f1889fSMichael Ellerman echo "if [ \"\$$1\" = \"--summary\" ]; then" >> $(ALL_SCRIPT) 194d4e59a53SKees Cook echo " logfile=\$$BASE_DIR/output.log" >> $(ALL_SCRIPT) 195d4e59a53SKees Cook echo " cat /dev/null > \$$logfile" >> $(ALL_SCRIPT) 19614f1889fSMichael Ellerman echo "fi" >> $(ALL_SCRIPT) 19732dcfba6SMichael Ellerman 19832dcfba6SMichael Ellerman for TARGET in $(TARGETS); do \ 199a8ba798bSbamvor.zhangjian@huawei.com BUILD_TARGET=$$BUILD/$$TARGET; \ 20088893cf7SMichael Ellerman echo "[ -w /dev/kmsg ] && echo \"kselftest: Running tests in $$TARGET\" >> /dev/kmsg" >> $(ALL_SCRIPT); \ 20132dcfba6SMichael Ellerman echo "cd $$TARGET" >> $(ALL_SCRIPT); \ 202bf660782SKees Cook echo -n "run_many" >> $(ALL_SCRIPT); \ 203a8ba798bSbamvor.zhangjian@huawei.com make -s --no-print-directory OUTPUT=$$BUILD_TARGET -C $$TARGET emit_tests >> $(ALL_SCRIPT); \ 204bf660782SKees Cook echo "" >> $(ALL_SCRIPT); \ 20532dcfba6SMichael Ellerman echo "cd \$$ROOT" >> $(ALL_SCRIPT); \ 20632dcfba6SMichael Ellerman done; 20732dcfba6SMichael Ellerman 20832dcfba6SMichael Ellerman chmod u+x $(ALL_SCRIPT) 20932dcfba6SMichael Ellermanelse 21032dcfba6SMichael Ellerman $(error Error: set INSTALL_PATH to use install) 21132dcfba6SMichael Ellermanendif 21232dcfba6SMichael Ellerman 213274343adSFrederic Weisbeckerclean: 2141ede0536SShuah Khan @for TARGET in $(TARGETS); do \ 215a8ba798bSbamvor.zhangjian@huawei.com BUILD_TARGET=$$BUILD/$$TARGET; \ 216a8ba798bSbamvor.zhangjian@huawei.com make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\ 217274343adSFrederic Weisbecker done; 21832dcfba6SMichael Ellerman 2198ce72dc3SShuah Khan.PHONY: khdr all run_tests hotplug run_hotplug clean_hotplug run_pstore_crash install clean 220