ut/nvme: add coverage for nvme_allocate_request_null()
Change-Id: I39757052a7458ff1520b2cc13face2db1fafbf75 Signed-off-by: Paul Luse <paul.e.luse@intel.com> Reviewed-on: https://review.gerrithub.io/372542 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
198c373264
commit
84b2933ff5
@ -108,6 +108,38 @@ memset_trid(struct spdk_nvme_transport_id *trid1, struct spdk_nvme_transport_id
|
||||
memset(trid2, 0, sizeof(struct spdk_nvme_transport_id));
|
||||
}
|
||||
|
||||
static void
|
||||
test_nvme_allocate_request_null(void)
|
||||
{
|
||||
struct spdk_nvme_qpair qpair;
|
||||
spdk_nvme_cmd_cb cb_fn = (spdk_nvme_cmd_cb)0x1234;
|
||||
void *cb_arg = (void *)0x5678;
|
||||
struct nvme_request *req = NULL;
|
||||
struct nvme_request dummy_req;
|
||||
|
||||
STAILQ_INIT(&qpair.free_req);
|
||||
STAILQ_INIT(&qpair.queued_req);
|
||||
|
||||
/*
|
||||
* Put a dummy on the queue so we can make a request
|
||||
* and confirm that what comes back is what we expect.
|
||||
*/
|
||||
STAILQ_INSERT_HEAD(&qpair.free_req, &dummy_req, stailq);
|
||||
|
||||
req = nvme_allocate_request_null(&qpair, cb_fn, cb_arg);
|
||||
|
||||
/*
|
||||
* Compare the req with the parmaters that we passed in
|
||||
* as well as what the function is supposed to update.
|
||||
*/
|
||||
CU_ASSERT(req->cb_fn == cb_fn);
|
||||
CU_ASSERT(req->cb_arg == cb_arg);
|
||||
CU_ASSERT(req->pid == getpid());
|
||||
CU_ASSERT(req->payload.type == NVME_PAYLOAD_TYPE_CONTIG);
|
||||
CU_ASSERT(req->payload.md == NULL);
|
||||
CU_ASSERT(req->payload.u.contig == NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
test_nvme_allocate_request(void)
|
||||
{
|
||||
@ -576,6 +608,8 @@ int main(int argc, char **argv)
|
||||
test_trid_adrfam_str) == NULL ||
|
||||
CU_add_test(suite, "test_nvme_ctrlr_probe",
|
||||
test_nvme_ctrlr_probe) == NULL ||
|
||||
CU_add_test(suite, "test_nvme_allocate_request_null",
|
||||
test_nvme_allocate_request_null) == NULL ||
|
||||
CU_add_test(suite, "test_nvme_allocate_request",
|
||||
test_nvme_allocate_request) == NULL ||
|
||||
CU_add_test(suite, "test_nvme_free_request",
|
||||
|
Loading…
x
Reference in New Issue
Block a user