From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 69F69A0C43; Thu, 21 Oct 2021 23:32:35 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 19F2F4111C; Thu, 21 Oct 2021 23:32:32 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id 94662410E3 for ; Thu, 21 Oct 2021 23:32:30 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0E3B61063; Thu, 21 Oct 2021 14:32:30 -0700 (PDT) Received: from qc2400f-1.austin.arm.com (qc2400f-1.austin.arm.com [10.118.12.44]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 049273F73D; Thu, 21 Oct 2021 14:32:30 -0700 (PDT) From: Honnappa Nagarahalli To: dev@dpdk.org, honnappa.nagarahalli@arm.com, olivier.matz@6wind.com, lucp.at.work@gmail.com, stephen@networkplumber.org, david.marchand@redhat.com, thomas@monjalon.net Cc: ruifeng.wang@arm.com, nd@arm.com Date: Thu, 21 Oct 2021 16:32:21 -0500 Message-Id: <20211021213221.9239-2-honnappa.nagarahalli@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211021213221.9239-1-honnappa.nagarahalli@arm.com> References: <20210730213709.19400-1-honnappa.nagarahalli@arm.com> <20211021213221.9239-1-honnappa.nagarahalli@arm.com> Subject: [dpdk-dev] [PATCH v5 2/2] test/eal: add a test for rte_ctrl_thread_create X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add a testcase to test launching of control threads. Signed-off-by: Honnappa Nagarahalli --- app/test/test_lcores.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) 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 @@ test_non_eal_lcores_callback(unsigned int eal_threads_count) 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; } -- 2.25.1