Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

bamvor.zhangjian@huawei.com and committed by
Shuah Khan
7d758af2 5fe59799

+10 -21
-2
tools/testing/selftests/exec/Makefile
··· 11 11 execveat.denatured: execveat 12 12 cp $< $@ 13 13 chmod -x $@ 14 - %: %.c 15 - $(CC) $(CFLAGS) -o $@ $^ 16 14 17 15 TEST_GEN_PROGS := execveat 18 16 TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir
+3
tools/testing/selftests/lib.mk
··· 45 45 clean: 46 46 $(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) 47 47 48 + %: %.c 49 + $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ $^ 50 + 48 51 .PHONY: run_tests all clean install emit_tests
-3
tools/testing/selftests/mount/Makefile
··· 2 2 CFLAGS = -Wall \ 3 3 -O2 4 4 5 - unprivileged-remount-test: unprivileged-remount-test.c 6 - $(CC) $(CFLAGS) unprivileged-remount-test.c -o unprivileged-remount-test 7 - 8 5 TEST_GEN_PROGS := unprivileged-remount-test 9 6 10 7 include ../lib.mk
-2
tools/testing/selftests/net/Makefile
··· 4 4 CFLAGS += -I../../../../usr/include/ 5 5 6 6 reuseport_bpf_numa: LDFLAGS += -lnuma 7 - %: %.c 8 - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ 9 7 10 8 TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh 11 9 TEST_GEN_FILES = socket
+1 -3
tools/testing/selftests/size/Makefile
··· 1 - 2 - get_size: get_size.c 3 - $(CC) -static -ffreestanding -nostartfiles -s $< -o $@ 1 + CFLAGS := -static -ffreestanding -nostartfiles -s 4 2 5 3 TEST_GEN_PROGS := get_size 6 4
+6 -11
tools/testing/selftests/vm/Makefile
··· 1 1 # Makefile for vm selftests 2 2 3 3 CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS) 4 + LDLIBS = -lrt 4 5 TEST_GEN_FILES = compaction_test 5 6 TEST_GEN_FILES += hugepage-mmap 6 7 TEST_GEN_FILES += hugepage-shm ··· 13 12 TEST_GEN_FILES += userfaultfd 14 13 TEST_GEN_FILES += mlock-random-test 15 14 16 - %: %.c 17 - $(CC) $(CFLAGS) -o $@ $^ -lrt 18 - userfaultfd: userfaultfd.c ../../../../usr/include/linux/kernel.h 19 - $(CC) $(CFLAGS) -O2 -o $@ $< -lpthread 20 - 21 - mlock-random-test: mlock-random-test.c 22 - $(CC) $(CFLAGS) -o $@ $< -lcap 23 - 24 - ../../../../usr/include/linux/kernel.h: 25 - make -C ../../../.. headers_install 26 - 27 15 TEST_PROGS := run_vmtests 28 16 29 17 include ../lib.mk 30 18 19 + userfaultfd: LDLIBS += -lpthread ../../../../usr/include/linux/kernel.h 20 + mlock-random-test: LDLIBS += -lcap 21 + 22 + ../../../../usr/include/linux/kernel.h: 23 + make -C ../../../.. headers_install