From 84b5a8c1d61667336f278492de2204d26e621633 Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Wed, 15 Aug 2018 13:56:46 -0700 Subject: [PATCH] test: Use ut_multithread framework in nvmf subsystem unit test Use the default thread implementation instead. Change-Id: I844b02ba3c45d323e9f16b328a31b9d38dc8f754 Signed-off-by: Ben Walker Reviewed-on: https://review.gerrithub.io/422466 Tested-by: SPDK CI Jenkins Chandler-Test-Pool: SPDK Automated Test System Reviewed-by: Changpeng Liu Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto --- test/unit/lib/nvmf/subsystem.c/subsystem_ut.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/test/unit/lib/nvmf/subsystem.c/subsystem_ut.c b/test/unit/lib/nvmf/subsystem.c/subsystem_ut.c index 2db4e51aac..858f7df66f 100644 --- a/test/unit/lib/nvmf/subsystem.c/subsystem_ut.c +++ b/test/unit/lib/nvmf/subsystem.c/subsystem_ut.c @@ -33,7 +33,7 @@ #include "spdk/stdinc.h" -#include "common/lib/test_env.c" +#include "common/lib/ut_multithread.c" #include "spdk_cunit.h" #include "spdk_internal/mock.h" #include "spdk_internal/thread.h" @@ -53,12 +53,6 @@ DEFINE_STUB_V(spdk_bdev_module_release_bdev, DEFINE_STUB(spdk_bdev_get_block_size, uint32_t, (const struct spdk_bdev *bdev), 512); -static void -_subsystem_send_msg(spdk_msg_fn fn, void *ctx, void *thread_ctx) -{ - fn(ctx); -} - static void subsystem_ns_remove_cb(struct spdk_nvmf_subsystem *subsystem, void *cb_arg, int status) { @@ -295,7 +289,9 @@ test_spdk_nvmf_subsystem_add_ns(void) CU_ASSERT(subsystem.max_nsid == 5); spdk_nvmf_subsystem_remove_ns(&subsystem, 1, subsystem_ns_remove_cb, NULL); + poll_threads(); spdk_nvmf_subsystem_remove_ns(&subsystem, 5, subsystem_ns_remove_cb, NULL); + poll_threads(); free(subsystem.ns); free(tgt.subsystems); @@ -449,7 +445,6 @@ test_spdk_nvmf_subsystem_set_sn(void) int main(int argc, char **argv) { - struct spdk_thread *thread; CU_pSuite suite = NULL; unsigned int num_failures; @@ -471,15 +466,15 @@ int main(int argc, char **argv) return CU_get_error(); } - thread = spdk_allocate_thread(_subsystem_send_msg, NULL, NULL, NULL, "thread0"); - spdk_set_thread(thread); + allocate_threads(1); + set_thread(0); CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); num_failures = CU_get_number_of_failures(); CU_cleanup_registry(); - spdk_free_thread(); + free_threads(); return num_failures; }