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 324F945E3C; Thu, 5 Dec 2024 21:36:22 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8732240DD3; Thu, 5 Dec 2024 21:36:13 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 03F5540A87 for ; Thu, 5 Dec 2024 21:36:09 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1213) id 545F820ACD87; Thu, 5 Dec 2024 12:36:09 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 545F820ACD87 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1733430969; bh=Zb9EKkm4A70gnrrCQpmqdDsDsjzf3Y+JRNcLFBXm0Hc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RpX2KZ8eGJpPlBTxSoEEEzvecpqnBjmQTEHMOUIOVoYRwCJ/LvgeuELZLjuchwxtU 8fbDvr80/EvqwrWS4HO7Q1giOFMP4itzFr5jBMh5rRpqMH9Bn2IBRAxzRQ4LrcHmBz U6GYRAMtCDRA/pKS2o3WCLus/y5954UnfykRUiuI= From: Andre Muezerie To: dev@dpdk.org Cc: Andre Muezerie Subject: [PATCH v2 3/3] app/test: add test for rte_ffs32 and rte_ffs64 functions. Date: Thu, 5 Dec 2024 12:35:50 -0800 Message-Id: <1733430950-10412-4-git-send-email-andremue@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1733430950-10412-1-git-send-email-andremue@linux.microsoft.com> References: <1710969879-23701-1-git-send-email-roretzla@linux.microsoft.com> <1733430950-10412-1-git-send-email-andremue@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 Add tests for new rte_ffs32 and rte_ffs64 functions. Signed-off-by: Andre Muezerie --- app/test/test_bitops.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/app/test/test_bitops.c b/app/test/test_bitops.c index 78a7df6bb1..dd374d7883 100644 --- a/app/test/test_bitops.c +++ b/app/test/test_bitops.c @@ -406,6 +406,42 @@ test_bit_relaxed_test_set_clear(void) return TEST_SUCCESS; } +static int +test_bit_scan_forward(void) +{ + unsigned int bit_nr; + + TEST_ASSERT((bit_nr = rte_ffs32(0)) == 0, + "rte_ffs32 returned unexpected %d", bit_nr); + + for (int i = 0; i < 32; ++i) { + uint32_t n = RTE_BIT32(i); + + TEST_ASSERT((bit_nr = rte_ffs32(n)) == (unsigned int)(i+1), + "rte_ffs32 returned unexpected %d", bit_nr); + } + + return TEST_SUCCESS; +} + +static int +test_bit_scan_forward64(void) +{ + unsigned int bit_nr; + + TEST_ASSERT((bit_nr = rte_ffs64(0)) == 0, + "rte_ffs64 returned unexpected %d", bit_nr); + + for (int i = 0; i < 64; ++i) { + uint64_t n = RTE_BIT64(i); + + TEST_ASSERT((bit_nr = rte_ffs64(n)) == (unsigned int)(i+1), + "rte_ffs64 returned unexpected %d", bit_nr); + } + + return TEST_SUCCESS; +} + static struct unit_test_suite test_suite = { .suite_name = "Bitops test suite", .unit_test_cases = { @@ -428,6 +464,8 @@ static struct unit_test_suite test_suite = { TEST_CASE(test_bit_relaxed_set), TEST_CASE(test_bit_relaxed_clear), TEST_CASE(test_bit_relaxed_test_set_clear), + TEST_CASE(test_bit_scan_forward), + TEST_CASE(test_bit_scan_forward64), TEST_CASES_END() } }; -- 2.47.0.vfs.0.3