diff options
author | Michael Ellerman <mpe@ellerman.id.au> | 2015-03-11 00:05:59 -0400 |
---|---|---|
committer | Shuah Khan <shuahkh@osg.samsung.com> | 2015-03-13 17:13:40 -0400 |
commit | 5e29a9105b1a0da86eff0ad6ae015997b49d4d1d (patch) | |
tree | 8c913c799dc3d6251efec0e681ef738ec38a3f4e | |
parent | 7fe5f1c16c2c7904c7b8fcfb93e691893f21e8d3 (diff) |
selftests: Introduce minimal shared logic for running tests
This adds a Make include file which most selftests can then include to
get the run_tests logic.
On its own this has the advantage of some reduction in repetition, and
also means the pass/fail message is defined in fewer places.
However the key advantage is it will allow us to implement install very
simply in a subsequent patch.
The default implementation just executes each program in $(TEST_PROGS).
We use a variable to hold the default implementation of $(RUN_TESTS)
because that gives us a clean way to override it if necessary, ie. using
override. The mount, memory-hotplug and mqueue tests use that to provide
a different implementation.
Tests are not run via /bin/bash, so if they are scripts they must be
executable, we add a+x to several.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
29 files changed, 65 insertions, 67 deletions
diff --git a/tools/testing/selftests/breakpoints/Makefile b/tools/testing/selftests/breakpoints/Makefile index e18b42b254af..182235640209 100644 --- a/tools/testing/selftests/breakpoints/Makefile +++ b/tools/testing/selftests/breakpoints/Makefile | |||
@@ -16,8 +16,9 @@ else | |||
16 | echo "Not an x86 target, can't build breakpoints selftests" | 16 | echo "Not an x86 target, can't build breakpoints selftests" |
17 | endif | 17 | endif |
18 | 18 | ||
19 | run_tests: | 19 | TEST_PROGS := breakpoint_test |
20 | @./breakpoint_test || echo "breakpoints selftests: [FAIL]" | 20 | |
21 | include ../lib.mk | ||
21 | 22 | ||
22 | clean: | 23 | clean: |
23 | rm -fr breakpoint_test | 24 | rm -fr breakpoint_test |
diff --git a/tools/testing/selftests/cpu-hotplug/Makefile b/tools/testing/selftests/cpu-hotplug/Makefile index e9c28d8dc84b..15f02591d22c 100644 --- a/tools/testing/selftests/cpu-hotplug/Makefile +++ b/tools/testing/selftests/cpu-hotplug/Makefile | |||
@@ -1,7 +1,8 @@ | |||
1 | all: | 1 | all: |
2 | 2 | ||
3 | run_tests: | 3 | TEST_PROGS := on-off-test.sh |
4 | @/bin/bash ./on-off-test.sh || echo "cpu-hotplug selftests: [FAIL]" | 4 | |
5 | include ../lib.mk | ||
5 | 6 | ||
6 | run_full_test: | 7 | run_full_test: |
7 | @/bin/bash ./on-off-test.sh -a || echo "cpu-hotplug selftests: [FAIL]" | 8 | @/bin/bash ./on-off-test.sh -a || echo "cpu-hotplug selftests: [FAIL]" |
diff --git a/tools/testing/selftests/cpu-hotplug/on-off-test.sh b/tools/testing/selftests/cpu-hotplug/on-off-test.sh index 98b1d6565f2c..98b1d6565f2c 100644..100755 --- a/tools/testing/selftests/cpu-hotplug/on-off-test.sh +++ b/tools/testing/selftests/cpu-hotplug/on-off-test.sh | |||
diff --git a/tools/testing/selftests/efivarfs/Makefile b/tools/testing/selftests/efivarfs/Makefile index 29e8c6bc81b0..3052d0bda24b 100644 --- a/tools/testing/selftests/efivarfs/Makefile +++ b/tools/testing/selftests/efivarfs/Makefile | |||
@@ -5,8 +5,9 @@ test_objs = open-unlink create-read | |||
5 | 5 | ||
6 | all: $(test_objs) | 6 | all: $(test_objs) |
7 | 7 | ||
8 | run_tests: all | 8 | TEST_PROGS := efivarfs.sh |
9 | @/bin/bash ./efivarfs.sh || echo "efivarfs selftests: [FAIL]" | 9 | |
10 | include ../lib.mk | ||
10 | 11 | ||
11 | clean: | 12 | clean: |
12 | rm -f $(test_objs) | 13 | rm -f $(test_objs) |
diff --git a/tools/testing/selftests/efivarfs/efivarfs.sh b/tools/testing/selftests/efivarfs/efivarfs.sh index 77edcdcc016b..77edcdcc016b 100644..100755 --- a/tools/testing/selftests/efivarfs/efivarfs.sh +++ b/tools/testing/selftests/efivarfs/efivarfs.sh | |||
diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftests/exec/Makefile index 66dfc2ce1788..a0098daeb73d 100644 --- a/tools/testing/selftests/exec/Makefile +++ b/tools/testing/selftests/exec/Makefile | |||
@@ -18,8 +18,9 @@ execveat.denatured: execveat | |||
18 | %: %.c | 18 | %: %.c |
19 | $(CC) $(CFLAGS) -o $@ $^ | 19 | $(CC) $(CFLAGS) -o $@ $^ |
20 | 20 | ||
21 | run_tests: all | 21 | TEST_PROGS := execveat |
22 | ./execveat | 22 | |
23 | include ../lib.mk | ||
23 | 24 | ||
24 | clean: | 25 | clean: |
25 | rm -rf $(BINARIES) $(DEPS) subdir.moved execveat.moved xxxxx* | 26 | rm -rf $(BINARIES) $(DEPS) subdir.moved execveat.moved xxxxx* |
diff --git a/tools/testing/selftests/firmware/Makefile b/tools/testing/selftests/firmware/Makefile index e23cce0bbc3a..9bf82234855b 100644 --- a/tools/testing/selftests/firmware/Makefile +++ b/tools/testing/selftests/firmware/Makefile | |||
@@ -3,25 +3,9 @@ | |||
3 | # No binaries, but make sure arg-less "make" doesn't trigger "run_tests" | 3 | # No binaries, but make sure arg-less "make" doesn't trigger "run_tests" |
4 | all: | 4 | all: |
5 | 5 | ||
6 | fw_filesystem: | 6 | TEST_PROGS := fw_filesystem.sh fw_userhelper.sh |
7 | @if /bin/sh ./fw_filesystem.sh ; then \ | ||
8 | echo "fw_filesystem: ok"; \ | ||
9 | else \ | ||
10 | echo "fw_filesystem: [FAIL]"; \ | ||
11 | exit 1; \ | ||
12 | fi | ||
13 | 7 | ||
14 | fw_userhelper: | 8 | include ../lib.mk |
15 | @if /bin/sh ./fw_userhelper.sh ; then \ | ||
16 | echo "fw_userhelper: ok"; \ | ||
17 | else \ | ||
18 | echo "fw_userhelper: [FAIL]"; \ | ||
19 | exit 1; \ | ||
20 | fi | ||
21 | |||
22 | run_tests: all fw_filesystem fw_userhelper | ||
23 | 9 | ||
24 | # Nothing to clean up. | 10 | # Nothing to clean up. |
25 | clean: | 11 | clean: |
26 | |||
27 | .PHONY: all clean run_tests fw_filesystem fw_userhelper | ||
diff --git a/tools/testing/selftests/firmware/fw_filesystem.sh b/tools/testing/selftests/firmware/fw_filesystem.sh index 3fc6c10c2479..3fc6c10c2479 100644..100755 --- a/tools/testing/selftests/firmware/fw_filesystem.sh +++ b/tools/testing/selftests/firmware/fw_filesystem.sh | |||
diff --git a/tools/testing/selftests/firmware/fw_userhelper.sh b/tools/testing/selftests/firmware/fw_userhelper.sh index 6efbade12139..6efbade12139 100644..100755 --- a/tools/testing/selftests/firmware/fw_userhelper.sh +++ b/tools/testing/selftests/firmware/fw_userhelper.sh | |||
diff --git a/tools/testing/selftests/ftrace/Makefile b/tools/testing/selftests/ftrace/Makefile index 76cc9f156267..346720639d1d 100644 --- a/tools/testing/selftests/ftrace/Makefile +++ b/tools/testing/selftests/ftrace/Makefile | |||
@@ -1,7 +1,8 @@ | |||
1 | all: | 1 | all: |
2 | 2 | ||
3 | run_tests: | 3 | TEST_PROGS := ftracetest |
4 | @/bin/sh ./ftracetest || echo "ftrace selftests: [FAIL]" | 4 | |
5 | include ../lib.mk | ||
5 | 6 | ||
6 | clean: | 7 | clean: |
7 | rm -rf logs/* | 8 | rm -rf logs/* |
diff --git a/tools/testing/selftests/ipc/Makefile b/tools/testing/selftests/ipc/Makefile index 74bbefdeaf4c..3b6013da4f59 100644 --- a/tools/testing/selftests/ipc/Makefile +++ b/tools/testing/selftests/ipc/Makefile | |||
@@ -18,8 +18,9 @@ else | |||
18 | echo "Not an x86 target, can't build msgque selftest" | 18 | echo "Not an x86 target, can't build msgque selftest" |
19 | endif | 19 | endif |
20 | 20 | ||
21 | run_tests: all | 21 | TEST_PROGS := msgque_test |
22 | ./msgque_test | 22 | |
23 | include ../lib.mk | ||
23 | 24 | ||
24 | clean: | 25 | clean: |
25 | rm -fr ./msgque_test | 26 | rm -fr ./msgque_test |
diff --git a/tools/testing/selftests/kcmp/Makefile b/tools/testing/selftests/kcmp/Makefile index ff0eefdc6ceb..0eecd183058c 100644 --- a/tools/testing/selftests/kcmp/Makefile +++ b/tools/testing/selftests/kcmp/Makefile | |||
@@ -3,8 +3,9 @@ CFLAGS += -I../../../../usr/include/ | |||
3 | 3 | ||
4 | all: kcmp_test | 4 | all: kcmp_test |
5 | 5 | ||
6 | run_tests: all | 6 | TEST_PROGS := kcmp_test |
7 | @./kcmp_test || echo "kcmp_test: [FAIL]" | 7 | |
8 | include ../lib.mk | ||
8 | 9 | ||
9 | clean: | 10 | clean: |
10 | $(RM) kcmp_test kcmp-test-file | 11 | $(RM) kcmp_test kcmp-test-file |
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk new file mode 100644 index 000000000000..b30c5a49cb61 --- /dev/null +++ b/tools/testing/selftests/lib.mk | |||
@@ -0,0 +1,10 @@ | |||
1 | define RUN_TESTS | ||
2 | @for TEST in $(TEST_PROGS); do \ | ||
3 | (./$$TEST && echo "selftests: $$TEST [PASS]") || echo "selftests: $$TEST [FAIL]"; \ | ||
4 | done; | ||
5 | endef | ||
6 | |||
7 | run_tests: all | ||
8 | $(RUN_TESTS) | ||
9 | |||
10 | .PHONY: run_tests all clean | ||
diff --git a/tools/testing/selftests/memfd/Makefile b/tools/testing/selftests/memfd/Makefile index b80cd10d53ba..191dee9d6fd3 100644 --- a/tools/testing/selftests/memfd/Makefile +++ b/tools/testing/selftests/memfd/Makefile | |||
@@ -5,9 +5,9 @@ CFLAGS += -I../../../../include/ | |||
5 | all: | 5 | all: |
6 | gcc $(CFLAGS) memfd_test.c -o memfd_test | 6 | gcc $(CFLAGS) memfd_test.c -o memfd_test |
7 | 7 | ||
8 | run_tests: all | 8 | TEST_PROGS := memfd_test |
9 | gcc $(CFLAGS) memfd_test.c -o memfd_test | 9 | |
10 | @./memfd_test || echo "memfd_test: [FAIL]" | 10 | include ../lib.mk |
11 | 11 | ||
12 | build_fuse: | 12 | build_fuse: |
13 | gcc $(CFLAGS) fuse_mnt.c `pkg-config fuse --cflags --libs` -o fuse_mnt | 13 | gcc $(CFLAGS) fuse_mnt.c `pkg-config fuse --cflags --libs` -o fuse_mnt |
diff --git a/tools/testing/selftests/memory-hotplug/Makefile b/tools/testing/selftests/memory-hotplug/Makefile index d46b8d489cd2..8f7dea66ecac 100644 --- a/tools/testing/selftests/memory-hotplug/Makefile +++ b/tools/testing/selftests/memory-hotplug/Makefile | |||
@@ -1,7 +1,8 @@ | |||
1 | all: | 1 | all: |
2 | 2 | ||
3 | run_tests: | 3 | include ../lib.mk |
4 | @/bin/bash ./on-off-test.sh -r 2 || echo "memory-hotplug selftests: [FAIL]" | 4 | |
5 | override RUN_TESTS := ./on-off-test.sh -r 2 || echo "selftests: memory-hotplug [FAIL]" | ||
5 | 6 | ||
6 | run_full_test: | 7 | run_full_test: |
7 | @/bin/bash ./on-off-test.sh || echo "memory-hotplug selftests: [FAIL]" | 8 | @/bin/bash ./on-off-test.sh || echo "memory-hotplug selftests: [FAIL]" |
diff --git a/tools/testing/selftests/memory-hotplug/on-off-test.sh b/tools/testing/selftests/memory-hotplug/on-off-test.sh index 6cddde0b96f8..6cddde0b96f8 100644..100755 --- a/tools/testing/selftests/memory-hotplug/on-off-test.sh +++ b/tools/testing/selftests/memory-hotplug/on-off-test.sh | |||
diff --git a/tools/testing/selftests/mount/Makefile b/tools/testing/selftests/mount/Makefile index 337d853c2b72..06931dfd3ef0 100644 --- a/tools/testing/selftests/mount/Makefile +++ b/tools/testing/selftests/mount/Makefile | |||
@@ -5,13 +5,9 @@ all: unprivileged-remount-test | |||
5 | unprivileged-remount-test: unprivileged-remount-test.c | 5 | unprivileged-remount-test: unprivileged-remount-test.c |
6 | gcc -Wall -O2 unprivileged-remount-test.c -o unprivileged-remount-test | 6 | gcc -Wall -O2 unprivileged-remount-test.c -o unprivileged-remount-test |
7 | 7 | ||
8 | # Allow specific tests to be selected. | 8 | include ../lib.mk |
9 | test_unprivileged_remount: unprivileged-remount-test | ||
10 | @if [ -f /proc/self/uid_map ] ; then ./unprivileged-remount-test ; fi | ||
11 | 9 | ||
12 | run_tests: all test_unprivileged_remount | 10 | override RUN_TESTS := if [ -f /proc/self/uid_map ] ; then ./unprivileged-remount-test ; fi |
13 | 11 | ||
14 | clean: | 12 | clean: |
15 | rm -f unprivileged-remount-test | 13 | rm -f unprivileged-remount-test |
16 | |||
17 | .PHONY: all test_unprivileged_remount | ||
diff --git a/tools/testing/selftests/mqueue/Makefile b/tools/testing/selftests/mqueue/Makefile index 8056e2e68fa4..cbc300ef11bf 100644 --- a/tools/testing/selftests/mqueue/Makefile +++ b/tools/testing/selftests/mqueue/Makefile | |||
@@ -2,9 +2,12 @@ all: | |||
2 | gcc -O2 mq_open_tests.c -o mq_open_tests -lrt | 2 | gcc -O2 mq_open_tests.c -o mq_open_tests -lrt |
3 | gcc -O2 -o mq_perf_tests mq_perf_tests.c -lrt -lpthread -lpopt | 3 | gcc -O2 -o mq_perf_tests mq_perf_tests.c -lrt -lpthread -lpopt |
4 | 4 | ||
5 | run_tests: | 5 | include ../lib.mk |
6 | @./mq_open_tests /test1 || echo "mq_open_tests: [FAIL]" | 6 | |
7 | @./mq_perf_tests || echo "mq_perf_tests: [FAIL]" | 7 | override define RUN_TESTS |
8 | @./mq_open_tests /test1 || echo "selftests: mq_open_tests [FAIL]" | ||
9 | @./mq_perf_tests || echo "selftests: mq_perf_tests [FAIL]" | ||
10 | endef | ||
8 | 11 | ||
9 | clean: | 12 | clean: |
10 | rm -f mq_open_tests mq_perf_tests | 13 | rm -f mq_open_tests mq_perf_tests |
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile index 62f22cc9941c..fa8187ff15e6 100644 --- a/tools/testing/selftests/net/Makefile +++ b/tools/testing/selftests/net/Makefile | |||
@@ -11,9 +11,9 @@ all: $(NET_PROGS) | |||
11 | %: %.c | 11 | %: %.c |
12 | $(CC) $(CFLAGS) -o $@ $^ | 12 | $(CC) $(CFLAGS) -o $@ $^ |
13 | 13 | ||
14 | run_tests: all | 14 | TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh |
15 | @/bin/sh ./run_netsocktests || echo "sockettests: [FAIL]" | 15 | |
16 | @/bin/sh ./run_afpackettests || echo "afpackettests: [FAIL]" | 16 | include ../lib.mk |
17 | ./test_bpf.sh | 17 | |
18 | clean: | 18 | clean: |
19 | $(RM) $(NET_PROGS) | 19 | $(RM) $(NET_PROGS) |
diff --git a/tools/testing/selftests/net/run_afpackettests b/tools/testing/selftests/net/run_afpackettests index 5246e782d6e8..5246e782d6e8 100644..100755 --- a/tools/testing/selftests/net/run_afpackettests +++ b/tools/testing/selftests/net/run_afpackettests | |||
diff --git a/tools/testing/selftests/net/run_netsocktests b/tools/testing/selftests/net/run_netsocktests index c09a682df56a..c09a682df56a 100644..100755 --- a/tools/testing/selftests/net/run_netsocktests +++ b/tools/testing/selftests/net/run_netsocktests | |||
diff --git a/tools/testing/selftests/ptrace/Makefile b/tools/testing/selftests/ptrace/Makefile index 47ae2d385ce8..453927fea90c 100644 --- a/tools/testing/selftests/ptrace/Makefile +++ b/tools/testing/selftests/ptrace/Makefile | |||
@@ -6,5 +6,6 @@ all: peeksiginfo | |||
6 | clean: | 6 | clean: |
7 | rm -f peeksiginfo | 7 | rm -f peeksiginfo |
8 | 8 | ||
9 | run_tests: all | 9 | TEST_PROGS := peeksiginfo |
10 | @./peeksiginfo || echo "peeksiginfo selftests: [FAIL]" | 10 | |
11 | include ../lib.mk | ||
diff --git a/tools/testing/selftests/size/Makefile b/tools/testing/selftests/size/Makefile index 04dc25e4fa92..e4353d74ea6e 100644 --- a/tools/testing/selftests/size/Makefile +++ b/tools/testing/selftests/size/Makefile | |||
@@ -5,8 +5,9 @@ all: get_size | |||
5 | get_size: get_size.c | 5 | get_size: get_size.c |
6 | $(CC) -static -ffreestanding -nostartfiles -s $< -o $@ | 6 | $(CC) -static -ffreestanding -nostartfiles -s $< -o $@ |
7 | 7 | ||
8 | run_tests: all | 8 | TEST_PROGS := get_size |
9 | ./get_size | 9 | |
10 | include ../lib.mk | ||
10 | 11 | ||
11 | clean: | 12 | clean: |
12 | $(RM) get_size | 13 | $(RM) get_size |
diff --git a/tools/testing/selftests/sysctl/Makefile b/tools/testing/selftests/sysctl/Makefile index 0a92adaf0865..c9660f5ef9f9 100644 --- a/tools/testing/selftests/sysctl/Makefile +++ b/tools/testing/selftests/sysctl/Makefile | |||
@@ -4,16 +4,9 @@ | |||
4 | # No binaries, but make sure arg-less "make" doesn't trigger "run_tests". | 4 | # No binaries, but make sure arg-less "make" doesn't trigger "run_tests". |
5 | all: | 5 | all: |
6 | 6 | ||
7 | # Allow specific tests to be selected. | 7 | TEST_PROGS := run_numerictests run_stringtests |
8 | test_num: | ||
9 | @/bin/sh ./run_numerictests | ||
10 | 8 | ||
11 | test_string: | 9 | include ../lib.mk |
12 | @/bin/sh ./run_stringtests | ||
13 | |||
14 | run_tests: all test_num test_string | ||
15 | 10 | ||
16 | # Nothing to clean up. | 11 | # Nothing to clean up. |
17 | clean: | 12 | clean: |
18 | |||
19 | .PHONY: all run_tests clean test_num test_string | ||
diff --git a/tools/testing/selftests/sysctl/run_numerictests b/tools/testing/selftests/sysctl/run_numerictests index 8510f93f2d14..8510f93f2d14 100644..100755 --- a/tools/testing/selftests/sysctl/run_numerictests +++ b/tools/testing/selftests/sysctl/run_numerictests | |||
diff --git a/tools/testing/selftests/sysctl/run_stringtests b/tools/testing/selftests/sysctl/run_stringtests index 90a9293d520c..90a9293d520c 100644..100755 --- a/tools/testing/selftests/sysctl/run_stringtests +++ b/tools/testing/selftests/sysctl/run_stringtests | |||
diff --git a/tools/testing/selftests/user/Makefile b/tools/testing/selftests/user/Makefile index 12c9d15bab07..d401b63c5b1a 100644 --- a/tools/testing/selftests/user/Makefile +++ b/tools/testing/selftests/user/Makefile | |||
@@ -3,5 +3,6 @@ | |||
3 | # No binaries, but make sure arg-less "make" doesn't trigger "run_tests" | 3 | # No binaries, but make sure arg-less "make" doesn't trigger "run_tests" |
4 | all: | 4 | all: |
5 | 5 | ||
6 | run_tests: all | 6 | TEST_PROGS := test_user_copy.sh |
7 | ./test_user_copy.sh | 7 | |
8 | include ../lib.mk | ||
diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile index 077828c889f1..90e56090b0ed 100644 --- a/tools/testing/selftests/vm/Makefile +++ b/tools/testing/selftests/vm/Makefile | |||
@@ -9,8 +9,9 @@ all: $(BINARIES) | |||
9 | %: %.c | 9 | %: %.c |
10 | $(CC) $(CFLAGS) -o $@ $^ -lrt | 10 | $(CC) $(CFLAGS) -o $@ $^ -lrt |
11 | 11 | ||
12 | run_tests: all | 12 | TEST_PROGS := run_vmtests |
13 | @/bin/sh ./run_vmtests || (echo "vmtests: [FAIL]"; exit 1) | 13 | |
14 | include ../lib.mk | ||
14 | 15 | ||
15 | clean: | 16 | clean: |
16 | $(RM) $(BINARIES) | 17 | $(RM) $(BINARIES) |
diff --git a/tools/testing/selftests/vm/run_vmtests b/tools/testing/selftests/vm/run_vmtests index c87b6812300d..c87b6812300d 100644..100755 --- a/tools/testing/selftests/vm/run_vmtests +++ b/tools/testing/selftests/vm/run_vmtests | |||