]> git.karo-electronics.de Git - karo-tx-linux.git/blob - tools/testing/selftests/lib.mk
9fddffd066ca9eb07d81b51befae5cebe6424e33
[karo-tx-linux.git] / 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
4
5 define RUN_TESTS
6         @for TEST in $(TEST_GEN_PROGS) $(TEST_PROGS); do \
7                 (./$$TEST && echo "selftests: $$TEST [PASS]") || echo "selftests: $$TEST [FAIL]"; \
8         done;
9 endef
10
11 run_tests: all
12         $(RUN_TESTS)
13
14 define INSTALL_RULE
15         @if [ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)" != "X" ]; then                                        \
16                 mkdir -p ${INSTALL_PATH};                                                                               \
17                 echo "rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/";       \
18                 rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/;              \
19         fi
20         @if [ "X$(TEST_GEN_PROGS)$(TEST_GEN_PROGS_EXTENDED)$(TEST_GEN_FILES)" != "X" ]; then                                    \
21                 mkdir -p ${INSTALL_PATH};                                                                               \
22                 echo "rsync -a $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(INSTALL_PATH)/";        \
23                 rsync -a $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(INSTALL_PATH)/;               \
24         fi
25 endef
26
27 install: all
28 ifdef INSTALL_PATH
29         $(INSTALL_RULE)
30 else
31         $(error Error: set INSTALL_PATH to use install)
32 endif
33
34 define EMIT_TESTS
35         @for TEST in $(TEST_GEN_PROGS) $(TEST_PROGS); do \
36                 echo "(./$$TEST && echo \"selftests: $$TEST [PASS]\") || echo \"selftests: $$TEST [FAIL]\""; \
37         done;
38 endef
39
40 emit_tests:
41         $(EMIT_TESTS)
42
43 all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
44
45 clean:
46         $(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
47
48 .PHONY: run_tests all clean install emit_tests