diff options
author | Michael Ellerman <mpe@ellerman.id.au> | 2015-03-11 00:06:00 -0400 |
---|---|---|
committer | Shuah Khan <shuahkh@osg.samsung.com> | 2015-03-13 17:21:56 -0400 |
commit | 32dcfba6f8df667e4b915e0542b33ccbc8e76fa8 (patch) | |
tree | b7e9728ba9a2e7ba625bf37b374b56762bc082b0 /tools/testing/selftests | |
parent | 5e29a9105b1a0da86eff0ad6ae015997b49d4d1d (diff) |
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>
Diffstat (limited to 'tools/testing/selftests')
-rw-r--r-- | tools/testing/selftests/Makefile | 33 | ||||
-rw-r--r-- | tools/testing/selftests/efivarfs/Makefile | 1 | ||||
-rw-r--r-- | tools/testing/selftests/exec/Makefile | 3 | ||||
-rw-r--r-- | tools/testing/selftests/lib.mk | 23 | ||||
-rw-r--r-- | tools/testing/selftests/memory-hotplug/Makefile | 2 | ||||
-rw-r--r-- | tools/testing/selftests/mount/Makefile | 2 | ||||
-rw-r--r-- | tools/testing/selftests/mqueue/Makefile | 7 | ||||
-rw-r--r-- | tools/testing/selftests/net/Makefile | 1 | ||||
-rw-r--r-- | tools/testing/selftests/sysctl/Makefile | 1 | ||||
-rw-r--r-- | tools/testing/selftests/vm/Makefile | 1 |
10 files changed, 73 insertions, 1 deletions
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index 4e511221a0c1..9af1df28bb26 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile | |||
@@ -47,7 +47,40 @@ clean_hotplug: | |||
47 | make -C $$TARGET clean; \ | 47 | make -C $$TARGET clean; \ |
48 | done; | 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 | clean: | 81 | clean: |
51 | for TARGET in $(TARGETS); do \ | 82 | for TARGET in $(TARGETS); do \ |
52 | make -C $$TARGET clean; \ | 83 | make -C $$TARGET clean; \ |
53 | done; | 84 | done; |
85 | |||
86 | .PHONY: install | ||
diff --git a/tools/testing/selftests/efivarfs/Makefile b/tools/testing/selftests/efivarfs/Makefile index 3052d0bda24b..9ff04f154bd5 100644 --- a/tools/testing/selftests/efivarfs/Makefile +++ b/tools/testing/selftests/efivarfs/Makefile | |||
@@ -6,6 +6,7 @@ test_objs = open-unlink create-read | |||
6 | all: $(test_objs) | 6 | all: $(test_objs) |
7 | 7 | ||
8 | TEST_PROGS := efivarfs.sh | 8 | TEST_PROGS := efivarfs.sh |
9 | TEST_FILES := $(test_objs) | ||
9 | 10 | ||
10 | include ../lib.mk | 11 | include ../lib.mk |
11 | 12 | ||
diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftests/exec/Makefile index a0098daeb73d..886cabe307b1 100644 --- a/tools/testing/selftests/exec/Makefile +++ b/tools/testing/selftests/exec/Makefile | |||
@@ -19,8 +19,11 @@ execveat.denatured: execveat | |||
19 | $(CC) $(CFLAGS) -o $@ $^ | 19 | $(CC) $(CFLAGS) -o $@ $^ |
20 | 20 | ||
21 | TEST_PROGS := execveat | 21 | TEST_PROGS := execveat |
22 | TEST_FILES := $(DEPS) | ||
22 | 23 | ||
23 | include ../lib.mk | 24 | include ../lib.mk |
24 | 25 | ||
26 | override EMIT_TESTS := echo "mkdir -p subdir; (./execveat && echo \"selftests: execveat [PASS]\") || echo \"selftests: execveat [FAIL]\"" | ||
27 | |||
25 | clean: | 28 | clean: |
26 | rm -rf $(BINARIES) $(DEPS) subdir.moved execveat.moved xxxxx* | 29 | rm -rf $(BINARIES) $(DEPS) subdir.moved execveat.moved xxxxx* |
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk index b30c5a49cb61..7bd3dabe2846 100644 --- a/tools/testing/selftests/lib.mk +++ b/tools/testing/selftests/lib.mk | |||
@@ -7,4 +7,25 @@ endef | |||
7 | run_tests: all | 7 | run_tests: all |
8 | $(RUN_TESTS) | 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 | ||
diff --git a/tools/testing/selftests/memory-hotplug/Makefile b/tools/testing/selftests/memory-hotplug/Makefile index 8f7dea66ecac..598a1f68f534 100644 --- a/tools/testing/selftests/memory-hotplug/Makefile +++ b/tools/testing/selftests/memory-hotplug/Makefile | |||
@@ -2,7 +2,9 @@ all: | |||
2 | 2 | ||
3 | include ../lib.mk | 3 | include ../lib.mk |
4 | 4 | ||
5 | TEST_PROGS := on-off-test.sh | ||
5 | override RUN_TESTS := ./on-off-test.sh -r 2 || echo "selftests: memory-hotplug [FAIL]" | 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 | run_full_test: | 9 | run_full_test: |
8 | @/bin/bash ./on-off-test.sh || echo "memory-hotplug selftests: [FAIL]" | 10 | @/bin/bash ./on-off-test.sh || echo "memory-hotplug selftests: [FAIL]" |
diff --git a/tools/testing/selftests/mount/Makefile b/tools/testing/selftests/mount/Makefile index 06931dfd3ef0..a5b367f032ba 100644 --- a/tools/testing/selftests/mount/Makefile +++ b/tools/testing/selftests/mount/Makefile | |||
@@ -7,7 +7,9 @@ unprivileged-remount-test: unprivileged-remount-test.c | |||
7 | 7 | ||
8 | include ../lib.mk | 8 | include ../lib.mk |
9 | 9 | ||
10 | TEST_PROGS := unprivileged-remount-test | ||
10 | override RUN_TESTS := if [ -f /proc/self/uid_map ] ; then ./unprivileged-remount-test ; fi | 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 | clean: | 14 | clean: |
13 | rm -f unprivileged-remount-test | 15 | rm -f unprivileged-remount-test |
diff --git a/tools/testing/selftests/mqueue/Makefile b/tools/testing/selftests/mqueue/Makefile index cbc300ef11bf..6ca7261b55dc 100644 --- a/tools/testing/selftests/mqueue/Makefile +++ b/tools/testing/selftests/mqueue/Makefile | |||
@@ -9,5 +9,12 @@ override define RUN_TESTS | |||
9 | @./mq_perf_tests || echo "selftests: mq_perf_tests [FAIL]" | 9 | @./mq_perf_tests || echo "selftests: mq_perf_tests [FAIL]" |
10 | endef | 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 | clean: | 19 | clean: |
13 | rm -f mq_open_tests mq_perf_tests | 20 | rm -f mq_open_tests mq_perf_tests |
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile index fa8187ff15e6..6ba2ac7bbb0d 100644 --- a/tools/testing/selftests/net/Makefile +++ b/tools/testing/selftests/net/Makefile | |||
@@ -12,6 +12,7 @@ all: $(NET_PROGS) | |||
12 | $(CC) $(CFLAGS) -o $@ $^ | 12 | $(CC) $(CFLAGS) -o $@ $^ |
13 | 13 | ||
14 | TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh | 14 | TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh |
15 | TEST_FILES := $(NET_PROGS) | ||
15 | 16 | ||
16 | include ../lib.mk | 17 | include ../lib.mk |
17 | 18 | ||
diff --git a/tools/testing/selftests/sysctl/Makefile b/tools/testing/selftests/sysctl/Makefile index c9660f5ef9f9..b3c33e071f10 100644 --- a/tools/testing/selftests/sysctl/Makefile +++ b/tools/testing/selftests/sysctl/Makefile | |||
@@ -5,6 +5,7 @@ | |||
5 | all: | 5 | all: |
6 | 6 | ||
7 | TEST_PROGS := run_numerictests run_stringtests | 7 | TEST_PROGS := run_numerictests run_stringtests |
8 | TEST_FILES := common_tests | ||
8 | 9 | ||
9 | include ../lib.mk | 10 | include ../lib.mk |
10 | 11 | ||
diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile index 90e56090b0ed..1a49761df6ed 100644 --- a/tools/testing/selftests/vm/Makefile +++ b/tools/testing/selftests/vm/Makefile | |||
@@ -10,6 +10,7 @@ all: $(BINARIES) | |||
10 | $(CC) $(CFLAGS) -o $@ $^ -lrt | 10 | $(CC) $(CFLAGS) -o $@ $^ -lrt |
11 | 11 | ||
12 | TEST_PROGS := run_vmtests | 12 | TEST_PROGS := run_vmtests |
13 | TEST_FILES := $(BINARIES) | ||
13 | 14 | ||
14 | include ../lib.mk | 15 | include ../lib.mk |
15 | 16 | ||