Skip to content

Commit 88baa78

Browse files
bamvor.zhangjian@huawei.comShuah Khan
authored andcommitted
selftests: remove duplicated all and clean target
Currently, kselftest use TEST_PROGS, TEST_PROGS_EXTENDED, TEST_FILES to indicate the test program, extended test program and test files. It is easy to understand the purpose of these files. But mix of compiled and uncompiled files lead to duplicated "all" and "clean" targets. In order to remove the duplicated targets, introduce TEST_GEN_PROGS, TEST_GEN_PROGS_EXTENDED, TEST_GEN_FILES to indicate the compiled objects. Also, the later patch will make use of TEST_GEN_XXX to redirect these files to output directory indicated by KBUILD_OUTPUT or O. And add this changes to "Contributing new tests(details)" of Documentation/kselftest.txt. Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
1 parent 7ce7d89 commit 88baa78

File tree

37 files changed

+118
-255
lines changed

37 files changed

+118
-255
lines changed

Documentation/kselftest.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,15 @@ In general, the rules for selftests are
9595

9696
* Don't cause the top-level "make run_tests" to fail if your feature is
9797
unconfigured.
98+
99+
Contributing new tests(details)
100+
===============================
101+
102+
* Use TEST_GEN_XXX if such binaries or files are generated during
103+
compiling.
104+
TEST_PROGS, TEST_GEN_PROGS mean it is the excutable tested by
105+
default.
106+
TEST_PROGS_EXTENDED, TEST_GEN_PROGS_EXTENDED mean it is the
107+
executable which is not tested by default.
108+
TEST_FILES, TEST_GEN_FILES mean it is the file which is used by
109+
test.

tools/testing/selftests/bpf/Makefile

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
CFLAGS += -Wall -O2 -I../../../../usr/include
22

3-
test_objs = test_verifier test_maps test_lru_map
3+
TEST_GEN_PROGS = test_verifier test_maps test_lru_map
44

5-
TEST_PROGS := test_verifier test_maps test_lru_map test_kmod.sh
6-
TEST_FILES := $(test_objs)
7-
8-
all: $(test_objs)
5+
TEST_PROGS := test_kmod.sh
96

107
include ../lib.mk
11-
12-
clean:
13-
$(RM) $(test_objs)

tools/testing/selftests/breakpoints/Makefile

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,13 @@ uname_M := $(shell uname -m 2>/dev/null || echo not)
33
ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
44

55
ifeq ($(ARCH),x86)
6-
TEST_PROGS := breakpoint_test
6+
TEST_GEN_PROGS := breakpoint_test
77
endif
88
ifeq ($(ARCH),aarch64)
9-
TEST_PROGS := breakpoint_test_arm64
9+
TEST_GEN_PROGS := breakpoint_test_arm64
1010
endif
1111

12-
TEST_PROGS += step_after_suspend_test
13-
14-
all: $(TEST_PROGS)
12+
TEST_GEN_PROGS += step_after_suspend_test
1513

1614
include ../lib.mk
1715

18-
clean:
19-
rm -fr breakpoint_test breakpoint_test_arm64 step_after_suspend_test
Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
TEST_FILES := validate_cap
2-
TEST_PROGS := test_execve
3-
4-
BINARIES := $(TEST_FILES) $(TEST_PROGS)
1+
TEST_GEN_FILES := validate_cap
2+
TEST_GEN_PROGS := test_execve
53

64
CFLAGS += -O2 -g -std=gnu99 -Wall
75
LDLIBS += -lcap-ng -lrt -ldl
86

9-
all: $(BINARIES)
10-
11-
clean:
12-
$(RM) $(BINARIES)
13-
147
include ../lib.mk
158

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
CFLAGS = -Wall
22

3-
test_objs = open-unlink create-read
4-
5-
all: $(test_objs)
6-
3+
TEST_GEN_FILES := open-unlink create-read
74
TEST_PROGS := efivarfs.sh
8-
TEST_FILES := $(test_objs)
95

106
include ../lib.mk
117

12-
clean:
13-
rm -f $(test_objs)

