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

test/unit/lib/iscsi: 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: I63953b666e841942f51f9cc035c6a6521663079d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5084


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 f4b81843
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -49,8 +49,22 @@ DEFINE_STUB_V(spdk_trace_register_object, (uint8_t type, char id_prefix));
DEFINE_STUB_V(spdk_trace_register_description, (const char *name,
		uint16_t tpoint_id, uint8_t owner_type, uint8_t object_type, uint8_t new_object,
		uint8_t arg1_type, const char *arg1_name));
DEFINE_STUB_V(_spdk_trace_record, (uint64_t tsc, uint16_t tpoint_id, uint16_t poller_id,
DEFINE_STUB_V(_spdk_trace_record,
	      (uint64_t tsc, uint16_t tpoint_id, uint16_t poller_id,
	       uint32_t size, uint64_t object_id, uint64_t arg1));
DEFINE_STUB(iscsi_get_pdu, struct spdk_iscsi_pdu *,
	    (struct spdk_iscsi_conn *conn), NULL);
DEFINE_STUB(iscsi_param_eq_val, int,
	    (struct iscsi_param *params, const char *key, const char *val), 0);
DEFINE_STUB(iscsi_pdu_calc_data_digest, uint32_t, (struct spdk_iscsi_pdu *pdu), 0);
DEFINE_STUB(spdk_json_write_object_begin, int, (struct spdk_json_write_ctx *w), 0);
DEFINE_STUB(spdk_json_write_named_int32, int, (struct spdk_json_write_ctx *w,
		const char *name, int32_t val), 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_object_end, int, (struct spdk_json_write_ctx *w), 0);
DEFINE_STUB_V(spdk_sock_writev_async,
	      (struct spdk_sock *sock, struct spdk_sock_request *req));

struct spdk_scsi_lun {
	uint8_t reserved;
+3 −0
Original line number Diff line number Diff line
@@ -47,6 +47,9 @@
DEFINE_STUB(iscsi_conn_construct, int,
	    (struct spdk_iscsi_portal *portal, struct spdk_sock *sock),
	    0);
DEFINE_STUB(iscsi_check_chap_params, bool,
	    (bool disable, bool require, bool mutual, int group),
	    false);

struct spdk_iscsi_globals g_iscsi;

+13 −0
Original line number Diff line number Diff line
@@ -75,6 +75,19 @@ DEFINE_STUB(iscsi_portal_grp_find_by_tag,
DEFINE_STUB(iscsi_init_grp_find_by_tag, struct spdk_iscsi_init_grp *,
	    (int tag), NULL);

DEFINE_STUB_V(iscsi_op_abort_task_set,
	      (struct spdk_iscsi_task *task, uint8_t function));

DEFINE_STUB(iscsi_parse_redirect_addr,
	    int,
	    (struct sockaddr_storage *sa, const char *host, const char *port),
	    0);

DEFINE_STUB(iscsi_portal_grp_find_portal_by_addr,
	    struct spdk_iscsi_portal *,
	    (struct spdk_iscsi_portal_grp *pg, const char *host, const char *port),
	    NULL);

struct spdk_scsi_lun *
spdk_scsi_dev_get_lun(struct spdk_scsi_dev *dev, int lun_id)
{