From: Honnappa Nagarahalli Date: Thu, 21 Oct 2021 21:32:21 +0000 (-0500) Subject: test: test control thread creation X-Git-Url: http://git.droids-corp.org/?p=dpdk.git;a=commitdiff_plain;h=f217fa71accfb1acc1ee43c212ec8478501eb755 test: test control thread creation Add a testcase to test launching of control threads. Signed-off-by: Honnappa Nagarahalli Reviewed-by: Olivier Matz --- diff --git a/app/test/test_lcores.c b/app/test/test_lcores.c index 19a7ab9fce..35c47d5372 100644 --- a/app/test/test_lcores.c +++ b/app/test/test_lcores.c @@ -340,6 +340,44 @@ error: return -1; } +static void *ctrl_thread_loop(void *arg) +{ + struct thread_context *t = arg; + + printf("Control thread running successfully\n"); + + /* Set the thread state to DONE */ + t->state = DONE; + + return NULL; +} + +static int +test_ctrl_thread(void) +{ + struct thread_context ctrl_thread_context; + struct thread_context *t; + + /* Create one control thread */ + t = &ctrl_thread_context; + t->state = INIT; + if (rte_ctrl_thread_create(&t->id, "test_ctrl_threads", + NULL, ctrl_thread_loop, t) != 0) + return -1; + + /* Wait till the control thread exits. + * This also acts as the barrier such that the memory operations + * in control thread are visible to this thread. + */ + pthread_join(t->id, NULL); + + /* Check if the control thread set the correct state */ + if (t->state != DONE) + return -1; + + return 0; +} + static int test_lcores(void) { @@ -367,6 +405,9 @@ test_lcores(void) if (test_non_eal_lcores_callback(eal_threads_count) < 0) return TEST_FAILED; + if (test_ctrl_thread() < 0) + return TEST_FAILED; + return TEST_SUCCESS; }