Commit 598eda5d authored by paul luse's avatar paul luse Committed by Tomasz Zawadzki
Browse files

test/accel: add UT for spdk_accel_get_capabilities()



Signed-off-by: default avatarpaul luse <paul.e.luse@intel.com>
Change-Id: I6e18929dc8753301cf8735c2a33f53258a098768
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6356


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Community-CI: Mellanox Build Bot
parent 480d8ac7
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -173,6 +173,29 @@ test_spdk_accel_task_complete(void)
	CU_ASSERT(expected_batch == &batch);
}

static void
test_spdk_accel_get_capabilities(void)
{
	struct spdk_io_channel *ch;
	struct accel_io_channel *accel_ch;
	struct spdk_accel_engine engine;
	uint64_t cap, expected_cap;

	ch = calloc(1, sizeof(struct spdk_io_channel) + sizeof(struct accel_io_channel));
	SPDK_CU_ASSERT_FATAL(ch != NULL);

	/* Setup a few capabilites and make sure they are reported as expected. */
	accel_ch = (struct accel_io_channel *)((char *)ch + sizeof(struct spdk_io_channel));
	accel_ch->engine = &engine;
	expected_cap = ACCEL_COPY | ACCEL_DUALCAST | ACCEL_CRC32C;
	accel_ch->engine->capabilities = expected_cap;

	cap = spdk_accel_get_capabilities(ch);
	CU_ASSERT(cap == expected_cap);

	free(ch);
}

int main(int argc, char **argv)
{
	CU_pSuite	suite = NULL;
@@ -188,6 +211,7 @@ int main(int argc, char **argv)
	CU_ADD_TEST(suite, test_accel_sw_unregister);
	CU_ADD_TEST(suite, test_is_supported);
	CU_ADD_TEST(suite, test_spdk_accel_task_complete);
	CU_ADD_TEST(suite, test_spdk_accel_get_capabilities);

	CU_basic_set_mode(CU_BRM_VERBOSE);
	CU_basic_run_tests();