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 B3465A054A; Tue, 6 Dec 2022 18:28:53 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 48EAC40A7F; Tue, 6 Dec 2022 18:28:53 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id D159C40A7D for ; Tue, 6 Dec 2022 18:28:51 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 0E11120B83E5; Tue, 6 Dec 2022 09:28:50 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 0E11120B83E5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1670347731; bh=CmuhYbh3r6kVxo+WYuRE3URxj5YKoz1kAQzvjTQHcJU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BK2IMsOGJpHbLKGZM4Os7hSY8bgRFXRRofv+XRoMbuYWUXtDlwmdhfQQHUmqoTXlm LMNcVMHoUL6/nw/WTMVDrvH8tNzI0IH9a7P2/o2GoQq4/zW/jtjMy5n2nmLF2Ih3VB gHkLnHFxi35rEKbL8Ty2mDj/llVpuJdm3CANXTLs= From: Tyler Retzlaff To: dev@dpdk.org Cc: thomas@monjalon.net, david.marchand@redhat.com, stephen@networkplumber.org, olivier.matz@6wind.com, mb@smartsharesystems.com, Tyler Retzlaff Subject: [PATCH v2 2/3] test: add rte control thread create API test Date: Tue, 6 Dec 2022 09:28:25 -0800 Message-Id: <1670347706-23802-3-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1670347706-23802-1-git-send-email-roretzla@linux.microsoft.com> References: <1670271868-11364-1-git-send-email-roretzla@linux.microsoft.com> <1670347706-23802-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 | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/app/test/test_lcores.c b/app/test/test_lcores.c index a6bb412..517dc3c 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,34 @@ static void *ctrl_thread_loop(void *arg) } static int +test_control_thread(void) +{ + rte_thread_t jid; + 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. + */ + jid.opaque_id = t->id; + rte_thread_join(jid, 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 +452,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