Commit 566aa11e authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Jim Harris
Browse files

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: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Iaa456667b5509d5fd8470315e2716b0b9fe209a5
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/464811


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 42dec8ff
Loading
Loading
Loading
Loading
+9 −12
Original line number Diff line number Diff line
@@ -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