nvme: add the UT code for get_default_io_qpair_opts
The newly added UT code will exercise the cases that opts_size is smaller and equal to the current version of spdk_nvme_io_qpair_opts. This is for the backward compatibilty when SPDK components are built as the shared library later. Change-Id: Ic906d765f5b638070e3d9c8e38827577c625b679 Signed-off-by: GangCao <gang.cao@intel.com> Reviewed-on: https://review.gerrithub.io/380893 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>
This commit is contained in:
parent
d63013de11
commit
3d0f1168ff
@ -197,9 +197,9 @@ spdk_nvme_ctrlr_get_default_io_qpair_opts(struct spdk_nvme_ctrlr *ctrlr,
|
||||
struct spdk_nvme_io_qpair_opts *opts,
|
||||
size_t opts_size)
|
||||
{
|
||||
if (!ctrlr || !opts) {
|
||||
return;
|
||||
}
|
||||
assert(ctrlr);
|
||||
|
||||
assert(opts);
|
||||
|
||||
memset(opts, 0, opts_size);
|
||||
|
||||
|
@ -1452,6 +1452,32 @@ test_ctrlr_opts_set_defaults(void)
|
||||
CU_ASSERT(strlen(opts.src_svcid) == 0);
|
||||
}
|
||||
|
||||
static void
|
||||
test_ctrlr_get_default_io_qpair_opts(void)
|
||||
{
|
||||
struct spdk_nvme_ctrlr ctrlr = {};
|
||||
struct spdk_nvme_io_qpair_opts opts = {};
|
||||
|
||||
memset(&opts, 0, sizeof(opts));
|
||||
|
||||
/* set a smaller opts_size */
|
||||
ctrlr.opts.io_queue_size = DEFAULT_IO_QUEUE_SIZE;
|
||||
CU_ASSERT(sizeof(opts) > 8);
|
||||
spdk_nvme_ctrlr_get_default_io_qpair_opts(&ctrlr, &opts, 8);
|
||||
CU_ASSERT_EQUAL(opts.qprio, SPDK_NVME_QPRIO_URGENT);
|
||||
CU_ASSERT_EQUAL(opts.io_queue_size, DEFAULT_IO_QUEUE_SIZE);
|
||||
/* check below field is not initialized by default value */
|
||||
CU_ASSERT_EQUAL(opts.io_queue_requests, 0);
|
||||
|
||||
/* set a consistent opts_size */
|
||||
ctrlr.opts.io_queue_size = DEFAULT_IO_QUEUE_SIZE;
|
||||
ctrlr.opts.io_queue_requests = DEFAULT_IO_QUEUE_REQUESTS;
|
||||
spdk_nvme_ctrlr_get_default_io_qpair_opts(&ctrlr, &opts, sizeof(opts));
|
||||
CU_ASSERT_EQUAL(opts.qprio, SPDK_NVME_QPRIO_URGENT);
|
||||
CU_ASSERT_EQUAL(opts.io_queue_size, DEFAULT_IO_QUEUE_SIZE);
|
||||
CU_ASSERT_EQUAL(opts.io_queue_requests, DEFAULT_IO_QUEUE_REQUESTS);
|
||||
}
|
||||
|
||||
#if 0 /* TODO: move to PCIe-specific unit test */
|
||||
static void
|
||||
test_nvme_ctrlr_alloc_cmb(void)
|
||||
@ -1580,6 +1606,7 @@ int main(int argc, char **argv)
|
||||
test_nvme_ctrlr_init_en_0_rdy_0_ams_vs) == NULL
|
||||
|| CU_add_test(suite, "alloc_io_qpair_rr 1", test_alloc_io_qpair_rr_1) == NULL
|
||||
|| CU_add_test(suite, "set_defaults", test_ctrlr_opts_set_defaults) == NULL
|
||||
|| CU_add_test(suite, "get_default_io_qpair_opts", test_ctrlr_get_default_io_qpair_opts) == NULL
|
||||
|| CU_add_test(suite, "alloc_io_qpair_wrr 1", test_alloc_io_qpair_wrr_1) == NULL
|
||||
|| CU_add_test(suite, "alloc_io_qpair_wrr 2", test_alloc_io_qpair_wrr_2) == NULL
|
||||
|| CU_add_test(suite, "test nvme ctrlr function update_firmware",
|
||||
|
Loading…
Reference in New Issue
Block a user