tools/testing/selftests/exec/Makefile

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
CFLAGS = -Wall
2-
BINARIES = execveat
3-
DEPS = execveat.symlink execveat.denatured script subdir
4-
all: $(BINARIES) $(DEPS)
52

63
subdir:
74
mkdir -p $@
@@ -17,11 +14,12 @@ execveat.denatured: execveat
1714
%: %.c
1815
$(CC) $(CFLAGS) -o $@ $^
1916

20-
TEST_PROGS := execveat
17+
TEST_GEN_PROGS := execveat
18+
TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir
2119
# Makefile is a run-time dependency, since it's accessed by the execveat test
22-
TEST_FILES := $(DEPS) Makefile
20+
TEST_FILES := Makefile
2321

2422
include ../lib.mk
2523

2624
clean:
27-
rm -rf $(BINARIES) $(DEPS) subdir.moved execveat.moved xxxxx*
25+
rm -rf $(TEST_GEN_PROGS) $(TEST_GEN_FILES) subdir.moved execveat.moved xxxxx*

tools/testing/selftests/futex/functional/Makefile

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ CFLAGS := $(CFLAGS) -g -O2 -Wall -D_GNU_SOURCE -pthread $(INCLUDES)
33
LDFLAGS := $(LDFLAGS) -pthread -lrt
44

55
HEADERS := ../include/futextest.h
6-
TARGETS := \
6+
TEST_GEN_FILES := \
77
futex_wait_timeout \
88
futex_wait_wouldblock \
99
futex_requeue_pi \
@@ -12,14 +12,8 @@ TARGETS := \
1212
futex_wait_uninitialized_heap \
1313
futex_wait_private_mapped_file
1414

15-
TEST_PROGS := $(TARGETS) run.sh
16-
17-
.PHONY: all clean
18-
all: $(TARGETS)
19-
20-
$(TARGETS): $(HEADERS)
15+
TEST_PROGS := run.sh
2116

2217
include ../../lib.mk
2318

24-
clean:
25-
rm -f $(TARGETS)
19+
$(TEST_GEN_FILES): $(HEADERS)

tools/testing/selftests/ipc/Makefile

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,7 @@ endif
1111

1212
CFLAGS += -I../../../../usr/include/
1313

14-
all:
15-
$(CC) $(CFLAGS) msgque.c -o msgque_test
16-
17-
TEST_PROGS := msgque_test
14+
TEST_GEN_PROGS := msgque
1815

1916
include ../lib.mk
2017

21-
clean:
22-
rm -fr ./msgque_test

tools/testing/selftests/kcmp/Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
CFLAGS += -I../../../../usr/include/
22

3-
all: kcmp_test
4-
5-
TEST_PROGS := kcmp_test
3+
TEST_GEN_PROGS := kcmp_test
64

75
include ../lib.mk
86

97
clean:
10-
$(RM) kcmp_test kcmp-test-file
8+
$(RM) $(TEST_GEN_PROGS) kcmp-test-file

tools/testing/selftests/lib.mk

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
CC := $(CROSS_COMPILE)gcc
44

55
define RUN_TESTS
6-
@for TEST in $(TEST_PROGS); do \
6+
@for TEST in $(TEST_GEN_PROGS) $(TEST_PROGS); do \
77
(./$$TEST && echo "selftests: $$TEST [PASS]") || echo "selftests: $$TEST [FAIL]"; \
88
done;
99
endef
@@ -14,8 +14,13 @@ run_tests: all
1414
define INSTALL_RULE
1515
@if [ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)" != "X" ]; then \
1616
mkdir -p ${INSTALL_PATH}; \
17-
echo "rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/"; \
18-
rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/; \
17+
echo "rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/"; \
18+
rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/; \
19+
fi
20+
@if [ "X$(TEST_GEN_PROGS)$(TEST_GEN_PROGS_EXTENDED)$(TEST_GEN_FILES)" != "X" ]; then \
21+
mkdir -p ${INSTALL_PATH}; \
22+
echo "rsync -a $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(INSTALL_PATH)/"; \
23+
rsync -a $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(INSTALL_PATH)/; \
1924
fi
2025
endef
2126

