From a414e7bbf6c27601cf97b252f08bf1c2f78ec48f Mon Sep 17 00:00:00 2001 From: Nick Connolly Date: Wed, 11 Nov 2020 13:29:41 +0000 Subject: [PATCH] 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: Nick Connolly Change-Id: I7bafbd2b414e1502d54f317d7b671798d564732c Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5079 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Aleksey Marchuk --- test/unit/lib/sock/sock.c/sock_ut.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/unit/lib/sock/sock.c/sock_ut.c b/test/unit/lib/sock/sock.c/sock_ut.c index bbe4822d7..877dbaf4b 100644 --- a/test/unit/lib/sock/sock.c/sock_ut.c +++ b/test/unit/lib/sock/sock.c/sock_ut.c @@ -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)