Skip to content

Commit

Permalink
selftests: add default rules for c source file
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
bamvor.zhangjian@huawei.com authored and Shuah Khan committed Jan 5, 2017
1 parent 5fe5979 commit 7d758af
Showing 6 changed files with 10 additions and 21 deletions.
2 changes: 0 additions & 2 deletions tools/testing/selftests/exec/Makefile
Original file line number Diff line number Diff line change
@@ -11,8 +11,6 @@ execveat.symlink: execveat
execveat.denatured: execveat
cp $< $@
chmod -x $@
%: %.c
$(CC) $(CFLAGS) -o $@ $^

TEST_GEN_PROGS := execveat
TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir
3 changes: 3 additions & 0 deletions tools/testing/selftests/lib.mk
Original file line number Diff line number Diff line change
@@ -45,4 +45,7 @@ all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
clean:
$(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)

%: %.c
$(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ $^

.PHONY: run_tests all clean install emit_tests
3 changes: 0 additions & 3 deletions tools/testing/selftests/mount/Makefile
Original file line number Diff line number Diff line change
@@ -2,9 +2,6 @@
CFLAGS = -Wall \
-O2

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

TEST_GEN_PROGS := unprivileged-remount-test

include ../lib.mk
2 changes: 0 additions & 2 deletions tools/testing/selftests/net/Makefile
Original file line number Diff line number Diff line change
@@ -4,8 +4,6 @@ CFLAGS = -Wall -Wl,--no-as-needed -O2 -g
CFLAGS += -I../../../../usr/include/

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

TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh
TEST_GEN_FILES = socket
4 changes: 1 addition & 3 deletions tools/testing/selftests/size/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

get_size: get_size.c
$(CC) -static -ffreestanding -nostartfiles -s $< -o $@
CFLAGS := -static -ffreestanding -nostartfiles -s

TEST_GEN_PROGS := get_size

17 changes: 6 additions & 11 deletions tools/testing/selftests/vm/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Makefile for vm selftests

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

%: %.c
$(CC) $(CFLAGS) -o $@ $^ -lrt
userfaultfd: userfaultfd.c ../../../../usr/include/linux/kernel.h
$(CC) $(CFLAGS) -O2 -o $@ $< -lpthread

mlock-random-test: mlock-random-test.c
$(CC) $(CFLAGS) -o $@ $< -lcap

../../../../usr/include/linux/kernel.h:
make -C ../../../.. headers_install

TEST_PROGS := run_vmtests

include ../lib.mk

userfaultfd: LDLIBS += -lpthread ../../../../usr/include/linux/kernel.h
mlock-random-test: LDLIBS += -lcap

../../../../usr/include/linux/kernel.h:
make -C ../../../.. headers_install

0 comments on commit 7d758af

Please sign in to comment.