Commit 84ab68c1 authored by Jim Harris's avatar Jim Harris Committed by Tomasz Zawadzki
Browse files

test/scheduler: add a for_each_reactor shutdown test



The scheduler test app is ideal for testing that the
reactors properly flush any existing for_each_reactor
operations during the shutdown process.  This is
because it has no SPDK subsystems, so the reactors
stop immediately after the application is signaled to
terminate.

So start a for_each_reactor operation when the
application starts, and then keep starting another
one once the previous one completes.

This serves as a regression test for issue #2206.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I69825b50ad6f3c059da11241f58a8319199e88d5

Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9929


Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarXiaodong Liu <xiaodong.liu@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent 5466d5d4
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -43,6 +43,8 @@
#include "spdk/thread.h"
#include "spdk/util.h"

#include "spdk_internal/event.h"

static bool g_is_running = true;
pthread_mutex_t g_sched_list_mutex = PTHREAD_MUTEX_INITIALIZER;
#define TIMESLICE_US 100 * 1000
@@ -390,10 +392,28 @@ test_shutdown(void)
	pthread_mutex_unlock(&g_sched_list_mutex);
}

static void
for_each_nop(void *arg1, void *arg2)
{
}

static void
for_each_done(void *arg1, void *arg2)
{
	spdk_for_each_reactor(for_each_nop, NULL, NULL, for_each_done);
}

static void
test_start(void *arg1)
{
	SPDK_NOTICELOG("Scheduler test application started.\n");
	/* Start an spdk_for_each_reactor operation that just keeps
	 * running over and over again until the app exits.  This
	 * serves as a regression test for SPDK issue #2206, ensuring
	 * that any pending spdk_for_each_reactor operations are
	 * completed before reactors are shut down.
	 */
	for_each_done(NULL, NULL);
}

int