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 CD66EA00C2; Fri, 9 Dec 2022 00:19:39 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B365740E0F; Fri, 9 Dec 2022 00:19:39 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 2E9E340E03 for ; Fri, 9 Dec 2022 00:19:38 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 79E7A20B83E5; Thu, 8 Dec 2022 15:19:37 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 79E7A20B83E5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1670541577; bh=SQYNN+yT8b7GVewPS95EotHSnyqDvRDS5QWrUxCkDXE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BadVOXjFqAnz05CTajfql0tSHkrCEDIsHdSaT3bHWAofnnu57sB0gTY3EgwzqewFi HxRKQfXQ668kaVaxolgyWpg4oIoBYRL9BfzonvGw17lswfAidpRHdNbRhQZmF9cL7H zzuBtFoyvCLWsFfCba5/G2fPFF5yMRXiBoYtmNZw= From: Tyler Retzlaff To: dev@dpdk.org Cc: thomas@monjalon.net, david.marchand@redhat.com, stephen@networkplumber.org, olivier.matz@6wind.com, hofors@lysator.liu.se, Tyler Retzlaff Subject: [PATCH v4 2/3] test: add rte control thread create API test Date: Thu, 8 Dec 2022 15:19:35 -0800 Message-Id: <1670541576-18008-3-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1670541576-18008-1-git-send-email-roretzla@linux.microsoft.com> References: <1670271868-11364-1-git-send-email-roretzla@linux.microsoft.com> <1670541576-18008-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; } -- 1.8.3.1