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

0 commit comments

Comments
 (0)