test: Use ut_multithread framework in blobfs sync test
Change-Id: I5a15f3af773aad23e0479ad94c4544a2a5f9ea50 Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.gerrithub.io/c/422470 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
parent
47d5ddb7ce
commit
11654a6065
@ -64,12 +64,6 @@ spdk_conf_section_get_intval(struct spdk_conf_section *sp, const char *key)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void
|
||||
_fs_send_msg(spdk_msg_fn fn, void *ctx, void *thread_ctx)
|
||||
{
|
||||
fn(ctx);
|
||||
}
|
||||
|
||||
struct ut_request {
|
||||
fs_request_fn fn;
|
||||
void *arg;
|
||||
@ -144,21 +138,34 @@ fs_op_with_handle_complete(void *ctx, struct spdk_filesystem *fs, int fserrno)
|
||||
static void
|
||||
_fs_init(void *arg)
|
||||
{
|
||||
struct spdk_thread *thread;
|
||||
struct spdk_bs_dev *dev;
|
||||
|
||||
g_fs = NULL;
|
||||
g_fserrno = -1;
|
||||
dev = init_dev();
|
||||
spdk_fs_init(dev, NULL, send_request, fs_op_with_handle_complete, NULL);
|
||||
thread = spdk_get_thread();
|
||||
spdk_set_thread(NULL);
|
||||
while (spdk_thread_poll(thread, 0) > 0) {}
|
||||
spdk_set_thread(thread);
|
||||
|
||||
SPDK_CU_ASSERT_FATAL(g_fs != NULL);
|
||||
SPDK_CU_ASSERT_FATAL(g_fs->bdev == dev);
|
||||
CU_ASSERT(g_fserrno == 0);
|
||||
}
|
||||
|
||||
static void
|
||||
_fs_unload(void *arg)
|
||||
{
|
||||
struct spdk_thread *thread;
|
||||
|
||||
g_fserrno = -1;
|
||||
spdk_fs_unload(g_fs, fs_op_complete, NULL);
|
||||
thread = spdk_get_thread();
|
||||
spdk_set_thread(NULL);
|
||||
while (spdk_thread_poll(thread, 0) > 0) {}
|
||||
spdk_set_thread(thread);
|
||||
CU_ASSERT(g_fserrno == 0);
|
||||
g_fs = NULL;
|
||||
}
|
||||
@ -208,6 +215,7 @@ cache_write_null_buffer(void)
|
||||
uint64_t length;
|
||||
int rc;
|
||||
struct spdk_io_channel *channel;
|
||||
struct spdk_thread *thread;
|
||||
|
||||
ut_send_request(_fs_init, NULL);
|
||||
|
||||
@ -230,6 +238,11 @@ cache_write_null_buffer(void)
|
||||
|
||||
spdk_fs_free_io_channel(channel);
|
||||
|
||||
thread = spdk_get_thread();
|
||||
spdk_set_thread(NULL);
|
||||
while (spdk_thread_poll(thread, 0) > 0) {}
|
||||
spdk_set_thread(thread);
|
||||
|
||||
ut_send_request(_fs_unload, NULL);
|
||||
}
|
||||
|
||||
@ -238,6 +251,7 @@ fs_create_sync(void)
|
||||
{
|
||||
int rc;
|
||||
struct spdk_io_channel *channel;
|
||||
struct spdk_thread *thread;
|
||||
|
||||
ut_send_request(_fs_init, NULL);
|
||||
|
||||
@ -256,6 +270,11 @@ fs_create_sync(void)
|
||||
|
||||
spdk_fs_free_io_channel(channel);
|
||||
|
||||
thread = spdk_get_thread();
|
||||
spdk_set_thread(NULL);
|
||||
while (spdk_thread_poll(thread, 0) > 0) {}
|
||||
spdk_set_thread(thread);
|
||||
|
||||
ut_send_request(_fs_unload, NULL);
|
||||
}
|
||||
|
||||
@ -265,6 +284,7 @@ cache_append_no_cache(void)
|
||||
int rc;
|
||||
char buf[100];
|
||||
struct spdk_io_channel *channel;
|
||||
struct spdk_thread *thread;
|
||||
|
||||
ut_send_request(_fs_init, NULL);
|
||||
|
||||
@ -293,6 +313,11 @@ cache_append_no_cache(void)
|
||||
|
||||
spdk_fs_free_io_channel(channel);
|
||||
|
||||
thread = spdk_get_thread();
|
||||
spdk_set_thread(NULL);
|
||||
while (spdk_thread_poll(thread, 0) > 0) {}
|
||||
spdk_set_thread(thread);
|
||||
|
||||
ut_send_request(_fs_unload, NULL);
|
||||
}
|
||||
|
||||
@ -302,6 +327,7 @@ fs_delete_file_without_close(void)
|
||||
int rc;
|
||||
struct spdk_io_channel *channel;
|
||||
struct spdk_file *file;
|
||||
struct spdk_thread *thread;
|
||||
|
||||
ut_send_request(_fs_init, NULL);
|
||||
channel = spdk_fs_alloc_io_channel_sync(g_fs);
|
||||
@ -326,6 +352,11 @@ fs_delete_file_without_close(void)
|
||||
|
||||
spdk_fs_free_io_channel(channel);
|
||||
|
||||
thread = spdk_get_thread();
|
||||
spdk_set_thread(NULL);
|
||||
while (spdk_thread_poll(thread, 0) > 0) {}
|
||||
spdk_set_thread(thread);
|
||||
|
||||
ut_send_request(_fs_unload, NULL);
|
||||
|
||||
}
|
||||
@ -343,7 +374,7 @@ spdk_thread(void *arg)
|
||||
struct spdk_thread *thread;
|
||||
struct ut_request *req;
|
||||
|
||||
thread = spdk_allocate_thread(_fs_send_msg, NULL, NULL, NULL, "thread1");
|
||||
thread = spdk_allocate_thread(NULL, NULL, NULL, NULL, "thread1");
|
||||
spdk_set_thread(thread);
|
||||
|
||||
while (1) {
|
||||
@ -358,6 +389,10 @@ spdk_thread(void *arg)
|
||||
g_req = NULL;
|
||||
}
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
|
||||
spdk_set_thread(NULL);
|
||||
spdk_thread_poll(thread, 0);
|
||||
spdk_set_thread(thread);
|
||||
}
|
||||
|
||||
spdk_free_thread();
|
||||
@ -393,7 +428,7 @@ int main(int argc, char **argv)
|
||||
return CU_get_error();
|
||||
}
|
||||
|
||||
thread = spdk_allocate_thread(_fs_send_msg, NULL, NULL, NULL, "thread0");
|
||||
thread = spdk_allocate_thread(NULL, NULL, NULL, NULL, "thread0");
|
||||
spdk_set_thread(thread);
|
||||
|
||||
pthread_create(&spdk_tid, NULL, spdk_thread, NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user