DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andre Muezerie <andremue@linux.microsoft.com>
To: dev@dpdk.org
Cc: Andre Muezerie <andremue@linux.microsoft.com>
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	[thread overview]
Message-ID: <1737735244-23234-4-git-send-email-andremue@linux.microsoft.com> (raw)
In-Reply-To: <1737735244-23234-1-git-send-email-andremue@linux.microsoft.com>

Add tests for new rte_ffs32 and rte_ffs64 functions.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 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


      parent reply	other threads:[~2025-01-24 16:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-20 21:24 [PATCH 0/2] provide rte_ffs32, rte_ffs64 and __rte_x86_movdiri for MSVC Tyler Retzlaff
2024-03-20 21:24 ` [PATCH 1/2] eal: provide movdiri " Tyler Retzlaff
2024-03-20 21:24 ` [PATCH 2/2] eal: add rte ffs32 and rte ffs64 inline functions Tyler Retzlaff
2024-06-14 14:49   ` David Marchand
2024-12-05 20:17     ` Andre Muezerie
2024-12-05 20:35 ` [PATCH v2 0/3] provide rte_ffs32, rte_ffs64 and __rte_x86_movdiri Andre Muezerie
2024-12-05 20:35   ` [PATCH v2 1/3] eal: provide movdiri for MSVC Andre Muezerie
2024-12-05 20:35   ` [PATCH v2 2/3] eal: add rte ffs32 and rte ffs64 inline functions Andre Muezerie
2024-12-05 20:35   ` [PATCH v2 3/3] app/test: add test for rte_ffs32 and rte_ffs64 functions Andre Muezerie
2025-01-24 14:53   ` [PATCH v2 0/3] provide rte_ffs32, rte_ffs64 and __rte_x86_movdiri David Marchand
2025-01-24 16:16     ` Andre Muezerie
2025-01-24 16:14 ` [PATCH v3 " Andre Muezerie
2025-01-24 16:14   ` [PATCH v3 1/3] eal: provide movdiri for MSVC Andre Muezerie
2025-01-24 16:14   ` [PATCH v3 2/3] eal: add rte ffs32 and rte ffs64 inline functions Andre Muezerie
2025-01-24 16:14   ` Andre Muezerie [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1737735244-23234-4-git-send-email-andremue@linux.microsoft.com \
    --to=andremue@linux.microsoft.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).