test/vfio-user: add delete_io_cq test case
Change-Id: Icf7f978d7083afdc729959328d985a660111e371 Signed-off-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9681 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
e91846d342
commit
0171f8c184
@ -418,6 +418,90 @@ delete_create_io_sq(void)
|
||||
spdk_nvme_detach(ctrlr);
|
||||
}
|
||||
|
||||
static void
|
||||
delete_io_cq(void)
|
||||
{
|
||||
struct spdk_nvme_ctrlr *ctrlr;
|
||||
struct spdk_nvme_io_qpair_opts opts;
|
||||
struct spdk_nvme_qpair *qpair;
|
||||
struct spdk_nvme_ns *ns;
|
||||
uint32_t nsid;
|
||||
struct spdk_nvme_cmd cmd;
|
||||
struct status s;
|
||||
void *buf;
|
||||
uint32_t nlbas;
|
||||
int rc;
|
||||
|
||||
SPDK_CU_ASSERT_FATAL(spdk_nvme_transport_id_parse(&g_trid, g_trid_str) == 0);
|
||||
ctrlr = spdk_nvme_connect(&g_trid, NULL, 0);
|
||||
SPDK_CU_ASSERT_FATAL(ctrlr);
|
||||
|
||||
spdk_nvme_ctrlr_get_default_io_qpair_opts(ctrlr, &opts, sizeof(opts));
|
||||
qpair = spdk_nvme_ctrlr_alloc_io_qpair(ctrlr, &opts, sizeof(opts));
|
||||
SPDK_CU_ASSERT_FATAL(qpair);
|
||||
|
||||
nsid = spdk_nvme_ctrlr_get_first_active_ns(ctrlr);
|
||||
ns = spdk_nvme_ctrlr_get_ns(ctrlr, nsid);
|
||||
SPDK_CU_ASSERT_FATAL(ns != NULL);
|
||||
|
||||
/* READ command should execute successfully. */
|
||||
nlbas = 1;
|
||||
buf = spdk_dma_zmalloc(nlbas * spdk_nvme_ns_get_sector_size(ns), 0x1000, NULL);
|
||||
SPDK_CU_ASSERT_FATAL(buf != NULL);
|
||||
s.done = false;
|
||||
rc = spdk_nvme_ns_cmd_read_with_md(ns, qpair, buf, NULL, 0, nlbas, test_cb, &s, 0, 0, 0);
|
||||
SPDK_CU_ASSERT_FATAL(rc == 0);
|
||||
|
||||
wait_for_io_completion(&s, qpair);
|
||||
|
||||
CU_ASSERT(s.cpl.status.sct == SPDK_NVME_SCT_GENERIC);
|
||||
CU_ASSERT(s.cpl.status.sc == SPDK_NVME_SC_SUCCESS);
|
||||
|
||||
/* Delete CQ 1, this is invalid. */
|
||||
memset(&cmd, 0, sizeof(cmd));
|
||||
cmd.opc = SPDK_NVME_OPC_DELETE_IO_CQ;
|
||||
cmd.cdw10_bits.delete_io_q.qid = 1;
|
||||
|
||||
s.done = false;
|
||||
rc = spdk_nvme_ctrlr_cmd_admin_raw(ctrlr, &cmd, NULL, 0, test_cb, &s);
|
||||
CU_ASSERT(rc == 0);
|
||||
|
||||
wait_for_admin_completion(&s, ctrlr);
|
||||
|
||||
CU_ASSERT(s.cpl.status.sct == SPDK_NVME_SCT_COMMAND_SPECIFIC);
|
||||
CU_ASSERT(s.cpl.status.sc == SPDK_NVME_SC_INVALID_QUEUE_DELETION);
|
||||
|
||||
/* Delete SQ 1, this is valid. */
|
||||
s.done = false;
|
||||
memset(&cmd, 0, sizeof(cmd));
|
||||
cmd.opc = SPDK_NVME_OPC_DELETE_IO_SQ;
|
||||
cmd.cdw10_bits.delete_io_q.qid = 1;
|
||||
rc = spdk_nvme_ctrlr_cmd_admin_raw(ctrlr, &cmd, NULL, 0, test_cb, &s);
|
||||
CU_ASSERT(rc == 0);
|
||||
|
||||
wait_for_admin_completion(&s, ctrlr);
|
||||
|
||||
CU_ASSERT(s.cpl.status.sct == SPDK_NVME_SCT_GENERIC);
|
||||
CU_ASSERT(s.cpl.status.sc == SPDK_NVME_SC_SUCCESS);
|
||||
|
||||
/* Delete CQ 1 again, this is valid */
|
||||
memset(&cmd, 0, sizeof(cmd));
|
||||
cmd.opc = SPDK_NVME_OPC_DELETE_IO_CQ;
|
||||
cmd.cdw10_bits.delete_io_q.qid = 1;
|
||||
|
||||
s.done = false;
|
||||
rc = spdk_nvme_ctrlr_cmd_admin_raw(ctrlr, &cmd, NULL, 0, test_cb, &s);
|
||||
CU_ASSERT(rc == 0);
|
||||
|
||||
wait_for_admin_completion(&s, ctrlr);
|
||||
|
||||
CU_ASSERT(s.cpl.status.sct == SPDK_NVME_SCT_GENERIC);
|
||||
CU_ASSERT(s.cpl.status.sc == SPDK_NVME_SC_SUCCESS);
|
||||
|
||||
spdk_dma_free(buf);
|
||||
spdk_nvme_detach(ctrlr);
|
||||
}
|
||||
|
||||
static int
|
||||
parse_args(int argc, char **argv, struct spdk_env_opts *opts)
|
||||
{
|
||||
@ -473,6 +557,7 @@ int main(int argc, char **argv)
|
||||
CU_ADD_TEST(suite, delete_admin_queue);
|
||||
CU_ADD_TEST(suite, delete_io_sq_twice);
|
||||
CU_ADD_TEST(suite, delete_create_io_sq);
|
||||
CU_ADD_TEST(suite, delete_io_cq);
|
||||
|
||||
CU_basic_set_mode(CU_BRM_VERBOSE);
|
||||
CU_basic_run_tests();
|
||||
|
Loading…
Reference in New Issue
Block a user