test/nvmf/transport: cases for creating polling group
Also make stub for spdk_mempool_get_bulk consistent with DPDK APIs. Change-Id: I021378ea92651d75a73cc9f447df57c2f71680fa Signed-off-by: Mao Jiang <maox.jiang@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9356 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Community-CI: Mellanox Build Bot Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
88b2d4e6b4
commit
c17c7b9564
@ -368,6 +368,12 @@ spdk_mempool_get(struct spdk_mempool *_mp)
|
||||
int
|
||||
spdk_mempool_get_bulk(struct spdk_mempool *mp, void **ele_arr, size_t count)
|
||||
{
|
||||
struct test_mempool *test_mp = (struct test_mempool *)mp;
|
||||
|
||||
if (test_mp && test_mp->count < count) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
ele_arr[i] = spdk_mempool_get(mp);
|
||||
if (ele_arr[i] == NULL) {
|
||||
|
@ -40,6 +40,7 @@
|
||||
SPDK_LOG_REGISTER_COMPONENT(nvmf)
|
||||
|
||||
#define RDMA_UT_UNITS_IN_MAX_IO 16
|
||||
#define SPDK_NVMF_DEFAULT_BUFFER_CACHE_SIZE 32
|
||||
|
||||
struct spdk_nvmf_transport_opts g_rdma_ut_transport_opts = {
|
||||
.max_queue_depth = SPDK_NVMF_RDMA_DEFAULT_MAX_QUEUE_DEPTH,
|
||||
@ -174,6 +175,57 @@ test_spdk_nvmf_transport_create(void)
|
||||
MOCK_CLEAR(ut_transport_create);
|
||||
}
|
||||
|
||||
static struct spdk_nvmf_transport_poll_group *
|
||||
ut_poll_group_create(struct spdk_nvmf_transport *transport)
|
||||
{
|
||||
struct spdk_nvmf_transport_poll_group *group;
|
||||
|
||||
group = calloc(1, sizeof(*group));
|
||||
SPDK_CU_ASSERT_FATAL(group != NULL);
|
||||
return group;
|
||||
}
|
||||
|
||||
static void
|
||||
ut_poll_group_destroy(struct spdk_nvmf_transport_poll_group *group)
|
||||
{
|
||||
free(group);
|
||||
}
|
||||
|
||||
static void
|
||||
test_nvmf_transport_poll_group_create(void)
|
||||
{
|
||||
struct spdk_nvmf_transport_poll_group *poll_group = NULL;
|
||||
struct spdk_nvmf_transport transport = {};
|
||||
struct spdk_nvmf_transport_ops ops = {};
|
||||
|
||||
ops.poll_group_create = ut_poll_group_create;
|
||||
ops.poll_group_destroy = ut_poll_group_destroy;
|
||||
transport.ops = &ops;
|
||||
transport.opts.buf_cache_size = SPDK_NVMF_DEFAULT_BUFFER_CACHE_SIZE;
|
||||
transport.data_buf_pool = spdk_mempool_create("buf_pool", 32, 4096, 0, 0);
|
||||
|
||||
poll_group = nvmf_transport_poll_group_create(&transport);
|
||||
SPDK_CU_ASSERT_FATAL(poll_group != NULL);
|
||||
CU_ASSERT(poll_group->transport == &transport);
|
||||
CU_ASSERT(poll_group->buf_cache_size == SPDK_NVMF_DEFAULT_BUFFER_CACHE_SIZE);
|
||||
CU_ASSERT(poll_group->buf_cache_count == SPDK_NVMF_DEFAULT_BUFFER_CACHE_SIZE);
|
||||
|
||||
nvmf_transport_poll_group_destroy(poll_group);
|
||||
spdk_mempool_free(transport.data_buf_pool);
|
||||
|
||||
/* Mempool members insufficient */
|
||||
transport.data_buf_pool = spdk_mempool_create("buf_pool", 31, 4096, 0, 0);
|
||||
|
||||
poll_group = nvmf_transport_poll_group_create(&transport);
|
||||
SPDK_CU_ASSERT_FATAL(poll_group != NULL);
|
||||
CU_ASSERT(poll_group->transport == &transport);
|
||||
CU_ASSERT(poll_group->buf_cache_size == 31);
|
||||
CU_ASSERT(poll_group->buf_cache_count == 31);
|
||||
|
||||
nvmf_transport_poll_group_destroy(poll_group);
|
||||
spdk_mempool_free(transport.data_buf_pool);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
CU_pSuite suite = NULL;
|
||||
@ -185,6 +237,7 @@ int main(int argc, char **argv)
|
||||
suite = CU_add_suite("nvmf", NULL, NULL);
|
||||
|
||||
CU_ADD_TEST(suite, test_spdk_nvmf_transport_create);
|
||||
CU_ADD_TEST(suite, test_nvmf_transport_poll_group_create);
|
||||
|
||||
CU_basic_set_mode(CU_BRM_VERBOSE);
|
||||
CU_basic_run_tests();
|
||||
|
Loading…
Reference in New Issue
Block a user