Commit a414e7bb authored by Nick Connolly's avatar Nick Connolly Committed by Tomasz Zawadzki
Browse files

test/unit/lib/sock: Add unit test stubs



With some build environments (e.g. clang, see #1613) linking fails with
unresolved references. This is caused by the inclusion of 'unused code'
which is usually discarded by the linker. The 'unused code' contains
references to functions that have not been 'stubbed' out. The failure can
be seen by removing 'LDFLAGS += -Wl,--gc-sections' in spdk.unittest.mk

Resolved by adding stubs for missing references. These are never called
so return an arbtrary default value.

Part of a set of independent changes which
Fixes #1613

Signed-off-by: default avatarNick Connolly <nick.connolly@mayadata.io>
Change-Id: I7bafbd2b414e1502d54f317d7b671798d564732c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5079


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
parent c626ada0
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -41,6 +41,8 @@
#include "sock/sock.c"
#include "sock/posix/posix.c"

#include "spdk_internal/mock.h"

#define UT_IP	"test_ip"
#define UT_PORT	1234

@@ -67,6 +69,33 @@ struct spdk_ut_sock_group_impl {
#define __ut_sock(sock) (struct spdk_ut_sock *)sock
#define __ut_group(group) (struct spdk_ut_sock_group_impl *)group

DEFINE_STUB(spdk_json_write_array_begin, int,
	    (struct spdk_json_write_ctx *w), 0);

DEFINE_STUB(spdk_json_write_object_begin, int,
	    (struct spdk_json_write_ctx *w), 0);

DEFINE_STUB(spdk_json_write_named_string, int,
	    (struct spdk_json_write_ctx *w, const char *name,
	     const char *val), 0);

DEFINE_STUB(spdk_json_write_named_object_begin, int,
	    (struct spdk_json_write_ctx *w, const char *name), 0);

DEFINE_STUB(spdk_json_write_named_uint32, int,
	    (struct spdk_json_write_ctx *w, const char *name, uint32_t val),
	    0);

DEFINE_STUB(spdk_json_write_named_bool, int,
	    (struct spdk_json_write_ctx *w, const char *name, bool val),
	    0);

DEFINE_STUB(spdk_json_write_object_end, int,
	    (struct spdk_json_write_ctx *w), 0);

DEFINE_STUB(spdk_json_write_array_end, int,
	    (struct spdk_json_write_ctx *w), 0);

static int
spdk_ut_sock_getaddr(struct spdk_sock *_sock, char *saddr, int slen, uint16_t *sport,
		     char *caddr, int clen, uint16_t *cport)