Commit 5e181ba8 authored by Jim Harris's avatar Jim Harris
Browse files

build: explicitly link unit tests with static libraries



Unit tests define mock functions in the unit test code
itself.  This links fine with static libraries, but
doesn't work if trying to link with shared libraries.

So change the unit tests to always explicitly link
with the static libraries.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I3a8a60162fcab6c73a216c4bb364175767fdc62c

Reviewed-on: https://review.gerrithub.io/422441


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent afca5512
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -63,4 +63,13 @@ SPDK_LIB_LINKER_ARGS = \
	-Wl,--no-whole-archive \
	$(SPDK_REMAINING_LIB_LIST:%=-lspdk_%)

# This is primarily used for unit tests to ensure they link when shared library
# build is enabled.  Shared libraries can't get their mock implementation from
# the unit test file.
SPDK_STATIC_LIB_LINKER_ARGS = \
	-Wl,--whole-archive \
	$(SPDK_WHOLE_ARCHIVE_LIB_LIST:%=$(SPDK_ROOT_DIR)/build/lib/libspdk_%.a) \
	-Wl,--no-whole-archive \
	$(SPDK_REMAINING_LIB_LIST:%=$(SPDK_ROOT_DIR)/build/lib/libspdk_%.a)

install: all
+1 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ CFLAGS += -I$(SPDK_ROOT_DIR)/test

SPDK_LIB_LIST += thread util log spdk_mock sock

LIBS += -lcunit $(SPDK_LIB_LINKER_ARGS)
LIBS += -lcunit $(SPDK_STATIC_LIB_LINKER_ARGS)

APP = $(TEST_FILE:.c=)