test/nvmf: add local var for hostnqn string

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ia967512bfcc5d7b1df15b6f6b5c132f21d601dce
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10563
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Dong Yi <dongx.yi@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
Jim Harris 2021-12-04 01:25:30 +00:00
parent 9ac2cf7ff0
commit 3867f83dea

View File

@ -300,6 +300,7 @@ test_discovery_log(void)
struct spdk_nvmf_discovery_log_page *disc_log;
struct spdk_nvmf_discovery_log_page_entry *entry;
struct spdk_nvme_transport_id trid = {};
const char *hostnqn = "nqn.2016-06.io.spdk:host1";
int rc;
iov.iov_base = buffer;
@ -322,14 +323,14 @@ test_discovery_log(void)
/* Get only genctr (first field in the header) */
memset(buffer, 0xCC, sizeof(buffer));
disc_log = (struct spdk_nvmf_discovery_log_page *)buffer;
nvmf_get_discovery_log_page(&tgt, "nqn.2016-06.io.spdk:host1", &iov, 1, 0, sizeof(disc_log->genctr),
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0, sizeof(disc_log->genctr),
&trid);
CU_ASSERT(disc_log->genctr == 1); /* one added subsystem and listener */
/* Get only the header, no entries */
memset(buffer, 0xCC, sizeof(buffer));
disc_log = (struct spdk_nvmf_discovery_log_page *)buffer;
nvmf_get_discovery_log_page(&tgt, "nqn.2016-06.io.spdk:host1", &iov, 1, 0, sizeof(*disc_log),
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0, sizeof(*disc_log),
&trid);
CU_ASSERT(disc_log->genctr == 1);
CU_ASSERT(disc_log->numrec == 1);
@ -337,7 +338,7 @@ test_discovery_log(void)
/* Offset 0, exact size match */
memset(buffer, 0xCC, sizeof(buffer));
disc_log = (struct spdk_nvmf_discovery_log_page *)buffer;
nvmf_get_discovery_log_page(&tgt, "nqn.2016-06.io.spdk:host1", &iov, 1, 0,
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0,
sizeof(*disc_log) + sizeof(disc_log->entries[0]), &trid);
CU_ASSERT(disc_log->genctr != 0);
CU_ASSERT(disc_log->numrec == 1);
@ -346,7 +347,7 @@ test_discovery_log(void)
/* Offset 0, oversize buffer */
memset(buffer, 0xCC, sizeof(buffer));
disc_log = (struct spdk_nvmf_discovery_log_page *)buffer;
nvmf_get_discovery_log_page(&tgt, "nqn.2016-06.io.spdk:host1", &iov, 1, 0, sizeof(buffer), &trid);
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0, sizeof(buffer), &trid);
CU_ASSERT(disc_log->genctr != 0);
CU_ASSERT(disc_log->numrec == 1);
CU_ASSERT(disc_log->entries[0].trtype == 42);
@ -356,7 +357,7 @@ test_discovery_log(void)
/* Get just the first entry, no header */
memset(buffer, 0xCC, sizeof(buffer));
entry = (struct spdk_nvmf_discovery_log_page_entry *)buffer;
nvmf_get_discovery_log_page(&tgt, "nqn.2016-06.io.spdk:host1", &iov, 1,
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1,
offsetof(struct spdk_nvmf_discovery_log_page, entries[0]), sizeof(*entry), &trid);
CU_ASSERT(entry->trtype == 42);
subsystem->state = SPDK_NVMF_SUBSYSTEM_INACTIVE;
@ -393,6 +394,7 @@ test_discovery_log_with_filters(void)
= { .listener_discover = test_tcp_discover };
struct spdk_nvmf_transport rdma_tr = {.ops = &rdma_tr_ops }, tcp_tr = { .ops = &tcp_tr_ops };
struct spdk_nvmf_subsystem *subsystem;
const char *hostnqn = "nqn.2016-06.io.spdk:host1";
uint8_t buffer[8192];
struct iovec iov;
struct spdk_nvmf_discovery_log_page *disc_log;
@ -453,18 +455,18 @@ test_discovery_log_with_filters(void)
/* Test case 1 - check that all trids are reported */
tgt.discovery_filter = SPDK_NVMF_TGT_DISCOVERY_MATCH_ANY;
nvmf_get_discovery_log_page(&tgt, "nqn.2016-06.io.spdk:host1", &iov, 1, 0, 8192, &rdma_trid_1);
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0, 8192, &rdma_trid_1);
CU_ASSERT(disc_log->numrec == 6);
/* Test case 2 - check that only entries of the same transport type are returned */
tgt.discovery_filter = SPDK_NVMF_TGT_DISCOVERY_MATCH_TRANSPORT_TYPE;
nvmf_get_discovery_log_page(&tgt, "nqn.2016-06.io.spdk:host1", &iov, 1, 0, 8192, &rdma_trid_1);
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0, 8192, &rdma_trid_1);
CU_ASSERT(disc_log->numrec == 3);
CU_ASSERT(disc_log->entries[0].trtype == rdma_trid_1.trtype);
CU_ASSERT(disc_log->entries[1].trtype == rdma_trid_1.trtype);
CU_ASSERT(disc_log->entries[2].trtype == rdma_trid_1.trtype);
nvmf_get_discovery_log_page(&tgt, "nqn.2016-06.io.spdk:host1", &iov, 1, 0, 8192, &tcp_trid_1);
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0, 8192, &tcp_trid_1);
CU_ASSERT(disc_log->numrec == 3);
CU_ASSERT(disc_log->entries[0].trtype == tcp_trid_1.trtype);
CU_ASSERT(disc_log->entries[1].trtype == tcp_trid_1.trtype);
@ -472,7 +474,7 @@ test_discovery_log_with_filters(void)
/* Test case 3 - check that only entries of the same transport address are returned */
tgt.discovery_filter = SPDK_NVMF_TGT_DISCOVERY_MATCH_TRANSPORT_ADDRESS;
nvmf_get_discovery_log_page(&tgt, "nqn.2016-06.io.spdk:host1", &iov, 1, 0, 8192, &rdma_trid_1);
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0, 8192, &rdma_trid_1);
CU_ASSERT(disc_log->numrec == 3);
/* one tcp and 2 rdma */
CU_ASSERT((disc_log->entries[0].trtype ^ disc_log->entries[1].trtype ^ disc_log->entries[2].trtype)
@ -481,7 +483,7 @@ test_discovery_log_with_filters(void)
CU_ASSERT(strcasecmp(disc_log->entries[1].traddr, rdma_trid_1.traddr) == 0);
CU_ASSERT(strcasecmp(disc_log->entries[2].traddr, rdma_trid_1.traddr) == 0);
nvmf_get_discovery_log_page(&tgt, "nqn.2016-06.io.spdk:host1", &iov, 1, 0, 8192, &tcp_trid_1);
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0, 8192, &tcp_trid_1);
CU_ASSERT(disc_log->numrec == 3);
/* one rdma and two tcp */
CU_ASSERT((disc_log->entries[0].trtype ^ disc_log->entries[1].trtype ^ disc_log->entries[2].trtype)
@ -493,26 +495,26 @@ test_discovery_log_with_filters(void)
/* Test case 4 - check that only entries of the same transport address and type returned */
tgt.discovery_filter = SPDK_NVMF_TGT_DISCOVERY_MATCH_TRANSPORT_TYPE |
SPDK_NVMF_TGT_DISCOVERY_MATCH_TRANSPORT_ADDRESS;
nvmf_get_discovery_log_page(&tgt, "nqn.2016-06.io.spdk:host1", &iov, 1, 0, 8192, &rdma_trid_1);
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0, 8192, &rdma_trid_1);
CU_ASSERT(disc_log->numrec == 2);
CU_ASSERT(strcasecmp(disc_log->entries[0].traddr, rdma_trid_1.traddr) == 0);
CU_ASSERT(strcasecmp(disc_log->entries[1].traddr, rdma_trid_1.traddr) == 0);
CU_ASSERT(disc_log->entries[0].trtype == rdma_trid_1.trtype);
CU_ASSERT(disc_log->entries[1].trtype == rdma_trid_1.trtype);
nvmf_get_discovery_log_page(&tgt, "nqn.2016-06.io.spdk:host1", &iov, 1, 0, 8192, &rdma_trid_2);
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0, 8192, &rdma_trid_2);
CU_ASSERT(disc_log->numrec == 1);
CU_ASSERT(strcasecmp(disc_log->entries[0].traddr, rdma_trid_2.traddr) == 0);
CU_ASSERT(disc_log->entries[0].trtype == rdma_trid_2.trtype);
nvmf_get_discovery_log_page(&tgt, "nqn.2016-06.io.spdk:host1", &iov, 1, 0, 8192, &tcp_trid_1);
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0, 8192, &tcp_trid_1);
CU_ASSERT(disc_log->numrec == 2);
CU_ASSERT(strcasecmp(disc_log->entries[0].traddr, tcp_trid_1.traddr) == 0);
CU_ASSERT(strcasecmp(disc_log->entries[1].traddr, tcp_trid_1.traddr) == 0);
CU_ASSERT(disc_log->entries[0].trtype == tcp_trid_1.trtype);
CU_ASSERT(disc_log->entries[1].trtype == tcp_trid_1.trtype);
nvmf_get_discovery_log_page(&tgt, "nqn.2016-06.io.spdk:host1", &iov, 1, 0, 8192, &rdma_trid_2);
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0, 8192, &rdma_trid_2);
CU_ASSERT(disc_log->numrec == 1);
CU_ASSERT(strcasecmp(disc_log->entries[0].traddr, rdma_trid_2.traddr) == 0);
CU_ASSERT(disc_log->entries[0].trtype == rdma_trid_2.trtype);
@ -520,24 +522,24 @@ test_discovery_log_with_filters(void)
/* Test case 5 - check that only entries of the same transport address and type returned */
tgt.discovery_filter = SPDK_NVMF_TGT_DISCOVERY_MATCH_TRANSPORT_TYPE |
SPDK_NVMF_TGT_DISCOVERY_MATCH_TRANSPORT_SVCID;
nvmf_get_discovery_log_page(&tgt, "nqn.2016-06.io.spdk:host1", &iov, 1, 0, 8192, &rdma_trid_1);
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0, 8192, &rdma_trid_1);
CU_ASSERT(disc_log->numrec == 2);
CU_ASSERT(strcasecmp(disc_log->entries[0].trsvcid, rdma_trid_1.trsvcid) == 0);
CU_ASSERT(strcasecmp(disc_log->entries[1].trsvcid, rdma_trid_2.trsvcid) == 0);
CU_ASSERT(disc_log->entries[0].trtype == rdma_trid_1.trtype);
CU_ASSERT(disc_log->entries[1].trtype == rdma_trid_2.trtype);
nvmf_get_discovery_log_page(&tgt, "nqn.2016-06.io.spdk:host1", &iov, 1, 0, 8192, &rdma_trid_3);
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0, 8192, &rdma_trid_3);
CU_ASSERT(disc_log->numrec == 1);
CU_ASSERT(strcasecmp(disc_log->entries[0].trsvcid, rdma_trid_3.trsvcid) == 0);
CU_ASSERT(disc_log->entries[0].trtype == rdma_trid_3.trtype);
nvmf_get_discovery_log_page(&tgt, "nqn.2016-06.io.spdk:host1", &iov, 1, 0, 8192, &tcp_trid_1);
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0, 8192, &tcp_trid_1);
CU_ASSERT(disc_log->numrec == 1);
CU_ASSERT(strcasecmp(disc_log->entries[0].trsvcid, tcp_trid_1.trsvcid) == 0);
CU_ASSERT(disc_log->entries[0].trtype == tcp_trid_1.trtype);
nvmf_get_discovery_log_page(&tgt, "nqn.2016-06.io.spdk:host1", &iov, 1, 0, 8192, &tcp_trid_2);
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0, 8192, &tcp_trid_2);
CU_ASSERT(disc_log->numrec == 2);
CU_ASSERT(strcasecmp(disc_log->entries[0].trsvcid, tcp_trid_2.trsvcid) == 0);
CU_ASSERT(strcasecmp(disc_log->entries[1].trsvcid, tcp_trid_2.trsvcid) == 0);
@ -548,37 +550,37 @@ test_discovery_log_with_filters(void)
* That also implies trtype since RDMA and TCP listeners can't occupy the same socket */
tgt.discovery_filter = SPDK_NVMF_TGT_DISCOVERY_MATCH_TRANSPORT_ADDRESS |
SPDK_NVMF_TGT_DISCOVERY_MATCH_TRANSPORT_SVCID;
nvmf_get_discovery_log_page(&tgt, "nqn.2016-06.io.spdk:host1", &iov, 1, 0, 8192, &rdma_trid_1);
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0, 8192, &rdma_trid_1);
CU_ASSERT(disc_log->numrec == 1);
CU_ASSERT(strcasecmp(disc_log->entries[0].traddr, rdma_trid_1.traddr) == 0);
CU_ASSERT(strcasecmp(disc_log->entries[0].trsvcid, rdma_trid_1.trsvcid) == 0);
CU_ASSERT(disc_log->entries[0].trtype == rdma_trid_1.trtype);
nvmf_get_discovery_log_page(&tgt, "nqn.2016-06.io.spdk:host1", &iov, 1, 0, 8192, &rdma_trid_2);
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0, 8192, &rdma_trid_2);
CU_ASSERT(disc_log->numrec == 1);
CU_ASSERT(strcasecmp(disc_log->entries[0].traddr, rdma_trid_2.traddr) == 0);
CU_ASSERT(strcasecmp(disc_log->entries[0].trsvcid, rdma_trid_2.trsvcid) == 0);
CU_ASSERT(disc_log->entries[0].trtype == rdma_trid_2.trtype);
nvmf_get_discovery_log_page(&tgt, "nqn.2016-06.io.spdk:host1", &iov, 1, 0, 8192, &rdma_trid_3);
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0, 8192, &rdma_trid_3);
CU_ASSERT(disc_log->numrec == 1);
CU_ASSERT(strcasecmp(disc_log->entries[0].traddr, rdma_trid_3.traddr) == 0);
CU_ASSERT(strcasecmp(disc_log->entries[0].trsvcid, rdma_trid_3.trsvcid) == 0);
CU_ASSERT(disc_log->entries[0].trtype == rdma_trid_3.trtype);
nvmf_get_discovery_log_page(&tgt, "nqn.2016-06.io.spdk:host1", &iov, 1, 0, 8192, &tcp_trid_1);
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0, 8192, &tcp_trid_1);
CU_ASSERT(disc_log->numrec == 1);
CU_ASSERT(strcasecmp(disc_log->entries[0].traddr, tcp_trid_1.traddr) == 0);
CU_ASSERT(strcasecmp(disc_log->entries[0].trsvcid, tcp_trid_1.trsvcid) == 0);
CU_ASSERT(disc_log->entries[0].trtype == tcp_trid_1.trtype);
nvmf_get_discovery_log_page(&tgt, "nqn.2016-06.io.spdk:host1", &iov, 1, 0, 8192, &tcp_trid_2);
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0, 8192, &tcp_trid_2);
CU_ASSERT(disc_log->numrec == 1);
CU_ASSERT(strcasecmp(disc_log->entries[0].traddr, tcp_trid_2.traddr) == 0);
CU_ASSERT(strcasecmp(disc_log->entries[0].trsvcid, tcp_trid_2.trsvcid) == 0);
CU_ASSERT(disc_log->entries[0].trtype == tcp_trid_2.trtype);
nvmf_get_discovery_log_page(&tgt, "nqn.2016-06.io.spdk:host1", &iov, 1, 0, 8192, &tcp_trid_3);
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0, 8192, &tcp_trid_3);
CU_ASSERT(disc_log->numrec == 1);
CU_ASSERT(strcasecmp(disc_log->entries[0].traddr, tcp_trid_3.traddr) == 0);
CU_ASSERT(strcasecmp(disc_log->entries[0].trsvcid, tcp_trid_3.trsvcid) == 0);
@ -588,37 +590,37 @@ test_discovery_log_with_filters(void)
tgt.discovery_filter = SPDK_NVMF_TGT_DISCOVERY_MATCH_TRANSPORT_TYPE |
SPDK_NVMF_TGT_DISCOVERY_MATCH_TRANSPORT_ADDRESS |
SPDK_NVMF_TGT_DISCOVERY_MATCH_TRANSPORT_SVCID;
nvmf_get_discovery_log_page(&tgt, "nqn.2016-06.io.spdk:host1", &iov, 1, 0, 8192, &rdma_trid_1);
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0, 8192, &rdma_trid_1);
CU_ASSERT(disc_log->numrec == 1);
CU_ASSERT(strcasecmp(disc_log->entries[0].traddr, rdma_trid_1.traddr) == 0);
CU_ASSERT(strcasecmp(disc_log->entries[0].trsvcid, rdma_trid_1.trsvcid) == 0);
CU_ASSERT(disc_log->entries[0].trtype == rdma_trid_1.trtype);
nvmf_get_discovery_log_page(&tgt, "nqn.2016-06.io.spdk:host1", &iov, 1, 0, 8192, &rdma_trid_2);
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0, 8192, &rdma_trid_2);
CU_ASSERT(disc_log->numrec == 1);
CU_ASSERT(strcasecmp(disc_log->entries[0].traddr, rdma_trid_2.traddr) == 0);
CU_ASSERT(strcasecmp(disc_log->entries[0].trsvcid, rdma_trid_2.trsvcid) == 0);
CU_ASSERT(disc_log->entries[0].trtype == rdma_trid_2.trtype);
nvmf_get_discovery_log_page(&tgt, "nqn.2016-06.io.spdk:host1", &iov, 1, 0, 8192, &rdma_trid_3);
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0, 8192, &rdma_trid_3);
CU_ASSERT(disc_log->numrec == 1);
CU_ASSERT(strcasecmp(disc_log->entries[0].traddr, rdma_trid_3.traddr) == 0);
CU_ASSERT(strcasecmp(disc_log->entries[0].trsvcid, rdma_trid_3.trsvcid) == 0);
CU_ASSERT(disc_log->entries[0].trtype == rdma_trid_3.trtype);
nvmf_get_discovery_log_page(&tgt, "nqn.2016-06.io.spdk:host1", &iov, 1, 0, 8192, &tcp_trid_1);
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0, 8192, &tcp_trid_1);
CU_ASSERT(disc_log->numrec == 1);
CU_ASSERT(strcasecmp(disc_log->entries[0].traddr, tcp_trid_1.traddr) == 0);
CU_ASSERT(strcasecmp(disc_log->entries[0].trsvcid, tcp_trid_1.trsvcid) == 0);
CU_ASSERT(disc_log->entries[0].trtype == tcp_trid_1.trtype);
nvmf_get_discovery_log_page(&tgt, "nqn.2016-06.io.spdk:host1", &iov, 1, 0, 8192, &tcp_trid_2);
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0, 8192, &tcp_trid_2);
CU_ASSERT(disc_log->numrec == 1);
CU_ASSERT(strcasecmp(disc_log->entries[0].traddr, tcp_trid_2.traddr) == 0);
CU_ASSERT(strcasecmp(disc_log->entries[0].trsvcid, tcp_trid_2.trsvcid) == 0);
CU_ASSERT(disc_log->entries[0].trtype == tcp_trid_2.trtype);
nvmf_get_discovery_log_page(&tgt, "nqn.2016-06.io.spdk:host1", &iov, 1, 0, 8192, &tcp_trid_3);
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0, 8192, &tcp_trid_3);
CU_ASSERT(disc_log->numrec == 1);
CU_ASSERT(strcasecmp(disc_log->entries[0].traddr, tcp_trid_3.traddr) == 0);
CU_ASSERT(strcasecmp(disc_log->entries[0].trsvcid, tcp_trid_3.trsvcid) == 0);