lvol_ut: add test for invalid options

Add unit test for calling spdk_lvs_load_ext()/lvs_load()
with invalid options (opts_size is 0).

Change-Id: I9c48b972066cf977304e3efa936827d1ef1b5250
Signed-off-by: Marcin Spiewak <marcin.spiewak@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17584
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Mike Gerdts <mgerdts@nvidia.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Marcin Spiewak 2023-04-13 13:56:50 +00:00 committed by Konrad Sztyber
parent 324e3261e6
commit 9ab5c8b67a

View File

@ -1115,6 +1115,7 @@ test_lvs_load(void)
struct spdk_lvs_with_handle_req *req;
struct spdk_bs_opts bs_opts = {};
struct spdk_blob *super_blob;
struct spdk_lvs_opts opts = {};
req = calloc(1, sizeof(*req));
SPDK_CU_ASSERT_FATAL(req != NULL);
@ -1179,6 +1180,15 @@ test_lvs_load(void)
CU_ASSERT(g_lvol_store == NULL);
CU_ASSERT(TAILQ_EMPTY(&g_lvol_stores));
/* Fail on invalid options */
g_lvserrno = -1;
spdk_lvs_opts_init(&opts);
opts.opts_size = 0; /* Invalid length */
spdk_lvs_load_ext(&dev.bs_dev, &opts, lvol_store_op_with_handle_complete, NULL);
CU_ASSERT(g_lvserrno == -EINVAL);
CU_ASSERT(g_lvol_store == NULL);
CU_ASSERT(TAILQ_EMPTY(&g_lvol_stores));
/* Load successfully */
g_lvserrno = 0;
super_blob->close_status = 0;