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 E4D1F4612D; Fri, 24 Jan 2025 17:14:14 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A8590402CC; Fri, 24 Jan 2025 17:14:14 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 12E6B4279A for ; Fri, 24 Jan 2025 17:14:13 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1213) id 7DFB8210D0C6; Fri, 24 Jan 2025 08:14:12 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 7DFB8210D0C6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1737735252; bh=VwS46Q+IqRv1oR1h0n4t7Eb1Y9wkqljnsK44aEHxo44=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H3/xwhLyAVxcHoHvbADPpyhRRuVlMO7RgF2vHc/J4Z90f60b+PhsgBKwbCd5SzHzZ oAzUJhDebErHwPqvG/+/8gH8eI2z6GDfm3w2MAICDwMuKHNriAi+2ODSgDgbr5/ECx Mppe4BOaAXFfAGupEdv4ZVJ0/riJbsHbodah2EgQ= From: Andre Muezerie To: dev@dpdk.org Cc: Andre Muezerie Subject: [PATCH v3 3/3] app/test: add test for rte_ffs32 and rte_ffs64 functions. Date: Fri, 24 Jan 2025 08:14:04 -0800 Message-Id: <1737735244-23234-4-git-send-email-andremue@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1737735244-23234-1-git-send-email-andremue@linux.microsoft.com> References: <1710969879-23701-1-git-send-email-roretzla@linux.microsoft.com> <1737735244-23234-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_bitcount.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/app/test/test_bitcount.c b/app/test/test_bitcount.c index 83c68feb7b..8eb4a460f2 100644 --- a/app/test/test_bitcount.c +++ b/app/test/test_bitcount.c @@ -12,6 +12,42 @@ RTE_LOG_REGISTER(bitcount_logtype_test, test.bitcount, INFO); +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 int test_clz32(void) { @@ -117,6 +153,8 @@ static struct unit_test_suite bitcount_test_suite = { .setup = NULL, .teardown = NULL, .unit_test_cases = { + TEST_CASE(test_bit_scan_forward), + TEST_CASE(test_bit_scan_forward64), TEST_CASE(test_clz32), TEST_CASE(test_clz64), TEST_CASE(test_ctz32), -- 2.47.2.vfs.0.1