DPDK patches and discussions
 help / color / mirror / Atom feed
From: Suanming Mou <suanmingm@mellanox.com>
To: cristian.dumitrescu@intel.com, dev@dpdk.org
Cc: amo@semihalf.com
Subject: [dpdk-dev] [PATCH v3 2/2] test/bitmap: add bitmap create with all bits set case
Date: Fri, 10 Apr 2020 20:46:27 +0800	[thread overview]
Message-ID: <1586522787-403236-3-git-send-email-suanmingm@mellanox.com> (raw)
In-Reply-To: <1586522787-403236-1-git-send-email-suanmingm@mellanox.com>

Add the case to verify bitmap create with all bits set works
correctly.

Signed-off-by: Suanming Mou <suanmingm@mellanox.com>
---
 app/test/test_bitmap.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 56 insertions(+), 1 deletion(-)

diff --git a/app/test/test_bitmap.c b/app/test/test_bitmap.c
index 95c5184..a8204d3 100644
--- a/app/test/test_bitmap.c
+++ b/app/test/test_bitmap.c
@@ -146,7 +146,7 @@
 }
 
 static int
-test_bitmap(void)
+test_bitmap_all_clear(void)
 {
 	void *mem;
 	uint32_t bmp_size;
@@ -182,4 +182,59 @@
 	return TEST_SUCCESS;
 }
 
+static int
+test_bitmap_all_set(void)
+{
+	void *mem;
+	uint32_t i;
+	uint64_t slab;
+	uint32_t pos;
+	uint32_t bmp_size;
+	struct rte_bitmap *bmp;
+
+	bmp_size =
+		rte_bitmap_get_memory_footprint(MAX_BITS);
+
+	mem = rte_zmalloc("test_bmap", bmp_size, RTE_CACHE_LINE_SIZE);
+	if (mem == NULL) {
+		printf("Failed to allocate memory for bitmap\n");
+		return TEST_FAILED;
+	}
+
+	bmp = rte_bitmap_init_with_all_set(MAX_BITS, mem, bmp_size);
+	if (bmp == NULL) {
+		printf("Failed to init bitmap\n");
+		return TEST_FAILED;
+	}
+
+	for (i = 0; i < MAX_BITS; i++) {
+		pos = slab = 0;
+		if (!rte_bitmap_scan(bmp, &pos, &slab)) {
+			printf("Failed with init bitmap.\n");
+			return TEST_FAILED;
+		}
+		pos += (slab ? __builtin_ctzll(slab) : 0);
+		rte_bitmap_clear(bmp, pos);
+	}
+
+	if (rte_bitmap_scan(bmp, &pos, &slab)) {
+		printf("Too much bits set.\n");
+		return TEST_FAILED;
+	}
+
+	rte_bitmap_free(bmp);
+	rte_free(mem);
+
+	return TEST_SUCCESS;
+
+}
+
+static int
+test_bitmap(void)
+{
+	if (test_bitmap_all_clear() != TEST_SUCCESS)
+		return TEST_FAILED;
+	return test_bitmap_all_set();
+}
+
 REGISTER_TEST_COMMAND(bitmap_test, test_bitmap);
-- 
1.8.3.1


  parent reply	other threads:[~2020-04-10 12:46 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-10  8:21 [dpdk-dev] [PATCH 0/2] bitmap: add create bitmap with all bits set Suanming Mou
2020-03-10  8:21 ` [dpdk-dev] [PATCH 1/2] " Suanming Mou
2020-04-03 14:49   ` Andrzej Ostruszka
2020-04-07  6:19     ` Suanming Mou
2020-04-07 15:00       ` Suanming Mou
2020-04-07 17:48   ` Dumitrescu, Cristian
2020-04-08  2:57     ` Suanming Mou
2020-03-10  8:21 ` [dpdk-dev] [PATCH 2/2] test/bitmap: add bitmap create with all bits set case Suanming Mou
2020-03-25 13:25 ` [dpdk-dev] [PATCH 0/2] bitmap: add create bitmap with all bits set Thomas Monjalon
2020-04-02 13:44   ` Suanming Mou
2020-04-08  3:05 ` [dpdk-dev] [PATCH v2 " Suanming Mou
2020-04-08  3:05   ` [dpdk-dev] [PATCH v2 1/2] " Suanming Mou
2020-04-09 14:16     ` Dumitrescu, Cristian
2020-04-10 10:34       ` Suanming Mou
2020-04-10 11:21         ` Dumitrescu, Cristian
2020-04-10 12:30           ` Suanming Mou
2020-04-08  3:05   ` [dpdk-dev] [PATCH v2 2/2] test/bitmap: add bitmap create with all bits set case Suanming Mou
2020-04-10 12:46 ` [dpdk-dev] [PATCH v3 0/2] bitmap: add create bitmap with all bits set Suanming Mou
2020-04-10 12:46   ` [dpdk-dev] [PATCH v3 1/2] " Suanming Mou
2020-04-10 16:04     ` Dumitrescu, Cristian
2020-04-10 12:46   ` Suanming Mou [this message]
2020-04-15 14:15 ` [dpdk-dev] [PATCH v4] bitmap: add init " Thomas Monjalon
2020-04-15 14:22   ` Suanming Mou
2020-04-15 14:42     ` Thomas Monjalon

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=1586522787-403236-3-git-send-email-suanmingm@mellanox.com \
    --to=suanmingm@mellanox.com \
    --cc=amo@semihalf.com \
    --cc=cristian.dumitrescu@intel.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).