From: Reichel Andreas <[email protected]> Per default, tests are now always compiled.
To run tests, with the main Makefile, issue * 'make check'. The Makefile in `tools/tests` is changed so that: * `make all` and `make build-tests`: builds the tests * `make run-tests`: runs the tests Signed-off-by: Andreas Reichel <[email protected]> --- Makefile.am | 12 +++++++++++- docs/COMPILE.md | 6 +++++- tools/tests/Makefile | 18 ++++++++++++++---- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/Makefile.am b/Makefile.am index c6ebec4..cb8e238 100644 --- a/Makefile.am +++ b/Makefile.am @@ -190,6 +190,16 @@ bg_printenvdir = $(top_srcdir) bg_printenv: $(bg_setenv) $(LN_S) -f bg_setenv bg_printenv -all-local: bg_printenv +all-local: bg_printenv build_tests + +build_tests: + make -C tools/tests build-tests + +.PHONY: check +check: + make -C tools/tests run-tests + +clean-local: + make -C tools/tests clean CLEANFILES += bg_printenv diff --git a/docs/COMPILE.md b/docs/COMPILE.md index 51c2008..33faefd 100644 --- a/docs/COMPILE.md +++ b/docs/COMPILE.md @@ -28,6 +28,8 @@ autoreconf -fi make ``` +This will also automatically run internal tests for the environment API. + To cross-compile, the environment variables must be set accordingly, i.e. `CXX=<compiler-to-use>`. The following example shows how to specify needed paths for an out-of-tree build, where cross-compilation environment variables @@ -41,8 +43,10 @@ autoreconf -fi .. --with-gnuefi-sys-dir=<sys-root-dir> \ --with-gnuefi-include-dir=<sys-root-dir>/usr/include/efi \ --with-gnuefi-lds-dir=<sys-root-dir>/usr/lib \ - --with-gnuefi-lib-dir=<sys-root-dir>/usr/lib + --with-gnuefi-lib-dir=<sys-root-dir>/usr/lib \ + --disable-tests make ``` where `<sys-root-dir>` points to the wanted sysroot for cross-compilation. +The option `--disable-tests` inhibits any test runs during compilation. diff --git a/tools/tests/Makefile b/tools/tests/Makefile index d52deaa..da12a61 100644 --- a/tools/tests/Makefile +++ b/tools/tests/Makefile @@ -78,18 +78,28 @@ define WEAKEN_SYMBOLS = $(foreach symbol,$(MOCKOBJS_SYMBOLS_$(1)-$(2)),$(call WEAKEN_SYMBOL,$(symbol),$(1).o)) endef -define TEST_TARGET_TEMPLATE = +define TEST_TARGET_COMPILE_TEMPLATE = $(1): $$(OBJS_$(1:.target=)) $(foreach mockobj,$(MOCKOBJS_$(1:.target=)),$(call WEAKEN_SYMBOLS,$(mockobj),$(1:.target=))) $(CC) $$(OBJS_$(1:.target=):O=o) -o $(1:.target=) $(LIBS) +endef + +define TEST_TARGET_RUN_TEMPLATE = +$(1:.target=.run): $$(OBJS_$(1:.target=)) ./$(1:.target=) endef -.PHONY: clean all $(TEST_TARGETS) +.PHONY: clean all $(TEST_TARGETS) build-tests run-tests + +all: build-tests + +build-tests: $(TEST_TARGETS) + +$(foreach test,$(TEST_TARGETS),$(eval $(call TEST_TARGET_COMPILE_TEMPLATE,$(test)))) -all: $(TEST_TARGETS) +run-tests: $(TEST_TARGETS:.target=.run) -$(foreach test,$(TEST_TARGETS),$(eval $(call TEST_TARGET_TEMPLATE,$(test)))) +$(foreach test,$(TEST_TARGETS),$(eval $(call TEST_TARGET_RUN_TEMPLATE,$(test)))) # Search for source files in current and parent directory %.O: %.c -- 2.14.1 -- You received this message because you are subscribed to the Google Groups "EFI Boot Guard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/efibootguard-dev/20170905082734.11233-3-andreas.reichel.ext%40siemens.com. For more options, visit https://groups.google.com/d/optout.
