Home | History | Annotate | Download | only in selftests
      1 # SPDX-License-Identifier: GPL-2.0
      2 TARGETS = android
      3 TARGETS += bpf
      4 TARGETS += breakpoints
      5 TARGETS += capabilities
      6 TARGETS += cpufreq
      7 TARGETS += cpu-hotplug
      8 TARGETS += efivarfs
      9 TARGETS += exec
     10 TARGETS += firmware
     11 TARGETS += ftrace
     12 TARGETS += futex
     13 TARGETS += gpio
     14 TARGETS += intel_pstate
     15 TARGETS += ipc
     16 TARGETS += kcmp
     17 TARGETS += lib
     18 TARGETS += membarrier
     19 TARGETS += memfd
     20 TARGETS += memory-hotplug
     21 TARGETS += mount
     22 TARGETS += mqueue
     23 TARGETS += net
     24 TARGETS += nsfs
     25 TARGETS += powerpc
     26 TARGETS += pstore
     27 TARGETS += ptrace
     28 TARGETS += seccomp
     29 TARGETS += sigaltstack
     30 TARGETS += size
     31 TARGETS += splice
     32 TARGETS += static_keys
     33 TARGETS += sync
     34 TARGETS += sysctl
     35 ifneq (1, $(quicktest))
     36 TARGETS += timers
     37 endif
     38 TARGETS += user
     39 TARGETS += vm
     40 TARGETS += x86
     41 TARGETS += zram
     42 #Please keep the TARGETS list alphabetically sorted
     43 # Run "make quicktest=1 run_tests" or
     44 # "make quicktest=1 kselftest" from top level Makefile
     45 
     46 TARGETS_HOTPLUG = cpu-hotplug
     47 TARGETS_HOTPLUG += memory-hotplug
     48 
     49 # 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.
     52 ifeq (1,$(MAKELEVEL))
     53 override LDFLAGS =
     54 override MAKEFLAGS =
     55 endif
     56 
     57 ifneq ($(KBUILD_SRC),)
     58 override LDFLAGS =
     59 endif
     60 
     61 BUILD := $(O)
     62 ifndef BUILD
     63   BUILD := $(KBUILD_OUTPUT)
     64 endif
     65 ifndef BUILD
     66   BUILD := $(shell pwd)
     67 endif
     68 
     69 export BUILD
     70 all:
     71 	@for TARGET in $(TARGETS); do		\
     72 		BUILD_TARGET=$$BUILD/$$TARGET;	\
     73 		mkdir $$BUILD_TARGET  -p;	\
     74 		make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
     75 	done;
     76 
     77 run_tests: all
     78 	@for TARGET in $(TARGETS); do \
     79 		BUILD_TARGET=$$BUILD/$$TARGET;	\
     80 		make OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\
     81 	done;
     82 
     83 hotplug:
     84 	@for TARGET in $(TARGETS_HOTPLUG); do \
     85 		BUILD_TARGET=$$BUILD/$$TARGET;	\
     86 		make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
     87 	done;
     88 
     89 run_hotplug: hotplug
     90 	@for TARGET in $(TARGETS_HOTPLUG); do \
     91 		BUILD_TARGET=$$BUILD/$$TARGET;	\
     92 		make OUTPUT=$$BUILD_TARGET -C $$TARGET run_full_test;\
     93 	done;
     94 
     95 clean_hotplug:
     96 	@for TARGET in $(TARGETS_HOTPLUG); do \
     97 		BUILD_TARGET=$$BUILD/$$TARGET;	\
     98 		make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
     99 	done;
    100 
    101 run_pstore_crash:
    102 	make -C pstore run_crash
    103 
    104 INSTALL_PATH ?= install
    105 INSTALL_PATH := $(abspath $(INSTALL_PATH))
    106 ALL_SCRIPT := $(INSTALL_PATH)/run_kselftest.sh
    107 
    108 install:
    109 ifdef INSTALL_PATH
    110 	@# Ask all targets to install their files
    111 	mkdir -p $(INSTALL_PATH)
    112 	@for TARGET in $(TARGETS); do \
    113 		BUILD_TARGET=$$BUILD/$$TARGET;	\
    114 		make OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
    115 	done;
    116 
    117 	@# Ask all targets to emit their test scripts
    118 	echo "#!/bin/sh" > $(ALL_SCRIPT)
    119 	echo "cd \$$(dirname \$$0)" >> $(ALL_SCRIPT)
    120 	echo "ROOT=\$$PWD" >> $(ALL_SCRIPT)
    121 
    122 	for TARGET in $(TARGETS); do \
    123 		BUILD_TARGET=$$BUILD/$$TARGET;	\
    124 		echo "echo ; echo Running tests in $$TARGET" >> $(ALL_SCRIPT); \
    125 		echo "echo ========================================" >> $(ALL_SCRIPT); \
    126 		echo "cd $$TARGET" >> $(ALL_SCRIPT); \
    127 		make -s --no-print-directory OUTPUT=$$BUILD_TARGET -C $$TARGET emit_tests >> $(ALL_SCRIPT); \
    128 		echo "cd \$$ROOT" >> $(ALL_SCRIPT); \
    129 	done;
    130 
    131 	chmod u+x $(ALL_SCRIPT)
    132 else
    133 	$(error Error: set INSTALL_PATH to use install)
    134 endif
    135 
    136 clean:
    137 	@for TARGET in $(TARGETS); do \
    138 		BUILD_TARGET=$$BUILD/$$TARGET;	\
    139 		make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
    140 	done;
    141 
    142 .PHONY: all run_tests hotplug run_hotplug clean_hotplug run_pstore_crash install clean
    143