test/nvmf/vfio_user: cases for creating vfio user
Change-Id: Id477e1f1f278d34b6d025dafa34ddd9ed1cae1d1 Signed-off-by: Mao Jiang <maox.jiang@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8770 Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
parent
34c901e308
commit
a43f891e9b
@ -221,6 +221,42 @@ test_nvme_cmd_map_sgls(void)
|
||||
spdk_free(sgls);
|
||||
}
|
||||
|
||||
static void
|
||||
ut_transport_destroy_done_cb(void *cb_arg)
|
||||
{
|
||||
int *done = cb_arg;
|
||||
*done = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
test_nvmf_vfio_user_create_destroy(void)
|
||||
{
|
||||
struct spdk_nvmf_transport *transport = NULL;
|
||||
struct nvmf_vfio_user_transport *vu_transport = NULL;
|
||||
struct nvmf_vfio_user_endpoint *endpoint = NULL;
|
||||
struct spdk_nvmf_transport_opts opts = {};
|
||||
int rc;
|
||||
int done;
|
||||
|
||||
/* Initialize transport_specific NULL to avoid decoding json */
|
||||
opts.transport_specific = NULL;
|
||||
|
||||
transport = nvmf_vfio_user_create(&opts);
|
||||
CU_ASSERT(transport != NULL);
|
||||
|
||||
vu_transport = SPDK_CONTAINEROF(transport, struct nvmf_vfio_user_transport,
|
||||
transport);
|
||||
/* Allocate a endpoint for destroy */
|
||||
endpoint = calloc(1, sizeof(*endpoint));
|
||||
pthread_mutex_init(&endpoint->lock, NULL);
|
||||
TAILQ_INSERT_TAIL(&vu_transport->endpoints, endpoint, link);
|
||||
done = 0;
|
||||
|
||||
rc = nvmf_vfio_user_destroy(transport, ut_transport_destroy_done_cb, &done);
|
||||
CU_ASSERT(rc == 0);
|
||||
CU_ASSERT(done == 1);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
CU_pSuite suite = NULL;
|
||||
@ -233,6 +269,7 @@ int main(int argc, char **argv)
|
||||
|
||||
CU_ADD_TEST(suite, test_nvme_cmd_map_prps);
|
||||
CU_ADD_TEST(suite, test_nvme_cmd_map_sgls);
|
||||
CU_ADD_TEST(suite, test_nvmf_vfio_user_create_destroy);
|
||||
|
||||
CU_basic_set_mode(CU_BRM_VERBOSE);
|
||||
CU_basic_run_tests();
|
||||
|
Loading…
Reference in New Issue
Block a user