From patchwork Wed Dec 7 20:31:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 120544 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5DB38A00C3; Wed, 7 Dec 2022 21:31:49 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AF2FC42D35; Wed, 7 Dec 2022 21:31:35 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id D625241611 for ; Wed, 7 Dec 2022 21:31:31 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id D49CA20B83E5; Wed, 7 Dec 2022 12:31:30 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com D49CA20B83E5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1670445090; bh=SQYNN+yT8b7GVewPS95EotHSnyqDvRDS5QWrUxCkDXE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y/IDqeCmh8Myb0yUiO+PSN7O//QOTA65BWRzai9Tt8ApbRqFNOsVbtUAI4ltlWZJy llksK3ItgfkeQnUv/a0DLEi1g3XIkpHu0tytMY9nWgZQH3zl3hbYy6xmXk24eplXOk Bp9uZOWHyuQHARV//vEMNHo+TxyEY0hUDCpz8Ivw= From: Tyler Retzlaff To: dev@dpdk.org Cc: thomas@monjalon.net, david.marchand@redhat.com, stephen@networkplumber.org, olivier.matz@6wind.com, Tyler Retzlaff Subject: [PATCH v3 2/3] test: add rte control thread create API test Date: Wed, 7 Dec 2022 12:31:28 -0800 Message-Id: <1670445089-23898-3-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1670445089-23898-1-git-send-email-roretzla@linux.microsoft.com> References: <1670271868-11364-1-git-send-email-roretzla@linux.microsoft.com> <1670445089-23898-1-git-send-email-roretzla@linux.microsoft.com> 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 Duplicate the rte_ctrl_thread_create test adapted to use rte_control_thread create to keep both apis under test until rte_ctrl_thread_create is removed. Signed-off-by: Tyler Retzlaff --- app/test/test_lcores.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/app/test/test_lcores.c b/app/test/test_lcores.c index a6bb412..375ecdb 100644 --- a/app/test/test_lcores.c +++ b/app/test/test_lcores.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "test.h" @@ -352,6 +353,18 @@ static void *ctrl_thread_loop(void *arg) return NULL; } +static uint32_t control_thread_loop(void *arg) +{ + struct thread_context *t = arg; + + printf("Control thread running successfully\n"); + + /* Set the thread state to DONE */ + t->state = Thread_DONE; + + return 0; +} + static int test_ctrl_thread(void) { @@ -379,6 +392,32 @@ static void *ctrl_thread_loop(void *arg) } static int +test_control_thread(void) +{ + struct thread_context ctrl_thread_context; + struct thread_context *t; + + /* Create one control thread */ + t = &ctrl_thread_context; + t->state = Thread_INIT; + if (rte_control_thread_create((rte_thread_t *)&t->id, "test_control_threads", + NULL, control_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. + */ + rte_thread_join((rte_thread_t){(uintptr_t)t->id}, NULL); + + /* Check if the control thread set the correct state */ + if (t->state != Thread_DONE) + return -1; + + return 0; +} + +static int test_lcores(void) { unsigned int eal_threads_count = 0; @@ -411,6 +450,9 @@ static void *ctrl_thread_loop(void *arg) if (test_ctrl_thread() < 0) return TEST_FAILED; + if (test_control_thread() < 0) + return TEST_FAILED; + return TEST_SUCCESS; }