test/nvme_dp: return failure correctly when test it in CI
We will skip the test case if the drive didn't report such capability, this isn't treated as an error case. For vagrant environment, the namespace size is set to 1GiB or 2GiB, so here we also change the test LBA start from 0. Also use printf instead of fprintf for normal exit. Change-Id: Ib9f845ae548452921564aafebd2b23da6310b071 Signed-off-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2768 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
8cad1a9d15
commit
d3e9384c5a
@ -144,11 +144,9 @@ static uint32_t dp_guard_check_extended_lba_test(struct spdk_nvme_ns *ns, struct
|
||||
md_size = spdk_nvme_ns_get_md_size(ns);
|
||||
req->contig = spdk_zmalloc((sector_size + md_size) * req->lba_count, 0x1000, NULL,
|
||||
SPDK_ENV_LCORE_ID_ANY, SPDK_MALLOC_DMA);
|
||||
if (!req->contig) {
|
||||
return 0;
|
||||
}
|
||||
assert(req->contig);
|
||||
|
||||
req->lba = VALUE_2MB;
|
||||
req->lba = 0;
|
||||
req->use_extended_lba = true;
|
||||
req->use_sgl = true;
|
||||
req->buf_size = (sector_size + md_size) * req->lba_count;
|
||||
@ -188,15 +186,11 @@ static uint32_t dp_with_pract_test(struct spdk_nvme_ns *ns, struct io_request *r
|
||||
}
|
||||
req->contig = spdk_zmalloc(data_len, 0x1000, NULL, SPDK_ENV_LCORE_ID_ANY,
|
||||
SPDK_MALLOC_DMA);
|
||||
if (!req->contig) {
|
||||
return 0;
|
||||
}
|
||||
assert(req->contig);
|
||||
|
||||
req->metadata = spdk_zmalloc(md_size * req->lba_count, 0x1000, NULL, SPDK_ENV_LCORE_ID_ANY,
|
||||
SPDK_MALLOC_DMA);
|
||||
if (!req->metadata) {
|
||||
spdk_free(req->contig);
|
||||
return 0;
|
||||
}
|
||||
assert(req->metadata);
|
||||
|
||||
switch (spdk_nvme_ns_get_pi_type(ns)) {
|
||||
case SPDK_NVME_FMT_NVM_PROTECTION_TYPE3:
|
||||
@ -212,7 +206,7 @@ static uint32_t dp_with_pract_test(struct spdk_nvme_ns *ns, struct io_request *r
|
||||
break;
|
||||
}
|
||||
|
||||
req->lba = 0x100000;
|
||||
req->lba = 0;
|
||||
req->use_extended_lba = false;
|
||||
|
||||
return req->lba_count;
|
||||
@ -243,11 +237,9 @@ static uint32_t dp_without_pract_extended_lba_test(struct spdk_nvme_ns *ns, stru
|
||||
md_size = spdk_nvme_ns_get_md_size(ns);
|
||||
req->contig = spdk_zmalloc((sector_size + md_size) * req->lba_count, 0x1000, NULL,
|
||||
SPDK_ENV_LCORE_ID_ANY, SPDK_MALLOC_DMA);
|
||||
if (!req->contig) {
|
||||
return 0;
|
||||
}
|
||||
assert(req->contig);
|
||||
|
||||
req->lba = VALUE_2MB;
|
||||
req->lba = 0;
|
||||
req->use_extended_lba = true;
|
||||
req->metadata = NULL;
|
||||
pi = (struct spdk_nvme_protection_info *)(req->contig + sector_size + md_size - 8);
|
||||
@ -280,11 +272,9 @@ static uint32_t dp_without_flags_extended_lba_test(struct spdk_nvme_ns *ns, stru
|
||||
md_size = spdk_nvme_ns_get_md_size(ns);
|
||||
req->contig = spdk_zmalloc((sector_size + md_size) * req->lba_count, 0x1000, NULL,
|
||||
SPDK_ENV_LCORE_ID_ANY, SPDK_MALLOC_DMA);
|
||||
if (!req->contig) {
|
||||
return 0;
|
||||
}
|
||||
assert(req->contig);
|
||||
|
||||
req->lba = 0x400000;
|
||||
req->lba = 0;
|
||||
req->use_extended_lba = true;
|
||||
req->metadata = NULL;
|
||||
*io_flags = 0;
|
||||
@ -317,18 +307,13 @@ static uint32_t dp_without_pract_separate_meta_test(struct spdk_nvme_ns *ns, str
|
||||
md_size = spdk_nvme_ns_get_md_size(ns);
|
||||
req->contig = spdk_zmalloc(sector_size * req->lba_count, 0x1000, NULL, SPDK_ENV_LCORE_ID_ANY,
|
||||
SPDK_MALLOC_DMA);
|
||||
if (!req->contig) {
|
||||
return 0;
|
||||
}
|
||||
assert(req->contig);
|
||||
|
||||
req->metadata = spdk_zmalloc(md_size * req->lba_count, 0x1000, NULL, SPDK_ENV_LCORE_ID_ANY,
|
||||
SPDK_MALLOC_DMA);
|
||||
if (!req->metadata) {
|
||||
spdk_free(req->contig);
|
||||
return 0;
|
||||
}
|
||||
assert(req->metadata);
|
||||
|
||||
req->lba = 0x400000;
|
||||
req->lba = 0;
|
||||
req->use_extended_lba = false;
|
||||
|
||||
/* last 8 bytes if the metadata size bigger than 8 */
|
||||
@ -364,18 +349,13 @@ static uint32_t dp_without_pract_separate_meta_apptag_test(struct spdk_nvme_ns *
|
||||
md_size = spdk_nvme_ns_get_md_size(ns);
|
||||
req->contig = spdk_zmalloc(sector_size * req->lba_count, 0x1000, NULL, SPDK_ENV_LCORE_ID_ANY,
|
||||
SPDK_MALLOC_DMA);
|
||||
if (!req->contig) {
|
||||
return 0;
|
||||
}
|
||||
assert(req->contig);
|
||||
|
||||
req->metadata = spdk_zmalloc(md_size * req->lba_count, 0x1000, NULL, SPDK_ENV_LCORE_ID_ANY,
|
||||
SPDK_MALLOC_DMA);
|
||||
if (!req->metadata) {
|
||||
spdk_free(req->contig);
|
||||
return 0;
|
||||
}
|
||||
assert(req->metadata);
|
||||
|
||||
req->lba = 0x500000;
|
||||
req->lba = 0;
|
||||
req->use_extended_lba = false;
|
||||
req->apptag_mask = 0xFFFF;
|
||||
req->apptag = req->lba_count;
|
||||
@ -409,18 +389,13 @@ static uint32_t dp_without_flags_separate_meta_test(struct spdk_nvme_ns *ns, str
|
||||
md_size = spdk_nvme_ns_get_md_size(ns);
|
||||
req->contig = spdk_zmalloc(sector_size * req->lba_count, 0x1000, NULL, SPDK_ENV_LCORE_ID_ANY,
|
||||
SPDK_MALLOC_DMA);
|
||||
if (!req->contig) {
|
||||
return 0;
|
||||
}
|
||||
assert(req->contig);
|
||||
|
||||
req->metadata = spdk_zmalloc(md_size * req->lba_count, 0x1000, NULL, SPDK_ENV_LCORE_ID_ANY,
|
||||
SPDK_MALLOC_DMA);
|
||||
if (!req->metadata) {
|
||||
spdk_free(req->contig);
|
||||
return 0;
|
||||
}
|
||||
assert(req->metadata);
|
||||
|
||||
req->lba = 0x600000;
|
||||
req->lba = 0;
|
||||
req->use_extended_lba = false;
|
||||
*io_flags = 0;
|
||||
|
||||
@ -490,7 +465,7 @@ write_read_e2e_dp_tests(struct dev *dev, nvme_build_io_req_fn_t build_io_fn, con
|
||||
|
||||
ns = spdk_nvme_ctrlr_get_ns(dev->ctrlr, 1);
|
||||
if (!ns) {
|
||||
fprintf(stderr, "Null namespace\n");
|
||||
printf("Null namespace\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -501,20 +476,16 @@ write_read_e2e_dp_tests(struct dev *dev, nvme_build_io_req_fn_t build_io_fn, con
|
||||
nsdata = spdk_nvme_ns_get_data(ns);
|
||||
if (!nsdata || !spdk_nvme_ns_get_sector_size(ns)) {
|
||||
fprintf(stderr, "Empty nsdata or wrong sector size\n");
|
||||
return 0;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
req = spdk_zmalloc(sizeof(*req), 0, NULL, SPDK_ENV_LCORE_ID_ANY, SPDK_MALLOC_DMA);
|
||||
if (!req) {
|
||||
fprintf(stderr, "Allocate request failed\n");
|
||||
return 0;
|
||||
}
|
||||
assert(req);
|
||||
|
||||
/* IO parameters setting */
|
||||
lba_count = build_io_fn(ns, req, &io_flags);
|
||||
|
||||
if (!lba_count) {
|
||||
fprintf(stderr, "%s: %s bypass the test case\n", dev->name, test_name);
|
||||
printf("%s: %s bypass the test case\n", dev->name, test_name);
|
||||
free_req(req);
|
||||
return 0;
|
||||
}
|
||||
@ -599,10 +570,10 @@ write_read_e2e_dp_tests(struct dev *dev, nvme_build_io_req_fn_t build_io_fn, con
|
||||
return -1;
|
||||
}
|
||||
|
||||
fprintf(stdout, "%s: %s test passed\n", dev->name, test_name);
|
||||
printf("%s: %s test passed\n", dev->name, test_name);
|
||||
spdk_nvme_ctrlr_free_io_qpair(qpair);
|
||||
free_req(req);
|
||||
return rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool
|
||||
|
Loading…
Reference in New Issue
Block a user