Commit 35093786 authored by Seth Howell's avatar Seth Howell Committed by Jim Harris
Browse files

test/autobuild: verify external code can link to libs



This test helps ensure that nothing about the way we build our shared
objects changes in a way that breaks external applications or bdev
modules trying to link to SPDK.

Change-Id: I45ac36a2afc873b04eb237f4e633a9d84066737c
Signed-off-by: default avatarSeth Howell <seth.howell@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/435


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI
parent ae1dc68f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -151,6 +151,7 @@ function build_doc {

function autobuild_test_suite {
	run_test "autobuild_check_format" ./scripts/check_format.sh
	run_test "autobuild_external_code" sudo -E $rootdir/test/external_code/test_make.sh $rootdir
	if [ "$SPDK_TEST_OCF" -eq 1 ]; then
		run_test "autobuild_ocf_precompile" ocf_precompile
	fi
+5 −0
Original line number Diff line number Diff line
@@ -48,3 +48,8 @@ test/unit/lib/ftl/common/utils
test/unit/lib/iscsi/common
test/unit/lib/json_mock
test/unit/lib/sock/uring.c/uring_ut

# These files are in the external_code directory which doesn't get compiled with SPDK.
test/external_code/hello_world/hello_bdev
test/external_code/passthru/vbdev_passthru
test/external_code/passthru/vbdev_passthru_rpc
+80 −0
Original line number Diff line number Diff line
#
#  BSD LICENSE
#
#  Copyright (c) Intel Corporation.
#  All rights reserved.
#
#  Redistribution and use in source and binary forms, with or without
#  modification, are permitted provided that the following conditions
#  are met:
#
#    * Redistributions of source code must retain the above copyright
#      notice, this list of conditions and the following disclaimer.
#    * Redistributions in binary form must reproduce the above copyright
#      notice, this list of conditions and the following disclaimer in
#      the documentation and/or other materials provided with the
#      distribution.
#    * Neither the name of Intel Corporation nor the names of its
#      contributors may be used to endorse or promote products derived
#      from this software without specific prior written permission.
#
#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
#  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
#  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
#  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

ALL_DEPDIRS+= hello_world passthru

ifneq ($(SPDK_HEADER_DIR),)
COMMON_CFLAGS+=-I$(SPDK_HEADER_DIR)
endif

ifneq ($(SPDK_LIB_DIR),)
COMMON_CFLAGS+=-L$(SPDK_LIB_DIR)
endif

ifneq ($(DPDK_LIB_DIR),)
COMMON_CFLAGS+=-L$(DPDK_LIB_DIR)
endif
export
.PHONY: all

all: hello_world_bdev_shared_combo

static: hello_world_bdev_static

hello_world_bdev_shared_combo: passthru_shared
	$(MAKE) --directory=hello_world bdev_shared_combo

hello_world_bdev_shared_iso: passthru_shared
	$(MAKE) --directory=hello_world bdev_shared_iso

hello_world_no_bdev_shared_combo:
	$(MAKE) --directory=hello_world alone_shared_combo

hello_world_no_bdev_shared_iso:
	$(MAKE) --directory=hello_world alone_shared_iso

hello_world_bdev_static: passthru_static
	$(MAKE) --directory=hello_world bdev_static

hello_world_no_bdev_static:
	$(MAKE) --directory=hello_world alone_static

passthru_shared:
	$(MAKE) --directory=passthru shared

passthru_static:
	$(MAKE) --directory=passthru static

clean:
	rm -f ./hello_world/hello_bdev
	rm -f ./passthru/libpassthru_external.*
+17 −0
Original line number Diff line number Diff line
This directory is meant to demonstrate how to link an external application and bdev
module to the SPDK libraries. The makefiles contain six examples of linking against spdk
libraries. They cover linking an application both with and without a custom bdev. For each of
these categories, they also demonstrate linking against the spdk combined shared library,
individual shared libraries, and static libraries.

This directory also contains a convenient test script, test_make.sh, which automates making SPDK
and testing all six of these linker options. It takes a single argument, the path to an SPDK
repository and should be run as follows:

~~~
sudo ./test_make.sh /path/to/spdk
~~~

The application `hello_world` and bdev module `passthru_external` have been copied from their namesakes
in the top level [SPDK github repository](https://github.com/spdk/spdk) and don't have any special
functionality.
+1 −0
Original line number Diff line number Diff line
hello_bdev
Loading