]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - tools/testing/selftests/lib.mk
1 # This mimics the top-level Makefile. We do it explicitly here so that this
2 # Makefile can operate with or without the kbuild infrastructure.
3 CC
:= $(CROSS_COMPILE
)gcc
9 # The following are built by lib.mk common compile rules.
10 # TEST_CUSTOM_PROGS should be used by tests that require
11 # custom build rule and prevent common build rule use.
12 # TEST_PROGS are for test shell scripts.
13 # TEST_CUSTOM_PROGS and TEST_PROGS will be run by common run_tests
14 # and install targets. Common clean doesn't touch them.
15 TEST_GEN_PROGS
:= $(patsubst %,$(OUTPUT
)/%,$(TEST_GEN_PROGS
))
16 TEST_GEN_PROGS_EXTENDED
:= $(patsubst %,$(OUTPUT
)/%,$(TEST_GEN_PROGS_EXTENDED
))
17 TEST_GEN_FILES
:= $(patsubst %,$(OUTPUT
)/%,$(TEST_GEN_FILES
))
19 top_srcdir ?
= ..
/..
/..
/..
20 include $(top_srcdir
)/scripts
/subarch.
include
23 all: $(TEST_GEN_PROGS
) $(TEST_GEN_PROGS_EXTENDED
) $(TEST_GEN_FILES
)
27 make ARCH
=$(ARCH
) -C
$(top_srcdir
) headers_install
29 ifdef KSFT_KHDR_INSTALL
30 $(TEST_GEN_PROGS
) $(TEST_GEN_PROGS_EXTENDED
) $(TEST_GEN_FILES
):| khdr
36 @echo
"TAP version 13";
37 @for TEST in
$(1); do \
38 BASENAME_TEST
=`basename $$TEST`; \
39 test_num
=`echo $$test_num+1 | bc`; \
40 echo
"selftests: $$BASENAME_TEST"; \
41 echo
"========================================"; \
42 if
[ ! -x
$$TEST ]; then \
43 echo
"selftests: Warning: file $$BASENAME_TEST is not executable, correct this.";\
44 echo
"not ok 1..$$test_num selftests: $$BASENAME_TEST [FAIL]"; \
46 if
[ "X$(summary)" != "X" ]; then \
47 cd
`dirname $$TEST` > /dev
/null
; (.
/$$BASENAME_TEST > /tmp
/$$BASENAME_TEST 2>&1 && echo
"ok 1..$$test_num selftests: $$BASENAME_TEST [PASS]") || echo
"not ok 1..$$test_num selftests: $$BASENAME_TEST [FAIL]"; cd
- > /dev
/null
;\
49 cd
`dirname $$TEST` > /dev
/null
; (.
/$$BASENAME_TEST && echo
"ok 1..$$test_num selftests: $$BASENAME_TEST [PASS]") || echo
"not ok 1..$$test_num selftests: $$BASENAME_TEST [FAIL]"; cd
- > /dev
/null
;\
56 ifneq ($(KBUILD_SRC
),)
57 @if
[ "X$(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES)" != "X" ]; then
58 @rsync
-aq
$(TEST_PROGS
) $(TEST_PROGS_EXTENDED
) $(TEST_FILES
) $(OUTPUT
)
60 @if
[ "X$(TEST_PROGS)" != "X" ]; then
61 $(call RUN_TESTS
, $(TEST_GEN_PROGS
) $(TEST_CUSTOM_PROGS
) $(OUTPUT
)/$(TEST_PROGS
))
63 $(call RUN_TESTS
, $(TEST_GEN_PROGS
) $(TEST_CUSTOM_PROGS
))
66 $(call RUN_TESTS
, $(TEST_GEN_PROGS
) $(TEST_CUSTOM_PROGS
) $(TEST_PROGS
))
70 @if
[ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)" != "X" ]; then \
71 mkdir
-p
${INSTALL_PATH}; \
72 echo
"rsync -a $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/"; \
73 rsync
-a
$(TEST_PROGS
) $(TEST_PROGS_EXTENDED
) $(TEST_FILES
) $(INSTALL_PATH
)/; \
75 @if
[ "X$(TEST_GEN_PROGS)$(TEST_CUSTOM_PROGS)$(TEST_GEN_PROGS_EXTENDED)$(TEST_GEN_FILES)" != "X" ]; then \
76 mkdir
-p
${INSTALL_PATH}; \
77 echo
"rsync -a $(TEST_GEN_PROGS) $(TEST_CUSTOM_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(INSTALL_PATH)/"; \
78 rsync
-a
$(TEST_GEN_PROGS
) $(TEST_CUSTOM_PROGS
) $(TEST_GEN_PROGS_EXTENDED
) $(TEST_GEN_FILES
) $(INSTALL_PATH
)/; \
86 $(error Error
: set INSTALL_PATH to use
install)
90 @for TEST in
$(TEST_GEN_PROGS
) $(TEST_CUSTOM_PROGS
) $(TEST_PROGS
); do \
91 BASENAME_TEST
=`basename $$TEST`; \
92 echo
"(./$$BASENAME_TEST > /tmp/$$BASENAME_TEST 2>&1 && echo \"selftests: $$BASENAME_TEST [PASS]\") || echo \"selftests: $$BASENAME_TEST [FAIL]\""; \
99 # define if isn't already. It is undefined in make O= case.
105 $(RM
) -r
$(TEST_GEN_PROGS
) $(TEST_GEN_PROGS_EXTENDED
) $(TEST_GEN_FILES
) $(EXTRA_CLEAN
)
111 # When make O= with kselftest target from main level
112 # the following aren't defined.
114 ifneq ($(KBUILD_SRC
),)
115 LINK.c
= $(CC
) $(CFLAGS
) $(CPPFLAGS
) $(LDFLAGS
) $(TARGET_ARCH
)
116 COMPILE.S
= $(CC
) $(ASFLAGS
) $(CPPFLAGS
) $(TARGET_ARCH
) -c
117 LINK.S
= $(CC
) $(ASFLAGS
) $(CPPFLAGS
) $(LDFLAGS
) $(TARGET_ARCH
)
121 $(LINK.c
) $^
$(LDLIBS
) -o
$@
124 $(COMPILE.S
) $^
-o
$@
127 $(LINK.S
) $^
$(LDLIBS
) -o
$@
129 .PHONY
: run_tests
all clean install emit_tests