Hi,

On 09/11/2017 01:35 PM, [ext] Andreas J. Reichel wrote:
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      | 13 ++++++++++---
  tools/tests/Makefile | 18 ++++++++++++++----
  3 files changed, 35 insertions(+), 8 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..33d5604 100644
--- a/docs/COMPILE.md
+++ b/docs/COMPILE.md
@@ -5,13 +5,13 @@
  ### Arch Linux ###
```
-pacman -S gnu-efi-libs pciutils
+pacman -S gnu-efi-libs pciutils cmocka
  ```
### Debian 8 ### ```
-apt-get install gnu-efi libpci-dev
+apt-get install gnu-efi libpci-dev libcmocka-dev
  ```
## Compilation ##
@@ -28,6 +28,13 @@ autoreconf -fi
  make
  ```
+This will also automatically compile internal tests for the environment API.
+
+To run the tests, call
+```
+make check
+```
+
  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,7 +48,7 @@ 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 \

Again with the documentation... ;) '\' should not be there, otherwise 'make would be a parameter.

Cheers,
Claudius

  make
  ```
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


--
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-54 Fax: (+49)-8142-66989-80 Email: [email protected]

--
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/299d0722-c314-033d-b061-b14c1333319e%40siemens.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to