]> rtime.felk.cvut.cz Git - omk.git/blob - snippets/wvtest.omk
Update wvtool
[omk.git] / snippets / wvtest.omk
1 # wvtest_SCRIPTS    .. list of scripts producing wvtest output
2 # wvtest_PROGRAMS   .. list of the testing programs producing wvtest output
3
4 ifndef WVTEST_LIBRARY
5 WVTEST_LIBRARY = wvtest
6 endif
7
8 # Documentation: wvtest_PROGRAMS is amost equivalent to test_PROGRAMS.
9 # The two differences are that the program is automatically linked
10 # with $(WVTEST_LIBRARY) and it is run during "make wvtest".
11 test_PROGRAMS += $(wvtest_PROGRAMS)
12
13 # Documentation: If your project uses wvtest, it is recomended to put
14 # the "test: wvtest" rule to config.target.
15 wvtest:
16         $(Q)$(MAKERULES_DIR)/wvtestrun $(MAKE) wvtest-pass
17
18 .PHONY: wvtest
19
20 $(eval $(call omk_pass_template,wvtest-pass,$$(LOCAL_BUILD_DIR),,$(wvtest_SCRIPTS)$(wvtest_PROGRAMS)))
21
22 # Usage: $(call wvtest_template,<shell command>)
23 define wvtest_template
24 wvtest-pass-local: wvtest-run-$(1)
25 .PHONY: wvtest-run-$(1)
26 wvtest-run-$(1):
27         $(Q)echo "Testing \"Run $(1)\" in Makefile.rules:"
28         $(Q)mkdir -p $(1).wvtest
29         $(Q)cd $(1).wvtest && \
30           PATH=$$(USER_BIN_DIR):$$$$PATH LD_LIBRARY_PATH=$$(USER_LIB_DIR):$$$$LD_LIBRARY_PATH \
31           $(1)
32 $(notdir $(1))_LIBS += $$(WVTEST_LIBRARY)
33 endef
34
35 # Documentation: Write the test so, that it can be run from arbitrary
36 # directory, i.e. in case of a script ensure that the wvtest library
37 # is sourced like this:
38 #
39 # . $(dirname $0)/wvtest.sh
40
41 $(foreach script,$(wvtest_SCRIPTS),$(eval $(call wvtest_template,$(SOURCES_DIR)/$(script))))
42 # Hack!!!
43 USER_TESTS_DIR := $(OUTPUT_DIR)/_compiled/bin-tests
44 $(foreach prog,$(wvtest_PROGRAMS),$(eval $(call wvtest_template,$(USER_TESTS_DIR)/$(prog))))