From 281a7c2a157ec1a285fff2ef55a8f39251e308be Mon Sep 17 00:00:00 2001 From: Jiewei Ke Date: Tue, 13 Jul 2021 22:11:16 -0400 Subject: [PATCH] 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 Change-Id: I077b41f812266248c39fdbdb8cdff352d3b4cb74 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8767 Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Aleksey Marchuk Community-CI: Broadcom CI Community-CI: Mellanox Build Bot --- test/unit/lib/nvmf/subsystem.c/subsystem_ut.c | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/unit/lib/nvmf/subsystem.c/subsystem_ut.c b/test/unit/lib/nvmf/subsystem.c/subsystem_ut.c index 229a6331f..bc396be11 100644 --- a/test/unit/lib/nvmf/subsystem.c/subsystem_ut.c +++ b/test/unit/lib/nvmf/subsystem.c/subsystem_ut.c @@ -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); }