From 9bef42f2849a812218f26085a0e570ec3ef8c68d Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Mon, 17 Dec 2018 14:40:51 -0700 Subject: [PATCH] test: Use ut_multithread framework in bdev/pmem Change-Id: Ib9de83db429e4ae6f8e0cc988ca161cebdb27c9c Signed-off-by: Ben Walker Reviewed-on: https://review.gerrithub.io/c/437599 Tested-by: SPDK CI Jenkins Chandler-Test-Pool: SPDK Automated Test System Reviewed-by: Changpeng Liu Reviewed-by: Jim Harris --- test/common/lib/ut_multithread.c | 4 ++-- test/unit/lib/bdev/pmem/bdev_pmem_ut.c | 18 ++++++------------ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/test/common/lib/ut_multithread.c b/test/common/lib/ut_multithread.c index 763020ddc..e262b45b9 100644 --- a/test/common/lib/ut_multithread.c +++ b/test/common/lib/ut_multithread.c @@ -120,8 +120,8 @@ poll_thread(uintptr_t thread_id) struct ut_thread *thread = &g_ut_threads[thread_id]; uintptr_t original_thread_id; - CU_ASSERT(thread_id != (uintptr_t)INVALID_THREAD); - CU_ASSERT(thread_id < g_ut_num_threads); + assert(thread_id != (uintptr_t)INVALID_THREAD); + assert(thread_id < g_ut_num_threads); original_thread_id = g_thread_id; set_thread(INVALID_THREAD); diff --git a/test/unit/lib/bdev/pmem/bdev_pmem_ut.c b/test/unit/lib/bdev/pmem/bdev_pmem_ut.c index 982dda8c7..ade1d942a 100644 --- a/test/unit/lib/bdev/pmem/bdev_pmem_ut.c +++ b/test/unit/lib/bdev/pmem/bdev_pmem_ut.c @@ -33,7 +33,7 @@ #include "spdk_cunit.h" -#include "common/lib/test_env.c" +#include "common/lib/ut_multithread.c" #include "unit/lib/json_mock.c" #include "spdk_internal/thread.h" @@ -100,12 +100,6 @@ static struct spdk_bdev *g_bdev; static const char *g_check_version_msg; 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 * find_pmemblk_pool(const char *path) { @@ -370,8 +364,9 @@ ut_pmem_blk_clean(void) /* Unload module to free IO channel */ g_bdev_pmem_module->module_fini(); + poll_threads(); - spdk_free_thread(); + free_threads(); return 0; } @@ -379,12 +374,10 @@ ut_pmem_blk_clean(void) static int ut_pmem_blk_init(void) { - struct spdk_thread *thread; - errno = 0; - thread = spdk_allocate_thread(_pmem_send_msg, NULL, NULL, NULL, NULL); - spdk_set_thread(thread); + allocate_threads(1); + set_thread(0); g_pool_ok.buffer = calloc(g_pool_ok.nblock, g_pool_ok.bsize); if (g_pool_ok.buffer == NULL) { @@ -784,5 +777,6 @@ main(int argc, char **argv) CU_basic_run_tests(); num_failures = CU_get_number_of_failures(); CU_cleanup_registry(); + return num_failures; }