aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests
diff options
context:
space:
mode:
authorMichael Ellerman <mpe@ellerman.id.au>2015-03-11 00:06:00 -0400
committerShuah Khan <shuahkh@osg.samsung.com>2015-03-13 17:21:56 -0400
commit32dcfba6f8df667e4b915e0542b33ccbc8e76fa8 (patch)
treeb7e9728ba9a2e7ba625bf37b374b56762bc082b0 /tools/testing/selftests
parent5e29a9105b1a0da86eff0ad6ae015997b49d4d1d (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/Makefile33
-rw-r--r--tools/testing/selftests/efivarfs/Makefile1
-rw-r--r--tools/testing/selftests/exec/Makefile3
-rw-r--r--tools/testing/selftests/lib.mk23
-rw-r--r--tools/testing/selftests/memory-hotplug/Makefile2
-rw-r--r--tools/testing/selftests/mount/Makefile2
-rw-r--r--tools/testing/selftests/mqueue/Makefile7
-rw-r--r--tools/testing/selftests/net/Makefile1
-rw-r--r--tools/testing/selftests/sysctl/Makefile1
-rw-r--r--tools/testing/selftests/vm/Makefile1
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
50INSTALL_PATH ?= install
51INSTALL_PATH := $(abspath $(INSTALL_PATH))
52ALL_SCRIPT := $(INSTALL_PATH)/run_kselftest.sh
53
54install:
55ifdef 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)
77else
78 $(error Error: set INSTALL_PATH to use install)
79endif
80
50clean: 81clean:
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
6all: $(test_objs) 6all: $(test_objs)
7 7
8TEST_PROGS := efivarfs.sh 8TEST_PROGS := efivarfs.sh
9TEST_FILES := $(test_objs)
9 10
10include ../lib.mk 11include ../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
21TEST_PROGS := execveat 21TEST_PROGS := execveat
22TEST_FILES := $(DEPS)
22 23
23include ../lib.mk 24include ../lib.mk
24 25
26override EMIT_TESTS := echo "mkdir -p subdir; (./execveat && echo \"selftests: execveat [PASS]\") || echo \"selftests: execveat [FAIL]\""
27
25clean: 28clean:
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
7run_tests: all 7run_tests: all
8 $(RUN_TESTS) 8 $(RUN_TESTS)
9 9
10.PHONY: run_tests all clean 10define INSTALL_RULE
11 mkdir -p $(INSTALL_PATH)
12 install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_FILES)
13endef
14
15install: all
16ifdef INSTALL_PATH
17 $(INSTALL_RULE)
18else
19 $(error Error: set INSTALL_PATH to use install)
20endif
21
22define EMIT_TESTS
23 @for TEST in $(TEST_PROGS); do \
24 echo "(./$$TEST && echo \"selftests: $$TEST [PASS]\") || echo \"selftests: $$TEST [FAIL]\""; \
25 done;
26endef
27
28emit_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
3include ../lib.mk 3include ../lib.mk
4 4
5TEST_PROGS := on-off-test.sh
5override RUN_TESTS := ./on-off-test.sh -r 2 || echo "selftests: memory-hotplug [FAIL]" 6override RUN_TESTS := ./on-off-test.sh -r 2 || echo "selftests: memory-hotplug [FAIL]"
7override EMIT_TESTS := echo "$(RUN_TESTS)"
6 8
7run_full_test: 9run_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
8include ../lib.mk 8include ../lib.mk
9 9
10TEST_PROGS := unprivileged-remount-test
10override RUN_TESTS := if [ -f /proc/self/uid_map ] ; then ./unprivileged-remount-test ; fi 11override RUN_TESTS := if [ -f /proc/self/uid_map ] ; then ./unprivileged-remount-test ; fi
12override EMIT_TESTS := echo "$(RUN_TESTS)"
11 13
12clean: 14clean:
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]"
10endef 10endef
11 11
12TEST_PROGS := mq_open_tests mq_perf_tests
13
14override 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]\""
17endef
18
12clean: 19clean:
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
14TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh 14TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh
15TEST_FILES := $(NET_PROGS)
15 16
16include ../lib.mk 17include ../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 @@
5all: 5all:
6 6
7TEST_PROGS := run_numerictests run_stringtests 7TEST_PROGS := run_numerictests run_stringtests
8TEST_FILES := common_tests
8 9
9include ../lib.mk 10include ../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
12TEST_PROGS := run_vmtests 12TEST_PROGS := run_vmtests
13TEST_FILES := $(BINARIES)
13 14
14include ../lib.mk 15include ../lib.mk
15 16