From 566aa11ebb4b2eaf862a8c4169ee2ab2dad87edd Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Mon, 12 Aug 2019 07:33:32 +0900 Subject: [PATCH] ut/iscsi/portal_grp: Use UT multithread framework This is a preparation to the next patch to test IO channel. Separate this from the next patch to clarify the intention. Signed-off-by: Shuhei Matsumoto Change-Id: Iaa456667b5509d5fd8470315e2716b0b9fe209a5 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/464811 Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- .../lib/iscsi/portal_grp.c/portal_grp_ut.c | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/test/unit/lib/iscsi/portal_grp.c/portal_grp_ut.c b/test/unit/lib/iscsi/portal_grp.c/portal_grp_ut.c index 016efa52f..b210a2468 100644 --- a/test/unit/lib/iscsi/portal_grp.c/portal_grp_ut.c +++ b/test/unit/lib/iscsi/portal_grp.c/portal_grp_ut.c @@ -36,7 +36,7 @@ #include "spdk_cunit.h" -#include "common/lib/test_env.c" +#include "common/lib/ut_multithread.c" #include "common/lib/test_sock.c" #include "../common.c" @@ -322,17 +322,16 @@ static void portal_grp_add_delete_case(void) { struct spdk_sock sock = {}; - struct spdk_thread *thread; struct spdk_iscsi_portal_grp *pg1, *pg2; struct spdk_iscsi_portal *p; int rc; - thread = spdk_thread_create(NULL, NULL); - spdk_set_thread(thread); - const char *host = "192.168.2.0"; const char *port = "3260"; + allocate_threads(1); + set_thread(0); + /* internal of add_portal_group */ pg1 = spdk_iscsi_portal_grp_create(1); CU_ASSERT(pg1 != NULL); @@ -360,15 +359,13 @@ portal_grp_add_delete_case(void) CU_ASSERT(TAILQ_EMPTY(&g_spdk_iscsi.portal_head)); CU_ASSERT(TAILQ_EMPTY(&g_spdk_iscsi.pg_head)); - spdk_thread_exit(thread); - spdk_thread_destroy(thread); + free_threads(); } static void portal_grp_add_delete_twice_case(void) { struct spdk_sock sock = {}; - struct spdk_thread *thread; struct spdk_iscsi_portal_grp *pg1, *pg2; struct spdk_iscsi_portal *p; int rc; @@ -376,8 +373,8 @@ portal_grp_add_delete_twice_case(void) const char *host = "192.168.2.0"; const char *port1 = "3260", *port2 = "3261"; - thread = spdk_thread_create(NULL, NULL); - spdk_set_thread(thread); + allocate_threads(1); + set_thread(0); /* internal of add_portal_group related */ pg1 = spdk_iscsi_portal_grp_create(1); @@ -420,8 +417,8 @@ portal_grp_add_delete_twice_case(void) CU_ASSERT(TAILQ_EMPTY(&g_spdk_iscsi.pg_head)); MOCK_CLEAR_P(spdk_sock_listen); - spdk_thread_exit(thread); - spdk_thread_destroy(thread); + + free_threads(); } int