Skip to content

Commit 7d758af

Browse files
bamvor.zhangjian@huawei.comShuah Khan
authored andcommitted
selftests: add default rules for c source file
There are difference rules for compiling c source file in different testcases. In order to enable KBUILD_OUTPUT support in later patch, this patch introduce the default rules in "tools/testing/selftest/lib.mk" and remove the existing rules in each testcase. Acked-by: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
1 parent 5fe5979 commit 7d758af

6 files changed

Lines changed: 10 additions & 21 deletions

File tree

‎tools/testing/selftests/exec/Makefile‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ execveat.symlink: execveat
1111
execveat.denatured: execveat
1212
cp $< $@
1313
chmod -x $@
14-
%: %.c
15-
$(CC) $(CFLAGS) -o $@ $^
1614

1715
TEST_GEN_PROGS := execveat
1816
TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir

‎tools/testing/selftests/lib.mk‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,7 @@ all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
4545
clean:
4646
$(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
4747

48+
%: %.c
49+
$(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ $^
50+
4851
.PHONY: run_tests all clean install emit_tests

‎tools/testing/selftests/mount/Makefile‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
CFLAGS = -Wall \
33
-O2
44

5-
unprivileged-remount-test: unprivileged-remount-test.c
6-
$(CC) $(CFLAGS) unprivileged-remount-test.c -o unprivileged-remount-test
7-
85
TEST_GEN_PROGS := unprivileged-remount-test
96

107
include ../lib.mk

‎tools/testing/selftests/net/Makefile‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ CFLAGS = -Wall -Wl,--no-as-needed -O2 -g
44
CFLAGS += -I../../../../usr/include/
55

66
reuseport_bpf_numa: LDFLAGS += -lnuma
7-
%: %.c
8-
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
97

108
TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh
119
TEST_GEN_FILES = socket

‎tools/testing/selftests/size/Makefile‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
2-
get_size: get_size.c
3-
$(CC) -static -ffreestanding -nostartfiles -s $< -o $@
1+
CFLAGS := -static -ffreestanding -nostartfiles -s
42

53
TEST_GEN_PROGS := get_size
64

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Makefile for vm selftests
22

33
CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS)
4+
LDLIBS = -lrt
45
TEST_GEN_FILES = compaction_test
56
TEST_GEN_FILES += hugepage-mmap
67
TEST_GEN_FILES += hugepage-shm
@@ -12,18 +13,12 @@ TEST_GEN_FILES += transhuge-stress
1213
TEST_GEN_FILES += userfaultfd
1314
TEST_GEN_FILES += mlock-random-test
1415

15-
%: %.c
16-
$(CC) $(CFLAGS) -o $@ $^ -lrt
17-
userfaultfd: userfaultfd.c ../../../../usr/include/linux/kernel.h
18-
$(CC) $(CFLAGS) -O2 -o $@ $< -lpthread
19-
20-
mlock-random-test: mlock-random-test.c
21-
$(CC) $(CFLAGS) -o $@ $< -lcap
22-
23-
../../../../usr/include/linux/kernel.h:
24-
make -C ../../../.. headers_install
25-
2616
TEST_PROGS := run_vmtests
2717

2818
include ../lib.mk
2919

20+
userfaultfd: LDLIBS += -lpthread ../../../../usr/include/linux/kernel.h
21+
mlock-random-test: LDLIBS += -lcap
22+
23+
../../../../usr/include/linux/kernel.h:
24+
make -C ../../../.. headers_install

0 commit comments

Comments
 (0)