test: Use ut_multithread framework in bdev/pmem

Change-Id: Ib9de83db429e4ae6f8e0cc988ca161cebdb27c9c
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/437599
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Ben Walker 2018-12-17 14:40:51 -07:00 committed by Jim Harris
parent 1abf660320
commit 9bef42f284
2 changed files with 8 additions and 14 deletions

View File

@ -120,8 +120,8 @@ poll_thread(uintptr_t thread_id)
struct ut_thread *thread = &g_ut_threads[thread_id]; struct ut_thread *thread = &g_ut_threads[thread_id];
uintptr_t original_thread_id; uintptr_t original_thread_id;
CU_ASSERT(thread_id != (uintptr_t)INVALID_THREAD); assert(thread_id != (uintptr_t)INVALID_THREAD);
CU_ASSERT(thread_id < g_ut_num_threads); assert(thread_id < g_ut_num_threads);
original_thread_id = g_thread_id; original_thread_id = g_thread_id;
set_thread(INVALID_THREAD); set_thread(INVALID_THREAD);

View File

@ -33,7 +33,7 @@
#include "spdk_cunit.h" #include "spdk_cunit.h"
#include "common/lib/test_env.c" #include "common/lib/ut_multithread.c"
#include "unit/lib/json_mock.c" #include "unit/lib/json_mock.c"
#include "spdk_internal/thread.h" #include "spdk_internal/thread.h"
@ -100,12 +100,6 @@ static struct spdk_bdev *g_bdev;
static const char *g_check_version_msg; static const char *g_check_version_msg;
static bool g_pmemblk_open_allow_open = true; static bool g_pmemblk_open_allow_open = true;
static void
_pmem_send_msg(spdk_msg_fn fn, void *ctx, void *thread_ctx)
{
fn(ctx);
}
static PMEMblkpool * static PMEMblkpool *
find_pmemblk_pool(const char *path) find_pmemblk_pool(const char *path)
{ {
@ -370,8 +364,9 @@ ut_pmem_blk_clean(void)
/* Unload module to free IO channel */ /* Unload module to free IO channel */
g_bdev_pmem_module->module_fini(); g_bdev_pmem_module->module_fini();
poll_threads();
spdk_free_thread(); free_threads();
return 0; return 0;
} }
@ -379,12 +374,10 @@ ut_pmem_blk_clean(void)
static int static int
ut_pmem_blk_init(void) ut_pmem_blk_init(void)
{ {
struct spdk_thread *thread;
errno = 0; errno = 0;
thread = spdk_allocate_thread(_pmem_send_msg, NULL, NULL, NULL, NULL); allocate_threads(1);
spdk_set_thread(thread); set_thread(0);
g_pool_ok.buffer = calloc(g_pool_ok.nblock, g_pool_ok.bsize); g_pool_ok.buffer = calloc(g_pool_ok.nblock, g_pool_ok.bsize);
if (g_pool_ok.buffer == NULL) { if (g_pool_ok.buffer == NULL) {
@ -784,5 +777,6 @@ main(int argc, char **argv)
CU_basic_run_tests(); CU_basic_run_tests();
num_failures = CU_get_number_of_failures(); num_failures = CU_get_number_of_failures();
CU_cleanup_registry(); CU_cleanup_registry();
return num_failures; return num_failures;
} }