Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
[sfrench/cifs-2.6.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_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         mkdir -p $(INSTALL_PATH)
16         install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES)
17 endef
18
19 install: all
20 ifdef INSTALL_PATH
21         $(INSTALL_RULE)
22 else
23         $(error Error: set INSTALL_PATH to use install)
24 endif
25
26 define EMIT_TESTS
27         @for TEST in $(TEST_PROGS); do \
28                 echo "(./$$TEST && echo \"selftests: $$TEST [PASS]\") || echo \"selftests: $$TEST [FAIL]\""; \
29         done;
30 endef
31
32 emit_tests:
33         $(EMIT_TESTS)
34
35 .PHONY: run_tests all clean install emit_tests