From 84ab68c1a3a9f7045a63f67fe1542d547f2064a9 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Tue, 19 Oct 2021 12:10:01 -0700 Subject: [PATCH] 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: Jim Harris Change-Id: I69825b50ad6f3c059da11241f58a8319199e88d5 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9929 Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins Reviewed-by: Changpeng Liu Reviewed-by: Xiaodong Liu Reviewed-by: Aleksey Marchuk Reviewed-by: Tomasz Zawadzki --- test/event/scheduler/scheduler.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/event/scheduler/scheduler.c b/test/event/scheduler/scheduler.c index 885c76e9c..cdf9e7e7c 100644 --- a/test/event/scheduler/scheduler.c +++ b/test/event/scheduler/scheduler.c @@ -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