selftests: add default rules for c source file
authorbamvor.zhangjian@huawei.com <bamvor.zhangjian@huawei.com>
Tue, 29 Nov 2016 11:55:49 +0000 (19:55 +0800)
committerShuah Khan <shuahkh@osg.samsung.com>
Thu, 5 Jan 2017 20:42:01 +0000 (13:42 -0700)
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>
tools/testing/selftests/exec/Makefile
tools/testing/selftests/lib.mk
tools/testing/selftests/mount/Makefile
tools/testing/selftests/net/Makefile
tools/testing/selftests/size/Makefile
tools/testing/selftests/vm/Makefile

index b3bf091368ca9e1ec2d6bb926015bafde0c1061a..9eb1c3e4d33949c6876c184ab842fa1af01fc535 100644 (file)
@@ -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
index 5b8634cad0924bd6f9d77e01a1e22bcdac6f52e1..68d7c01b9f061db32c047740af05002c72b6046f 100644 (file)
@@ -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
index e8fb15e801722748fad1f2b2d2ac24a56cf82a65..9093d7ffe87f158e2f1f72d68e791e23afdcac40 100644 (file)
@@ -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
index fe5b36dd7140d43d3c40700acba4b7f082005dbb..fbfe5d0d5c2e05028e6af86d8db76d95e41c4fc5 100644 (file)
@@ -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
index c67f3577e888d5c91486471fa60f4b9253ec4cfb..4685b3e421fcd48f261d32a54edc6fa1658abc70 100644 (file)
@@ -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
 
index 323383ab45810744874aae098e3d64de0bc51f00..8141d5169f4de473040798a1c357da2edcd0e3ac 100644 (file)
@@ -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