]>
git.proxmox.com Git - mirror_ubuntu-eoan-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 all: $(TEST_GEN_PROGS
) $(TEST_GEN_PROGS_EXTENDED
) $(TEST_GEN_FILES
)
24 @echo
"TAP version 13";
25 @for TEST in
$(1); do \
26 BASENAME_TEST
=`basename $$TEST`; \
27 test_num
=`echo $$test_num+1 | bc`; \
28 echo
"selftests: $$BASENAME_TEST"; \
29 echo
"========================================"; \
30 if
[ ! -x
$$TEST ]; then \
31 echo
"selftests: Warning: file $$BASENAME_TEST is not executable, correct this.";\
32 echo
"not ok 1..$$test_num selftests: $$BASENAME_TEST [FAIL]"; \
34 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
;\
40 $(call RUN_TESTS
, $(TEST_GEN_PROGS
) $(TEST_CUSTOM_PROGS
) $(TEST_PROGS
))
43 @if
[ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)" != "X" ]; then \
44 mkdir
-p
${INSTALL_PATH}; \
45 echo
"rsync -a $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/"; \
46 rsync
-a
$(TEST_PROGS
) $(TEST_PROGS_EXTENDED
) $(TEST_FILES
) $(INSTALL_PATH
)/; \
48 @if
[ "X$(TEST_GEN_PROGS)$(TEST_CUSTOM_PROGS)$(TEST_GEN_PROGS_EXTENDED)$(TEST_GEN_FILES)" != "X" ]; then \
49 mkdir
-p
${INSTALL_PATH}; \
50 echo
"rsync -a $(TEST_GEN_PROGS) $(TEST_CUSTOM_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(INSTALL_PATH)/"; \
51 rsync
-a
$(TEST_GEN_PROGS
) $(TEST_CUSTOM_PROGS
) $(TEST_GEN_PROGS_EXTENDED
) $(TEST_GEN_FILES
) $(INSTALL_PATH
)/; \
59 $(error Error
: set INSTALL_PATH to use
install)
63 @for TEST in
$(TEST_GEN_PROGS
) $(TEST_CUSTOM_PROGS
) $(TEST_PROGS
); do \
64 BASENAME_TEST
=`basename $$TEST`; \
65 echo
"(./$$BASENAME_TEST > /tmp/$$BASENAME_TEST 2>&1 && echo \"selftests: $$BASENAME_TEST [PASS]\") || echo \"selftests: $$BASENAME_TEST [FAIL]\""; \
72 # define if isn't already. It is undefined in make O= case.
78 $(RM
) -r
$(TEST_GEN_PROGS
) $(TEST_GEN_PROGS_EXTENDED
) $(TEST_GEN_FILES
) $(EXTRA_CLEAN
)
84 # When make O= with kselftest target from main level
85 # the following aren't defined.
87 ifneq ($(KBUILD_SRC
),)
88 LINK.c
= $(CC
) $(CFLAGS
) $(CPPFLAGS
) $(LDFLAGS
) $(TARGET_ARCH
)
89 COMPILE.S
= $(CC
) $(ASFLAGS
) $(CPPFLAGS
) $(TARGET_ARCH
) -c
90 LINK.S
= $(CC
) $(ASFLAGS
) $(CPPFLAGS
) $(LDFLAGS
) $(TARGET_ARCH
)
94 $(LINK.c
) $^
$(LDLIBS
) -o
$@
100 $(LINK.S
) $^
$(LDLIBS
) -o
$@
102 .PHONY
: run_tests
all clean install emit_tests