Commit 18bc3a5e authored by Jing Xia's avatar Jing Xia Committed by Jim Harris
Browse files

test/blobfs: Test create sync file



Change-Id: I1f766502cf2d21698f01a05b755f15a7d346949a
Signed-off-by: default avatarJing Xia <jingx.y.xia@intel.com>
Reviewed-on: https://review.gerrithub.io/361879


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarGangCao <gang.cao@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent ecaf3fe1
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -211,6 +211,34 @@ cache_write_null_buffer(void)
	ut_send_request(_fs_unload, NULL);
}

static void
fs_create_sync(void)
{
	int rc;
	struct spdk_io_channel *channel;

	ut_send_request(_fs_init, NULL);

	spdk_allocate_thread();
	channel = spdk_fs_alloc_io_channel_sync(g_fs, SPDK_IO_PRIORITY_DEFAULT);
	CU_ASSERT(channel != NULL);

	rc = spdk_fs_create_file(g_fs, channel, "testfile");
	CU_ASSERT(rc == 0);

	/* Create should fail, because the file already exists. */
	rc = spdk_fs_create_file(g_fs, channel, "testfile");
	CU_ASSERT(rc != 0);

	rc = spdk_fs_delete_file(g_fs, channel, "testfile");
	CU_ASSERT(rc == 0);

	spdk_fs_free_io_channel(channel);
	spdk_free_thread();

	ut_send_request(_fs_unload, NULL);
}

static void
cache_append_no_cache(void)
{
@@ -300,6 +328,7 @@ int main(int argc, char **argv)
	if (
		CU_add_test(suite, "write", cache_write) == NULL ||
		CU_add_test(suite, "write_null_buffer", cache_write_null_buffer) == NULL ||
		CU_add_test(suite, "create_sync", fs_create_sync) == NULL ||
		CU_add_test(suite, "append_no_cache", cache_append_no_cache) == NULL
	) {
		CU_cleanup_registry();