tests: Allow specifying using system Cmocka or building from source
Add a flag "USE_SYSTEM_CMOCKA" in the Makefile of tests. (default 1) If USE_SYSTEM_CMOCKA=1, we will check if the system has Cmocka module, and link it directly. If the system doesn't have Cmocka, we will set the flag to 0 and print a warning message. If USE_SYSTEM_CMOCKA=0, we will build Cmocka from 3rdparty source code. BUG=none TEST=make unit-tests -j TEST=USE_SYSTEM_CMOCKA=0 make unit-tests -j BRANCH=none Signed-off-by: roccochen@chromium.com <roccochen@chromium.org> Change-Id: I091784ca541e2590e3db0a18ceea83e7895ed0c2 Reviewed-on: https://review.coreboot.org/c/coreboot/+/79019 Reviewed-by: Jakub "Kuba" Czapiga <czapiga@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
e7d598ba2c
commit
f4a123f055
2 changed files with 14 additions and 1 deletions
|
|
@ -157,11 +157,14 @@ $($(1)-sysobjs): $(testobj)/$(1)/%.o: $$$$*.c $$($(1)-config-file)
|
|||
|
||||
# Link against Cmocka if not disabled
|
||||
ifeq ($(strip $(filter-out 0 n no,$($(1)-no_test_framework))),)
|
||||
ifneq ($(USE_SYSTEM_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 $$@
|
||||
|
|
|
|||
|
|
@ -24,6 +24,15 @@ TEST_CFLAGS += --coverage
|
|||
TEST_LDFLAGS += --coverage
|
||||
endif
|
||||
|
||||
# Use system cmoka in default, or build from 3rdparty source code if requested
|
||||
USE_SYSTEM_CMOCKA ?= 1
|
||||
ifeq ($(USE_SYSTEM_CMOCKA),1)
|
||||
ifeq ($(shell $(HOSTPKG_CONFIG) --exists cmocka || echo 1),1)
|
||||
$(warning No system cmocka, build from 3rdparty instead...)
|
||||
USE_SYSTEM_CMOCKA=0
|
||||
endif
|
||||
endif
|
||||
|
||||
stages := decompressor bootblock romstage smm verstage
|
||||
stages += ramstage rmodule postcar libagesa
|
||||
|
||||
|
|
@ -186,6 +195,7 @@ help-unit-tests help::
|
|||
@echo '*** coreboot unit-tests targets ***'
|
||||
@echo ' Use "COV=1 make [target]" to enable code coverage for unit tests'
|
||||
@echo ' Use "GDB_DEBUG=1 make [target]" to build with debug symbols'
|
||||
@echo ' Use "USE_SYSTEM_CMOCKA=0 make [target]" to build Cmocka from source'
|
||||
@echo ' unit-tests - Run all unit-tests from tests/'
|
||||
@echo ' clean-unit-tests - Remove unit-tests build artifacts'
|
||||
@echo ' list-unit-tests - List all unit-tests'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue