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 59B09A034F; Wed, 10 Nov 2021 04:02:21 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D172B4113C; Wed, 10 Nov 2021 04:01:53 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id B207940E28 for ; Wed, 10 Nov 2021 04:01:47 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1059) id 6D1F920C355A; Tue, 9 Nov 2021 19:01:46 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 6D1F920C355A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1636513306; bh=5C4heeV4WBx39de1HrNbOSDdCF+ltXwjmM5xOk+Yt3Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rzUoZ48I/cXTsZitcEGlLISDoI4tUbEaUoe6F+vWnwrgukNSaPoauChc0r+QiTmeq oJGuEvTYnNTUdFzQWDWTwvh4ezu1pdoQAQQDfvv4AtPnFs+b3MF+S8YW15Uc3qmpfk L4WmwoqUn1ga9hNXRLNPfRfn6iktDdz0Ng3aZ+Lw= From: Narcisa Ana Maria Vasile To: dev@dpdk.org, thomas@monjalon.net, dmitry.kozliuk@gmail.com, khot@microsoft.com, navasile@microsoft.com, dmitrym@microsoft.com, roretzla@microsoft.com, talshn@nvidia.com, ocardona@microsoft.com Cc: bruce.richardson@intel.com, david.marchand@redhat.com, pallavi.kadam@intel.com Date: Tue, 9 Nov 2021 19:01:38 -0800 Message-Id: <1636513302-7359-10-git-send-email-navasile@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1636513302-7359-1-git-send-email-navasile@linux.microsoft.com> References: <1633765318-28356-1-git-send-email-navasile@linux.microsoft.com> <1636513302-7359-1-git-send-email-navasile@linux.microsoft.com> Subject: [dpdk-dev] [PATCH v17 09/13] app/test: add unit tests for thread lifetime management 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" From: Narcisa Vasile As a new API for threading is introduced, a set of unit tests have been added to test the new interface. Verify that threads are created and cleaned up correctly. Signed-off-by: Narcisa Vasile --- app/test/test_threads.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/app/test/test_threads.c b/app/test/test_threads.c index 53e5892793..9fcae34179 100644 --- a/app/test/test_threads.c +++ b/app/test/test_threads.c @@ -167,6 +167,34 @@ test_thread_attributes_priority(void) return ret; } +static void * +thread_loop_return(void *arg) +{ + RTE_SET_USED(arg); + return NULL; +} + +static int +test_thread_detach(void) +{ + rte_thread_t threads_ids[THREADS_COUNT]; + size_t i; + int ret = 0; + + for (i = 0; i < THREADS_COUNT; ++i) { + ret = rte_thread_create(&threads_ids[i], NULL, + thread_loop_return, NULL); + RTE_TEST_ASSERT(ret == 0, "Failed to create threads!"); + } + + for (i = 0; i < THREADS_COUNT; ++i) { + ret = rte_thread_detach(threads_ids[i]); + RTE_TEST_ASSERT(ret == 0, "Failed to detach thread!"); + } + + return ret; +} + static struct unit_test_suite threads_test_suite = { .suite_name = "threads autotest", .setup = NULL, @@ -175,6 +203,7 @@ static struct unit_test_suite threads_test_suite = { TEST_CASE(test_thread_self), TEST_CASE(test_thread_attributes_affinity), TEST_CASE(test_thread_attributes_priority), + TEST_CASE(test_thread_detach), TEST_CASES_END() } }; -- 2.31.0.vfs.0.1