Commit 3eda8bf6 authored by Maciej Szwed's avatar Maciej Szwed Committed by Tomasz Zawadzki
Browse files

unit/bdev: Extract common code for comparev tests



Upcoming patch will use most of the comparev test code
so let's reuse it.

Signed-off-by: default avatarMaciej Szwed <maciej.szwed@intel.com>
Change-Id: Ibc6230d38da224bfcf25f76fe1d834d48200bfd9

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/479832


Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent bee042e4
Loading
Loading
Loading
Loading
+18 −5
Original line number Diff line number Diff line
@@ -2192,7 +2192,7 @@ bdev_histograms(void)
}

static void
bdev_compare_emulated(void)
_bdev_compare(bool emulated)
{
	struct spdk_bdev *bdev;
	struct spdk_bdev_desc *desc = NULL;
@@ -2203,12 +2203,19 @@ bdev_compare_emulated(void)
	char aa_buf[512];
	char bb_buf[512];
	struct iovec compare_iov;
	uint8_t io_type;
	int rc;

	if (emulated) {
		io_type = SPDK_BDEV_IO_TYPE_READ;
	} else {
		io_type = SPDK_BDEV_IO_TYPE_COMPARE;
	}

	memset(aa_buf, 0xaa, sizeof(aa_buf));
	memset(bb_buf, 0xbb, sizeof(bb_buf));

	g_io_types_supported[SPDK_BDEV_IO_TYPE_COMPARE] = false;
	g_io_types_supported[SPDK_BDEV_IO_TYPE_COMPARE] = !emulated;

	spdk_bdev_initialize(bdev_init_cb, NULL);
	fn_table.submit_request = stub_submit_request_get_buf;
@@ -2228,7 +2235,7 @@ bdev_compare_emulated(void)
	compare_iov.iov_base = aa_buf;
	compare_iov.iov_len = sizeof(aa_buf);

	expected_io = ut_alloc_expected_io(SPDK_BDEV_IO_TYPE_READ, offset, num_blocks, 0);
	expected_io = ut_alloc_expected_io(io_type, offset, num_blocks, 0);
	TAILQ_INSERT_TAIL(&g_bdev_ut_channel->expected_io, expected_io, link);

	g_io_done = false;
@@ -2241,7 +2248,7 @@ bdev_compare_emulated(void)
	CU_ASSERT(g_io_done == true);
	CU_ASSERT(g_io_status == SPDK_BDEV_IO_STATUS_SUCCESS);

	expected_io = ut_alloc_expected_io(SPDK_BDEV_IO_TYPE_READ, offset, num_blocks, 0);
	expected_io = ut_alloc_expected_io(io_type, offset, num_blocks, 0);
	TAILQ_INSERT_TAIL(&g_bdev_ut_channel->expected_io, expected_io, link);

	g_io_done = false;
@@ -2266,6 +2273,12 @@ bdev_compare_emulated(void)
	g_compare_read_buf = NULL;
}

static void
bdev_compare(void)
{
	_bdev_compare(true);
}

static void
bdev_compare_and_write(void)
{
@@ -3118,7 +3131,7 @@ main(int argc, char **argv)
		CU_add_test(suite, "bdev_histograms", bdev_histograms) == NULL ||
		CU_add_test(suite, "bdev_write_zeroes", bdev_write_zeroes) == NULL ||
		CU_add_test(suite, "bdev_compare_and_write", bdev_compare_and_write) == NULL ||
		CU_add_test(suite, "bdev_compare_emulated", bdev_compare_emulated) == NULL ||
		CU_add_test(suite, "bdev_compare", bdev_compare) == NULL ||
		CU_add_test(suite, "bdev_open_while_hotremove", bdev_open_while_hotremove) == NULL ||
		CU_add_test(suite, "bdev_close_while_hotremove", bdev_close_while_hotremove) == NULL ||
		CU_add_test(suite, "bdev_open_ext", bdev_open_ext) == NULL ||