Hsuan-ting Chen has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/78875?usp=email )
Change subject: tests: Add support for running unit tests on CrOS SDK ......................................................................
tests: Add support for running unit tests on CrOS SDK
Add support for running `make unit-tests` under CrOS SDK by applying two changes in tests/Makefile.common * Respect VBOOT_SOURCE while including generic headers. * Use host cmoka if possible.
BUG=none TEST=make clean-unit-tests && VBOOT_SOURCE=/path/to/vboot_reference/ make unit-tests -j TEST=make clean-unit-tests && make unit-tests -j (with cmocka) TEST=make clean-unit-tests && make unit-tests -j (without cmocka) BRANCH=none
Change-Id: Id3bb3726c91167d2dd648d748763a3948787f28d --- M Makefile M Makefile.inc M tests/Makefile.common 3 files changed, 7 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/75/78875/1
diff --git a/Makefile b/Makefile index 29597c8..b0a99146 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,7 @@
additional-dirs :=
+VBOOT_SOURCE ?= $(abspath 3rdparty/vboot) VBOOT_HOST_BUILD ?= $(abspath $(objutil)/vboot_lib)
COREBOOT_EXPORTS := COREBOOT_EXPORTS diff --git a/Makefile.inc b/Makefile.inc index 22a4646..047c955 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -460,7 +460,6 @@ endif
CPPFLAGS_common := -Isrc -Isrc/include -Isrc/commonlib/include -Isrc/commonlib/bsd/include -I$(obj) -VBOOT_SOURCE ?= 3rdparty/vboot CPPFLAGS_common += -I$(VBOOT_SOURCE)/firmware/include CPPFLAGS_common += -include $(src)/include/kconfig.h CPPFLAGS_common += -include $(src)/include/rules.h diff --git a/tests/Makefile.common b/tests/Makefile.common index e51d253..f1d47ce 100644 --- a/tests/Makefile.common +++ b/tests/Makefile.common @@ -36,7 +36,7 @@
TEST_INCLUDES += -I$(src) -I$(src)/include -I$(src)/commonlib/include \ -I$(src)/commonlib/bsd/include -I$(src)/arch/x86/include \ - -I$(top)/3rdparty/vboot/firmware/include + -I$(VBOOT_SOURCE)/firmware/include
# Path for Kconfig autoheader TEST_INCLUDES += -I$(dir $(TEST_KCONFIG_AUTOHEADER)) @@ -151,11 +151,15 @@
# Link against Cmocka if not disabled ifeq ($(strip $(filter-out 0 n no,$($(1)-no_test_framework))),) +HAVE_CMOCKA := $(shell $(HOSTPKG_CONFIG) --exists cmocka && echo 1) +ifeq ($(HAVE_CMOCKA),) $($(1)-objs): TEST_CFLAGS += -I$(cmockasrc)/include -$($(1)-bin): TEST_LDFLAGS += -L$(cmockaobj)/src -lcmocka -Wl,-rpath=$(cmockaobj)/src +$($(1)-bin): TEST_LDFLAGS += -L$(cmockaobj)/src -Wl,-rpath=$(cmockaobj)/src $($(1)-bin): TEST_CFLAGS += -I$(cmockasrc)/include $($(1)-bin): $(CMOCKA_LIB) endif +$($(1)-bin): TEST_LDFLAGS += -lcmocka +endif
$($(1)-bin): $($(1)-objs) $($(1)-sysobjs) $(HOSTCC) $$^ $($(1)-cflags) $$(TEST_LDFLAGS) -o $$@