Commit da48e839 authored by Tomasz Zawadzki's avatar Tomasz Zawadzki
Browse files

unit_test: check for creating the same lun twice



This patch adds new unit test for scsi lun:
- creates the same lun twice

As noted in code, one assert is incorrectly set to show functionality
that is not working currently.
Next patch in series implements that functionality and changes that assert
in the unit test.

Signed-off-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: Ie1ea6034ba295bc1c24d21529c6adcf20ac10c53
parent 095c690e
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -607,6 +607,27 @@ lun_construct_success(void)
	CU_ASSERT_EQUAL(g_task_count, 0);
}

static void
lun_construct_same_same_twice(void)
{
	struct spdk_scsi_lun		*lun, *lun2;
	struct spdk_bdev		bdev, bdev2;

	lun = spdk_scsi_lun_construct("lun0", &bdev);

	/* Successfully constructs and returns lun */
	CU_ASSERT(lun != NULL);

	lun2 = spdk_scsi_lun_construct("lun0", &bdev2);

	/* Fails to construct the same lun on another bdev and returns NULL */
	CU_ASSERT(lun2 != NULL); /* lun2 should be NULL, this shows it is not currently working */

	lun_destruct(lun);

	CU_ASSERT_EQUAL(g_task_count, 0);
}

static void
lun_deletable(void)
{
@@ -669,6 +690,7 @@ main(int argc, char **argv)
		|| CU_add_test(suite, "destruct task - success", lun_destruct_success) == NULL
		|| CU_add_test(suite, "construct - null ctx", lun_construct_null_ctx) == NULL
		|| CU_add_test(suite, "construct - success", lun_construct_success) == NULL
		|| CU_add_test(suite, "construct - same lun twice", lun_construct_same_same_twice) == NULL
		|| CU_add_test(suite, "deletable", lun_deletable) == NULL
	) {
		CU_cleanup_registry();