test/nvmf/subsystem: cases for subsystem ctrlr adding and removing
Change-Id: I831192e7938a21e2a959af6b5b6d3a41fc31e26f Signed-off-by: Mao Jiang <maox.jiang@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8513 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com> Reviewed-by: Ziye Yang <ziye.yang@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
parent
2e6fb86176
commit
741c7985fb
@ -1387,6 +1387,35 @@ test_nvmf_ns_reservation_add_remove_registrant(void)
|
||||
CU_ASSERT(ns.gen == 2);
|
||||
}
|
||||
|
||||
static void
|
||||
test_nvmf_subsystem_add_ctrlr(void)
|
||||
{
|
||||
int rc;
|
||||
struct spdk_nvmf_ctrlr ctrlr = {};
|
||||
struct spdk_nvmf_tgt tgt = {};
|
||||
char nqn[256] = "nqn.2016-06.io.spdk:subsystem1";
|
||||
struct spdk_nvmf_subsystem *subsystem = NULL;
|
||||
|
||||
tgt.max_subsystems = 1024;
|
||||
tgt.subsystems = calloc(tgt.max_subsystems, sizeof(struct spdk_nvmf_subsystem *));
|
||||
SPDK_CU_ASSERT_FATAL(tgt.subsystems != NULL);
|
||||
|
||||
subsystem = spdk_nvmf_subsystem_create(&tgt, nqn, SPDK_NVMF_SUBTYPE_NVME, 0);
|
||||
SPDK_CU_ASSERT_FATAL(subsystem != NULL);
|
||||
ctrlr.subsys = subsystem;
|
||||
|
||||
rc = nvmf_subsystem_add_ctrlr(subsystem, &ctrlr);
|
||||
CU_ASSERT(rc == 0);
|
||||
CU_ASSERT(!TAILQ_EMPTY(&subsystem->ctrlrs));
|
||||
CU_ASSERT(ctrlr.cntlid == 1);
|
||||
CU_ASSERT(nvmf_subsystem_get_ctrlr(subsystem, 1) == &ctrlr);
|
||||
|
||||
nvmf_subsystem_remove_ctrlr(subsystem, &ctrlr);
|
||||
CU_ASSERT(TAILQ_EMPTY(&subsystem->ctrlrs));
|
||||
spdk_nvmf_subsystem_destroy(subsystem);
|
||||
free(tgt.subsystems);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
CU_pSuite suite = NULL;
|
||||
@ -1412,6 +1441,7 @@ int main(int argc, char **argv)
|
||||
CU_ADD_TEST(suite, test_reservation_preempt_notification);
|
||||
CU_ADD_TEST(suite, test_spdk_nvmf_ns_event);
|
||||
CU_ADD_TEST(suite, test_nvmf_ns_reservation_add_remove_registrant);
|
||||
CU_ADD_TEST(suite, test_nvmf_subsystem_add_ctrlr);
|
||||
|
||||
allocate_threads(1);
|
||||
set_thread(0);
|
||||
|
Loading…
Reference in New Issue
Block a user