nvmf: Use STUB in UT for ctrlr_bdev.c

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I2a28254546fcb4b3744f3ca5b0420e600275abc9
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/458707
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Ziye Yang <ziye.yang@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
This commit is contained in:
Shuhei Matsumoto 2019-06-20 08:59:20 +09:00 committed by Changpeng Liu
parent 3a7b6e5bd4
commit 824bf66302

View File

@ -35,22 +35,16 @@
#include "spdk_cunit.h" #include "spdk_cunit.h"
#include "spdk_internal/mock.h"
#include "nvmf/ctrlr_bdev.c" #include "nvmf/ctrlr_bdev.c"
SPDK_LOG_REGISTER_COMPONENT("nvmf", SPDK_LOG_NVMF) SPDK_LOG_REGISTER_COMPONENT("nvmf", SPDK_LOG_NVMF)
int DEFINE_STUB(spdk_nvmf_request_complete, int, (struct spdk_nvmf_request *req), -1);
spdk_nvmf_request_complete(struct spdk_nvmf_request *req)
{
return -1;
}
const char * DEFINE_STUB(spdk_bdev_get_name, const char *, (const struct spdk_bdev *bdev), "test");
spdk_bdev_get_name(const struct spdk_bdev *bdev)
{
return "test";
}
uint32_t uint32_t
spdk_bdev_get_block_size(const struct spdk_bdev *bdev) spdk_bdev_get_block_size(const struct spdk_bdev *bdev)
@ -73,100 +67,69 @@ spdk_bdev_get_optimal_io_boundary(const struct spdk_bdev *bdev)
return 0; return 0;
} }
struct spdk_io_channel * DEFINE_STUB(spdk_bdev_get_io_channel, struct spdk_io_channel *,
spdk_bdev_get_io_channel(struct spdk_bdev_desc *desc) (struct spdk_bdev_desc *desc), NULL);
{
return NULL;
}
int DEFINE_STUB(spdk_bdev_flush_blocks, int,
spdk_bdev_flush_blocks(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch, (struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
uint64_t offset_blocks, uint64_t num_blocks, uint64_t offset_blocks, uint64_t num_blocks,
spdk_bdev_io_completion_cb cb, void *cb_arg) spdk_bdev_io_completion_cb cb, void *cb_arg),
{ 0);
return 0;
}
int DEFINE_STUB(spdk_bdev_unmap_blocks, int,
spdk_bdev_unmap_blocks(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch, (struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
uint64_t offset_blocks, uint64_t num_blocks, uint64_t offset_blocks, uint64_t num_blocks,
spdk_bdev_io_completion_cb cb, void *cb_arg) spdk_bdev_io_completion_cb cb, void *cb_arg),
{ 0);
return 0;
}
bool DEFINE_STUB(spdk_bdev_io_type_supported, bool,
spdk_bdev_io_type_supported(struct spdk_bdev *bdev, enum spdk_bdev_io_type io_type) (struct spdk_bdev *bdev, enum spdk_bdev_io_type io_type), false);
{
return false;
}
int DEFINE_STUB(spdk_bdev_queue_io_wait, int,
spdk_bdev_queue_io_wait(struct spdk_bdev *bdev, struct spdk_io_channel *ch, (struct spdk_bdev *bdev, struct spdk_io_channel *ch,
struct spdk_bdev_io_wait_entry *entry) struct spdk_bdev_io_wait_entry *entry),
{ 0);
return 0;
}
int DEFINE_STUB(spdk_bdev_write_blocks, int,
spdk_bdev_write_blocks(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch, void *buf, (struct spdk_bdev_desc *desc, struct spdk_io_channel *ch, void *buf,
uint64_t offset_blocks, uint64_t num_blocks, uint64_t offset_blocks, uint64_t num_blocks,
spdk_bdev_io_completion_cb cb, void *cb_arg) spdk_bdev_io_completion_cb cb, void *cb_arg),
{ 0);
return 0;
}
int DEFINE_STUB(spdk_bdev_writev_blocks, int,
spdk_bdev_writev_blocks(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch, (struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
struct iovec *iov, int iovcnt, struct iovec *iov, int iovcnt, uint64_t offset_blocks, uint64_t num_blocks,
uint64_t offset_blocks, uint64_t num_blocks, spdk_bdev_io_completion_cb cb, void *cb_arg),
spdk_bdev_io_completion_cb cb, void *cb_arg) 0);
{
return 0;
}
int DEFINE_STUB(spdk_bdev_read_blocks, int,
spdk_bdev_read_blocks(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch, void *buf, (struct spdk_bdev_desc *desc, struct spdk_io_channel *ch, void *buf,
uint64_t offset_blocks, uint64_t num_blocks, uint64_t offset_blocks, uint64_t num_blocks,
spdk_bdev_io_completion_cb cb, void *cb_arg) spdk_bdev_io_completion_cb cb, void *cb_arg),
{ 0);
return 0;
}
int spdk_bdev_readv_blocks(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch, DEFINE_STUB(spdk_bdev_readv_blocks, int,
struct iovec *iov, int iovcnt, (struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
uint64_t offset_blocks, uint64_t num_blocks, struct iovec *iov, int iovcnt, uint64_t offset_blocks, uint64_t num_blocks,
spdk_bdev_io_completion_cb cb, void *cb_arg) spdk_bdev_io_completion_cb cb, void *cb_arg),
{ 0);
return 0;
}
int DEFINE_STUB(spdk_bdev_write_zeroes_blocks, int,
spdk_bdev_write_zeroes_blocks(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch, (struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
uint64_t offset_blocks, uint64_t num_blocks, uint64_t offset_blocks, uint64_t num_blocks,
spdk_bdev_io_completion_cb cb, void *cb_arg) spdk_bdev_io_completion_cb cb, void *cb_arg),
{ 0);
return 0;
}
int DEFINE_STUB(spdk_bdev_nvme_io_passthru, int,
spdk_bdev_nvme_io_passthru(struct spdk_bdev_desc *desc, (struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
struct spdk_io_channel *ch, const struct spdk_nvme_cmd *cmd, void *buf, size_t nbytes,
const struct spdk_nvme_cmd *cmd, spdk_bdev_io_completion_cb cb, void *cb_arg),
void *buf, size_t nbytes, 0);
spdk_bdev_io_completion_cb cb, void *cb_arg)
{
return 0;
}
void spdk_bdev_free_io(struct spdk_bdev_io *bdev_io) DEFINE_STUB_V(spdk_bdev_free_io, (struct spdk_bdev_io *bdev_io));
{
}
const char *spdk_nvmf_subsystem_get_nqn(struct spdk_nvmf_subsystem *subsystem) DEFINE_STUB(spdk_nvmf_subsystem_get_nqn, const char *,
{ (struct spdk_nvmf_subsystem *subsystem), NULL);
return NULL;
}
struct spdk_nvmf_ns * struct spdk_nvmf_ns *
spdk_nvmf_subsystem_get_ns(struct spdk_nvmf_subsystem *subsystem, uint32_t nsid) spdk_nvmf_subsystem_get_ns(struct spdk_nvmf_subsystem *subsystem, uint32_t nsid)
@ -189,9 +152,8 @@ spdk_nvmf_subsystem_get_next_ns(struct spdk_nvmf_subsystem *subsystem, struct sp
return NULL; return NULL;
} }
void spdk_bdev_io_get_nvme_status(const struct spdk_bdev_io *bdev_io, int *sct, int *sc) DEFINE_STUB_V(spdk_bdev_io_get_nvme_status,
{ (const struct spdk_bdev_io *bdev_io, int *sct, int *sc));
}
static void static void
test_get_rw_params(void) test_get_rw_params(void)