test/unit/lib/nvmf: register target io device for test_spdk_nvmf_ns_event

In test_spdk_nvmf_ns_event, when doing ns resize it will call
spdk_for_each_channel() to pause the subsystem. But it doesn't call
spdk_io_device_register() in advance. This is wrong and may run into
assertion with the coming change since the io_device is not found.

Signed-off-by: Jiewei Ke <jiewei@smartx.com>
Change-Id: I077b41f812266248c39fdbdb8cdff352d3b4cb74
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8767
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
This commit is contained in:
Jiewei Ke 2021-07-13 22:11:16 -04:00 committed by Tomasz Zawadzki
parent 49c6afbf12
commit 281a7c2a15

View File

@ -1296,6 +1296,17 @@ test_reservation_preempt_notification(void)
ut_reservation_deinit();
}
static int
nvmf_tgt_create_poll_group(void *io_device, void *ctx_buf)
{
return 0;
}
static void
nvmf_tgt_destroy_poll_group(void *io_device, void *ctx_buf)
{
}
static void
test_spdk_nvmf_ns_event(void)
{
@ -1319,6 +1330,12 @@ test_spdk_nvmf_ns_event(void)
tgt.subsystems = calloc(tgt.max_subsystems, sizeof(struct spdk_nvmf_subsystem *));
SPDK_CU_ASSERT_FATAL(tgt.subsystems != NULL);
spdk_io_device_register(&tgt,
nvmf_tgt_create_poll_group,
nvmf_tgt_destroy_poll_group,
sizeof(struct spdk_nvmf_poll_group),
NULL);
/* Add one namespace */
spdk_nvmf_ns_opts_get_defaults(&ns_opts, sizeof(ns_opts));
nsid = spdk_nvmf_subsystem_add_ns_ext(&subsystem, "bdev1", &ns_opts, sizeof(ns_opts), NULL);
@ -1359,6 +1376,10 @@ test_spdk_nvmf_ns_event(void)
CU_ASSERT(NULL == subsystem.ns[0]);
CU_ASSERT(SPDK_NVMF_SUBSYSTEM_ACTIVE == subsystem.state);
spdk_io_device_unregister(&tgt, NULL);
poll_threads();
free(subsystem.ns);
free(tgt.subsystems);
}