Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: Add install target

This adds make install support to selftests. The basic usage is:

$ cd tools/testing/selftests
$ make install

That installs into tools/testing/selftests/install, which can then be
copied where ever necessary.

The install destination is also configurable using eg:

$ INSTALL_PATH=/mnt/selftests make install

The implementation uses two targets in the child makefiles. The first
"install" is expected to install all files into $(INSTALL_PATH).

The second, "emit_tests", is expected to emit the test instructions (ie.
bash script) on stdout. Separating this from install means the child
makefiles need no knowledge of the location of the test script.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>

authored by

Michael Ellerman and committed by
Shuah Khan
32dcfba6 5e29a910

+73 -1
+33
tools/testing/selftests/Makefile
··· 47 47 make -C $$TARGET clean; \ 48 48 done; 49 49 50 + INSTALL_PATH ?= install 51 + INSTALL_PATH := $(abspath $(INSTALL_PATH)) 52 + ALL_SCRIPT := $(INSTALL_PATH)/run_kselftest.sh 53 + 54 + install: 55 + ifdef INSTALL_PATH 56 + @# Ask all targets to install their files 57 + mkdir -p $(INSTALL_PATH) 58 + for TARGET in $(TARGETS); do \ 59 + mkdir -p $(INSTALL_PATH)/$$TARGET ; \ 60 + make -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \ 61 + done; 62 + 63 + @# Ask all targets to emit their test scripts 64 + echo "#!/bin/bash" > $(ALL_SCRIPT) 65 + echo "cd \$$(dirname \$$0)" >> $(ALL_SCRIPT) 66 + echo "ROOT=\$$PWD" >> $(ALL_SCRIPT) 67 + 68 + for TARGET in $(TARGETS); do \ 69 + echo "echo ; echo Running tests in $$TARGET" >> $(ALL_SCRIPT); \ 70 + echo "echo ========================================" >> $(ALL_SCRIPT); \ 71 + echo "cd $$TARGET" >> $(ALL_SCRIPT); \ 72 + make -s --no-print-directory -C $$TARGET emit_tests >> $(ALL_SCRIPT); \ 73 + echo "cd \$$ROOT" >> $(ALL_SCRIPT); \ 74 + done; 75 + 76 + chmod u+x $(ALL_SCRIPT) 77 + else 78 + $(error Error: set INSTALL_PATH to use install) 79 + endif 80 + 50 81 clean: 51 82 for TARGET in $(TARGETS); do \ 52 83 make -C $$TARGET clean; \ 53 84 done; 85 + 86 + .PHONY: install
+1
tools/testing/selftests/efivarfs/Makefile
··· 6 6 all: $(test_objs) 7 7 8 8 TEST_PROGS := efivarfs.sh 9 + TEST_FILES := $(test_objs) 9 10 10 11 include ../lib.mk 11 12
+3
tools/testing/selftests/exec/Makefile
··· 19 19 $(CC) $(CFLAGS) -o $@ $^ 20 20 21 21 TEST_PROGS := execveat 22 + TEST_FILES := $(DEPS) 22 23 23 24 include ../lib.mk 25 + 26 + override EMIT_TESTS := echo "mkdir -p subdir; (./execveat && echo \"selftests: execveat [PASS]\") || echo \"selftests: execveat [FAIL]\"" 24 27 25 28 clean: 26 29 rm -rf $(BINARIES) $(DEPS) subdir.moved execveat.moved xxxxx*
+22 -1
tools/testing/selftests/lib.mk
··· 7 7 run_tests: all 8 8 $(RUN_TESTS) 9 9 10 - .PHONY: run_tests all clean 10 + define INSTALL_RULE 11 + mkdir -p $(INSTALL_PATH) 12 + install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_FILES) 13 + endef 14 + 15 + install: all 16 + ifdef INSTALL_PATH 17 + $(INSTALL_RULE) 18 + else 19 + $(error Error: set INSTALL_PATH to use install) 20 + endif 21 + 22 + define EMIT_TESTS 23 + @for TEST in $(TEST_PROGS); do \ 24 + echo "(./$$TEST && echo \"selftests: $$TEST [PASS]\") || echo \"selftests: $$TEST [FAIL]\""; \ 25 + done; 26 + endef 27 + 28 + emit_tests: 29 + $(EMIT_TESTS) 30 + 31 + .PHONY: run_tests all clean install emit_tests
+2
tools/testing/selftests/memory-hotplug/Makefile
··· 2 2 3 3 include ../lib.mk 4 4 5 + TEST_PROGS := on-off-test.sh 5 6 override RUN_TESTS := ./on-off-test.sh -r 2 || echo "selftests: memory-hotplug [FAIL]" 7 + override EMIT_TESTS := echo "$(RUN_TESTS)" 6 8 7 9 run_full_test: 8 10 @/bin/bash ./on-off-test.sh || echo "memory-hotplug selftests: [FAIL]"
+2
tools/testing/selftests/mount/Makefile
··· 7 7 8 8 include ../lib.mk 9 9 10 + TEST_PROGS := unprivileged-remount-test 10 11 override RUN_TESTS := if [ -f /proc/self/uid_map ] ; then ./unprivileged-remount-test ; fi 12 + override EMIT_TESTS := echo "$(RUN_TESTS)" 11 13 12 14 clean: 13 15 rm -f unprivileged-remount-test
+7
tools/testing/selftests/mqueue/Makefile
··· 9 9 @./mq_perf_tests || echo "selftests: mq_perf_tests [FAIL]" 10 10 endef 11 11 12 + TEST_PROGS := mq_open_tests mq_perf_tests 13 + 14 + override define EMIT_TESTS 15 + echo "./mq_open_tests /test1 || echo \"selftests: mq_open_tests [FAIL]\"" 16 + echo "./mq_perf_tests || echo \"selftests: mq_perf_tests [FAIL]\"" 17 + endef 18 + 12 19 clean: 13 20 rm -f mq_open_tests mq_perf_tests
+1
tools/testing/selftests/net/Makefile
··· 12 12 $(CC) $(CFLAGS) -o $@ $^ 13 13 14 14 TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh 15 + TEST_FILES := $(NET_PROGS) 15 16 16 17 include ../lib.mk 17 18
+1
tools/testing/selftests/sysctl/Makefile
··· 5 5 all: 6 6 7 7 TEST_PROGS := run_numerictests run_stringtests 8 + TEST_FILES := common_tests 8 9 9 10 include ../lib.mk 10 11
+1
tools/testing/selftests/vm/Makefile
··· 10 10 $(CC) $(CFLAGS) -o $@ $^ -lrt 11 11 12 12 TEST_PROGS := run_vmtests 13 + TEST_FILES := $(BINARIES) 13 14 14 15 include ../lib.mk 15 16