@@ -27,12 +32,17 @@ else
2732
endif
2833

2934
define EMIT_TESTS
30-
@for TEST in $(TEST_PROGS); do \
35+
@for TEST in $(TEST_GEN_PROGS) $(TEST_PROGS); do \
3136
echo "(./$$TEST && echo \"selftests: $$TEST [PASS]\") || echo \"selftests: $$TEST [FAIL]\""; \
3237
done;
3338
endef
3439

3540
emit_tests:
3641
$(EMIT_TESTS)
3742

43+
all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
44+
45+
clean:
46+
$(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
47+
3848
.PHONY: run_tests all clean install emit_tests
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
CFLAGS += -g -I../../../../usr/include/
22

3-
TEST_PROGS := membarrier_test
4-
5-
all: $(TEST_PROGS)
3+
TEST_GEN_PROGS := membarrier_test
64

75
include ../lib.mk
86

9-
clean:
10-
$(RM) $(TEST_PROGS)

tools/testing/selftests/memfd/Makefile

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,11 @@ CFLAGS += -I../../../../include/uapi/
44
CFLAGS += -I../../../../include/
55
CFLAGS += -I../../../../usr/include/
66

7-
TEST_PROGS := memfd_test
8-
9-
all: $(TEST_PROGS)
10-
11-
include ../lib.mk
12-
13-
build_fuse: fuse_mnt fuse_test
7+
TEST_PROGS := run_fuse_test.sh
8+
TEST_GEN_FILES := memfd_test fuse_mnt fuse_test
149

1510
fuse_mnt.o: CFLAGS += $(shell pkg-config fuse --cflags)
1611
fuse_mnt: LDFLAGS += $(shell pkg-config fuse --libs)
1712

18-
run_fuse: build_fuse
19-
@./run_fuse_test.sh || echo "fuse_test: [FAIL]"
13+
include ../lib.mk
2014

21-
clean:
22-
$(RM) memfd_test fuse_test
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Makefile for mount selftests.
22
CFLAGS = -Wall \
33
-O2
4-
all: unprivileged-remount-test
54

65
unprivileged-remount-test: unprivileged-remount-test.c
76
$(CC) $(CFLAGS) unprivileged-remount-test.c -o unprivileged-remount-test
87

8+
TEST_GEN_PROGS := unprivileged-remount-test
9+
910
include ../lib.mk
1011

11-
TEST_PROGS := unprivileged-remount-test
1212
override RUN_TESTS := if [ -f /proc/self/uid_map ] ; \
1313
then \
1414
./unprivileged-remount-test ; \
@@ -17,5 +17,3 @@ override RUN_TESTS := if [ -f /proc/self/uid_map ] ; \
1717
fi
1818
override EMIT_TESTS := echo "$(RUN_TESTS)"
1919

20-
clean:
21-
rm -f unprivileged-remount-test

tools/testing/selftests/mqueue/Makefile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
CFLAGS += -O2
22
LDLIBS = -lrt -lpthread -lpopt
3-
TEST_PROGS := mq_open_tests mq_perf_tests
4-
5-
all: $(TEST_PROGS)
3+
TEST_GEN_PROGS := mq_open_tests mq_perf_tests
64

75
include ../lib.mk
86

@@ -16,5 +14,3 @@ override define EMIT_TESTS
1614
echo "./mq_perf_tests || echo \"selftests: mq_perf_tests [FAIL]\""
1715
endef
1816

19-
clean:
20-
rm -f mq_open_tests mq_perf_tests

tools/testing/selftests/net/Makefile

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,15 @@
33
CFLAGS = -Wall -Wl,--no-as-needed -O2 -g
44
CFLAGS += -I../../../../usr/include/
55

6-
NET_PROGS = socket
7-
NET_PROGS += psock_fanout psock_tpacket
8-
NET_PROGS += reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa
9-
NET_PROGS += reuseport_dualstack
10-
11-
all: $(NET_PROGS)
126
reuseport_bpf_numa: LDFLAGS += -lnuma
137
%: %.c
148
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
159

1610
TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh
17-
TEST_FILES := $(NET_PROGS)
11+
TEST_GEN_FILES = socket
12+
TEST_GEN_FILES += psock_fanout psock_tpacket
13+
TEST_GEN_FILES += reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa
14+
TEST_GEN_FILES += reuseport_dualstack
1815

1916
include ../lib.mk
2017

21-
clean:
22-
$(RM) $(NET_PROGS)

tools/testing/selftests/nsfs/Makefile

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
TEST_PROGS := owner pidns
1+
TEST_GEN_PROGS := owner pidns
22

33
CFLAGS := -Wall -Werror
44

5-
all: owner pidns
6-
owner: owner.c
7-
pidns: pidns.c
8-
9-
clean:
10-
$(RM) owner pidns
11-
125
include ../lib.mk
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
TEST_PROGS := copy_unaligned copy_first_unaligned paste_unaligned paste_last_unaligned
2-
3-
all: $(TEST_PROGS)
4-
5-
$(TEST_PROGS): ../harness.c ../utils.c copy_paste_unaligned_common.c
1+
TEST_GEN_PROGS := copy_unaligned copy_first_unaligned paste_unaligned paste_last_unaligned
62

73
include ../../lib.mk
84

9-
clean:
10-
rm -f $(TEST_PROGS)
5+
$(TEST_GEN_PROGS): ../harness.c ../utils.c copy_paste_unaligned_common.c
Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
TEST_PROGS := gettimeofday context_switch mmap_bench futex_bench null_syscall
1+
TEST_GEN_PROGS := gettimeofday context_switch mmap_bench futex_bench null_syscall
22

33
CFLAGS += -O2
44

5-
all: $(TEST_PROGS)
5+
$(TEST_GEN_PROGS): ../harness.c
66

7-
$(TEST_PROGS): ../harness.c
7+
include ../../lib.mk
88

99
context_switch: ../utils.c
1010
context_switch: CFLAGS += -maltivec -mvsx -mabi=altivec
1111
context_switch: LDLIBS += -lpthread
12-
13-
include ../../lib.mk
14-
15-
clean:
16-
rm -f $(TEST_PROGS) *.o
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
TEST_PROGS := cp_abort
2-
3-
all: $(TEST_PROGS)
4-
5-
$(TEST_PROGS): ../harness.c ../utils.c
1+
TEST_GEN_PROGS := cp_abort
62

73
include ../../lib.mk
84

9-
clean:
10-
rm -f $(TEST_PROGS)
5+
$(TEST_GEN_PROGS): ../harness.c ../utils.c

tools/testing/selftests/powerpc/copyloops/Makefile

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,14 @@ CFLAGS += -maltivec
77
# Use our CFLAGS for the implicit .S rule
88
ASFLAGS = $(CFLAGS)
99

10-
TEST_PROGS := copyuser_64 copyuser_power7 memcpy_64 memcpy_power7
10+
TEST_GEN_PROGS := copyuser_64 copyuser_power7 memcpy_64 memcpy_power7
1111
EXTRA_SOURCES := validate.c ../harness.c
1212

13-
all: $(TEST_PROGS)
13+
include ../../lib.mk
1414

1515
copyuser_64: CPPFLAGS += -D COPY_LOOP=test___copy_tofrom_user_base
1616
copyuser_power7: CPPFLAGS += -D COPY_LOOP=test___copy_tofrom_user_power7
1717
memcpy_64: CPPFLAGS += -D COPY_LOOP=test_memcpy
1818
memcpy_power7: CPPFLAGS += -D COPY_LOOP=test_memcpy_power7
1919

20-
$(TEST_PROGS): $(EXTRA_SOURCES)
21-
22-
include ../../lib.mk
23-
24-
clean:
25-
rm -f $(TEST_PROGS) *.o
20+
$(TEST_GEN_PROGS): $(EXTRA_SOURCES)

0 commit comments

Comments
 (0)