From db35950a13859f8680bb97c961337d3317a974b2 Mon Sep 17 00:00:00 2001 From: Konrad Sztyber Date: Fri, 2 Apr 2021 11:34:20 +0200 Subject: [PATCH] mk/unit: link with trace library Linking each unit test with spdk_trace allows for getting rid of lots of stub definitions for the trace functions. The behavior stays the same, as the trace calls result in no-op anyway because none of the unit test apps enable tracing. Signed-off-by: Konrad Sztyber Change-Id: I904dac92205aadd644100af2c38989bb7979e47c Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7231 Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Reviewed-by: Aleksey Marchuk Reviewed-by: Jim Harris Reviewed-by: Paul Luse --- mk/spdk.unittest.mk | 2 +- test/unit/lib/bdev/bdev.c/bdev_ut.c | 11 -------- test/unit/lib/bdev/mt/bdev.c/bdev_ut.c | 10 ------- test/unit/lib/bdev/part.c/part_ut.c | 10 ------- .../blobfs/blobfs_async_ut/blobfs_async_ut.c | 8 ------ .../blobfs/blobfs_sync_ut/blobfs_sync_ut.c | 8 ------ test/unit/lib/iscsi/common.c | 10 ------- test/unit/lib/iscsi/conn.c/conn_ut.c | 10 ------- test/unit/lib/nvmf/fc.c/fc_ut.c | 10 ------- test/unit/lib/nvmf/rdma.c/rdma_ut.c | 9 ------- test/unit/lib/nvmf/tcp.c/tcp_ut.c | 26 ------------------- test/unit/lib/scsi/lun.c/lun_ut.c | 6 ----- 12 files changed, 1 insertion(+), 119 deletions(-) diff --git a/mk/spdk.unittest.mk b/mk/spdk.unittest.mk index 4dddb9a00e..0f9add2c7e 100644 --- a/mk/spdk.unittest.mk +++ b/mk/spdk.unittest.mk @@ -52,7 +52,7 @@ CFLAGS += -I$(SPDK_ROOT_DIR)/test CFLAGS += -ffunction-sections LDFLAGS += -Wl,--gc-sections -SPDK_LIB_LIST += thread util log +SPDK_LIB_LIST += thread util log trace LIBS += -lcunit $(SPDK_STATIC_LIB_LINKER_ARGS) diff --git a/test/unit/lib/bdev/bdev.c/bdev_ut.c b/test/unit/lib/bdev/bdev.c/bdev_ut.c index a0350bafa7..0e5efc5cb8 100644 --- a/test/unit/lib/bdev/bdev.c/bdev_ut.c +++ b/test/unit/lib/bdev/bdev.c/bdev_ut.c @@ -42,20 +42,9 @@ #include "bdev/bdev.c" -struct spdk_trace_histories *g_trace_histories; -DEFINE_STUB_V(spdk_trace_add_register_fn, (struct spdk_trace_register_fn *reg_fn)); -DEFINE_STUB_V(spdk_trace_register_owner, (uint8_t type, char id_prefix)); -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, - uint32_t size, uint64_t object_id, uint64_t arg1)); DEFINE_STUB(spdk_notify_send, uint64_t, (const char *type, const char *ctx), 0); DEFINE_STUB(spdk_notify_type_register, struct spdk_notify_type *, (const char *type), NULL); - int g_status; int g_count; enum spdk_bdev_event_type g_event_type1; diff --git a/test/unit/lib/bdev/mt/bdev.c/bdev_ut.c b/test/unit/lib/bdev/mt/bdev.c/bdev_ut.c index 238823ebe6..96ebb009ea 100644 --- a/test/unit/lib/bdev/mt/bdev.c/bdev_ut.c +++ b/test/unit/lib/bdev/mt/bdev.c/bdev_ut.c @@ -44,16 +44,6 @@ #define BDEV_UT_NUM_THREADS 3 -struct spdk_trace_histories *g_trace_histories; -DEFINE_STUB_V(spdk_trace_add_register_fn, (struct spdk_trace_register_fn *reg_fn)); -DEFINE_STUB_V(spdk_trace_register_owner, (uint8_t type, char id_prefix)); -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, - uint32_t size, uint64_t object_id, uint64_t arg1)); DEFINE_STUB(spdk_notify_send, uint64_t, (const char *type, const char *ctx), 0); DEFINE_STUB(spdk_notify_type_register, struct spdk_notify_type *, (const char *type), NULL); DEFINE_STUB_V(spdk_scsi_nvme_translate, (const struct spdk_bdev_io *bdev_io, int *sc, int *sk, diff --git a/test/unit/lib/bdev/part.c/part_ut.c b/test/unit/lib/bdev/part.c/part_ut.c index b2c9363c5c..4e3c52889c 100644 --- a/test/unit/lib/bdev/part.c/part_ut.c +++ b/test/unit/lib/bdev/part.c/part_ut.c @@ -43,16 +43,6 @@ #include "bdev/bdev.c" #include "bdev/part.c" -struct spdk_trace_histories *g_trace_histories; -DEFINE_STUB_V(spdk_trace_add_register_fn, (struct spdk_trace_register_fn *reg_fn)); -DEFINE_STUB_V(spdk_trace_register_owner, (uint8_t type, char id_prefix)); -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, - uint32_t size, uint64_t object_id, uint64_t arg1)); DEFINE_STUB(spdk_notify_send, uint64_t, (const char *type, const char *ctx), 0); DEFINE_STUB(spdk_notify_type_register, struct spdk_notify_type *, (const char *type), NULL); diff --git a/test/unit/lib/blobfs/blobfs_async_ut/blobfs_async_ut.c b/test/unit/lib/blobfs/blobfs_async_ut/blobfs_async_ut.c index 804bc3a606..1f62b9ab5f 100644 --- a/test/unit/lib/blobfs/blobfs_async_ut/blobfs_async_ut.c +++ b/test/unit/lib/blobfs/blobfs_async_ut/blobfs_async_ut.c @@ -47,14 +47,6 @@ struct spdk_filesystem *g_fs; struct spdk_file *g_file; int g_fserrno; -struct spdk_trace_histories *g_trace_histories; -DEFINE_STUB_V(spdk_trace_add_register_fn, (struct spdk_trace_register_fn *reg_fn)); -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_is_ptr, const char *arg1_name)); -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)); static void fs_op_complete(void *ctx, int fserrno) diff --git a/test/unit/lib/blobfs/blobfs_sync_ut/blobfs_sync_ut.c b/test/unit/lib/blobfs/blobfs_sync_ut/blobfs_sync_ut.c index ae483dec97..442026b1a9 100644 --- a/test/unit/lib/blobfs/blobfs_sync_ut/blobfs_sync_ut.c +++ b/test/unit/lib/blobfs/blobfs_sync_ut/blobfs_sync_ut.c @@ -49,14 +49,6 @@ struct spdk_filesystem *g_fs; struct spdk_file *g_file; int g_fserrno; struct spdk_thread *g_dispatch_thread = NULL; -struct spdk_trace_histories *g_trace_histories; -DEFINE_STUB_V(spdk_trace_add_register_fn, (struct spdk_trace_register_fn *reg_fn)); -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_is_ptr, const char *arg1_name)); -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)); struct ut_request { fs_request_fn fn; diff --git a/test/unit/lib/iscsi/common.c b/test/unit/lib/iscsi/common.c index baa0bcd45a..e5d0f6ad1e 100644 --- a/test/unit/lib/iscsi/common.c +++ b/test/unit/lib/iscsi/common.c @@ -13,16 +13,6 @@ SPDK_LOG_REGISTER_COMPONENT(iscsi) -struct spdk_trace_histories *g_trace_histories; -DEFINE_STUB_V(spdk_trace_add_register_fn, (struct spdk_trace_register_fn *reg_fn)); -DEFINE_STUB_V(spdk_trace_register_owner, (uint8_t type, char id_prefix)); -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, - uint32_t size, uint64_t object_id, uint64_t arg1)); - TAILQ_HEAD(, spdk_iscsi_pdu) g_write_pdu_list = TAILQ_HEAD_INITIALIZER(g_write_pdu_list); static bool g_task_pool_is_empty = false; diff --git a/test/unit/lib/iscsi/conn.c/conn_ut.c b/test/unit/lib/iscsi/conn.c/conn_ut.c index 2ce45e5188..fae4b49d7f 100644 --- a/test/unit/lib/iscsi/conn.c/conn_ut.c +++ b/test/unit/lib/iscsi/conn.c/conn_ut.c @@ -42,16 +42,6 @@ SPDK_LOG_REGISTER_COMPONENT(iscsi) -struct spdk_trace_histories *g_trace_histories; -DEFINE_STUB_V(spdk_trace_add_register_fn, (struct spdk_trace_register_fn *reg_fn)); -DEFINE_STUB_V(spdk_trace_register_owner, (uint8_t type, char id_prefix)); -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, - 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, diff --git a/test/unit/lib/nvmf/fc.c/fc_ut.c b/test/unit/lib/nvmf/fc.c/fc_ut.c index cad99e4822..be9f9cc071 100644 --- a/test/unit/lib/nvmf/fc.c/fc_ut.c +++ b/test/unit/lib/nvmf/fc.c/fc_ut.c @@ -92,19 +92,9 @@ const struct spdk_nvmf_transport_ops spdk_nvmf_transport_tcp = { .type = SPDK_NVME_TRANSPORT_TCP, }; -struct spdk_trace_histories *g_trace_histories; - -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(spdk_nvme_transport_id_compare, int, (const struct spdk_nvme_transport_id *trid1, const struct spdk_nvme_transport_id *trid2), 0); -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_add_register_fn, (struct spdk_trace_register_fn *reg_fn)); DEFINE_STUB(spdk_bdev_get_name, const char *, (const struct spdk_bdev *bdev), "fc_ut_test"); DEFINE_STUB_V(nvmf_ctrlr_destruct, (struct spdk_nvmf_ctrlr *ctrlr)); DEFINE_STUB_V(nvmf_qpair_free_aer, (struct spdk_nvmf_qpair *qpair)); diff --git a/test/unit/lib/nvmf/rdma.c/rdma_ut.c b/test/unit/lib/nvmf/rdma.c/rdma_ut.c index f81a56f506..bc63aa2152 100644 --- a/test/unit/lib/nvmf/rdma.c/rdma_ut.c +++ b/test/unit/lib/nvmf/rdma.c/rdma_ut.c @@ -63,15 +63,6 @@ DEFINE_STUB(spdk_nvmf_qpair_get_listen_trid, int, (struct spdk_nvmf_qpair *qpair, struct spdk_nvme_transport_id *trid), 0); DEFINE_STUB_V(spdk_mem_map_free, (struct spdk_mem_map **pmap)); -struct spdk_trace_histories *g_trace_histories; -DEFINE_STUB_V(spdk_trace_add_register_fn, (struct spdk_trace_register_fn *reg_fn)); -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, - uint32_t size, uint64_t object_id, uint64_t arg1)); - DEFINE_STUB_V(spdk_nvmf_ctrlr_data_init, (struct spdk_nvmf_transport_opts *opts, struct spdk_nvmf_ctrlr_data *cdata)); DEFINE_STUB_V(spdk_nvmf_request_exec, (struct spdk_nvmf_request *req)); diff --git a/test/unit/lib/nvmf/tcp.c/tcp_ut.c b/test/unit/lib/nvmf/tcp.c/tcp_ut.c index 9ad670d621..b9ac4595d3 100644 --- a/test/unit/lib/nvmf/tcp.c/tcp_ut.c +++ b/test/unit/lib/nvmf/tcp.c/tcp_ut.c @@ -246,8 +246,6 @@ DEFINE_STUB(spdk_nvmf_bdev_ctrlr_nvme_passthru_admin, spdk_nvmf_nvme_passthru_cmd_cb cb_fn), 0) -struct spdk_trace_histories *g_trace_histories; - struct spdk_bdev { int ut_mock; uint64_t blockcnt; @@ -260,25 +258,6 @@ spdk_nvme_transport_id_compare(const struct spdk_nvme_transport_id *trid1, return 0; } -void -spdk_trace_register_object(uint8_t type, char id_prefix) -{ -} - -void -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) -{ -} - -void -_spdk_trace_record(uint64_t tsc, uint16_t tpoint_id, uint16_t poller_id, - uint32_t size, uint64_t object_id, uint64_t arg1) -{ -} - const char * spdk_nvme_transport_id_trtype_str(enum spdk_nvme_transport_type trtype) { @@ -367,11 +346,6 @@ spdk_nvmf_subsystem_get_mn(const struct spdk_nvmf_subsystem *subsystem) return subsystem->mn; } -void -spdk_trace_add_register_fn(struct spdk_trace_register_fn *reg_fn) -{ -} - static void test_nvmf_tcp_create(void) { diff --git a/test/unit/lib/scsi/lun.c/lun_ut.c b/test/unit/lib/scsi/lun.c/lun_ut.c index 532318fa5f..793ce662e2 100644 --- a/test/unit/lib/scsi/lun.c/lun_ut.c +++ b/test/unit/lib/scsi/lun.c/lun_ut.c @@ -57,12 +57,6 @@ static bool g_lun_execute_fail = false; static int g_lun_execute_status = SPDK_SCSI_TASK_PENDING; static uint32_t g_task_count = 0; -struct spdk_trace_histories *g_trace_histories; - -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(bdev_scsi_get_dif_ctx, bool, (struct spdk_bdev *bdev, struct spdk_scsi_task *task, struct spdk_dif_ctx *dif_ctx), false);