From: Chas Williams <3chas3@gmail.com>
To: dev@dpdk.org
Cc: cristian.dumitrescu@intel.com, "Charles (Chas) Williams" <chas3@att.com>
Subject: [PATCH 1/2] test/bitmap: add additional tests
Date: Fri, 9 Feb 2018 15:20:02 -0500 [thread overview]
Message-ID: <20180209202003.28546-1-3chas3@gmail.com> (raw)
From: "Charles (Chas) Williams" <chas3@att.com>
Add addtional units tests for the rte_bitmap_scan() routine. Test that
we are gettting the bits returned that we expect.
Signed-off-by: Chas Williams <chas3@att.com>
---
test/test/test_bitmap.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 68 insertions(+)
diff --git a/test/test/test_bitmap.c b/test/test/test_bitmap.c
index 05d547e..f498c02 100644
--- a/test/test/test_bitmap.c
+++ b/test/test/test_bitmap.c
@@ -74,6 +74,71 @@ test_bitmap_scan_operations(struct rte_bitmap *bmp)
}
static int
+test_bitmap_scan_operations2(struct rte_bitmap *bmp)
+{
+ uint32_t pos = 0;
+ uint64_t out_slab = 0;
+ uint32_t pattern[] = { 10, 11, 100, 101, 500, 501 };
+ uint32_t pattern2[] = { 11, 101, 501 };
+ uint32_t i;
+
+ rte_bitmap_reset(bmp);
+
+ /* Setup the initial bitmap. */
+ for (i = 0; i < sizeof(pattern)/sizeof(uint32_t); i++)
+ rte_bitmap_set(bmp, pattern[i]);
+
+ /* Iterate. */
+ for (i = 0; i < sizeof(pattern)/sizeof(uint32_t); i++) {
+ if (!rte_bitmap_scan(bmp, &pos, &out_slab) ||
+ pos != pattern[i]) {
+ printf("Failed to get pos %d from bitmap.\n",
+ pattern[i]);
+ return TEST_FAILED;
+ }
+ }
+
+ /* Check wrap around. */
+ if (!rte_bitmap_scan(bmp, &pos, &out_slab) || pos != pattern[0]) {
+ printf("Failed to get pos %d from bitmap.\n", pattern[0]);
+ return TEST_FAILED;
+ }
+
+ /* Delete half the entries in the slabs. */
+ rte_bitmap_clear(bmp, 10);
+ rte_bitmap_clear(bmp, 100);
+ rte_bitmap_clear(bmp, 500);
+
+ /* Iterate. */
+ for (i = 0; i < sizeof(pattern2)/sizeof(uint32_t); i++) {
+ if (!rte_bitmap_scan(bmp, &pos, &out_slab) ||
+ pos != pattern2[i]) {
+ printf("Failed to get pos %d from bitmap.\n",
+ pattern2[i]);
+ return TEST_FAILED;
+ }
+ }
+
+ /* Check wrap around. */
+ if (!rte_bitmap_scan(bmp, &pos, &out_slab) || pos != pattern2[0]) {
+ printf("Failed to get pos %d from bitmap.\n", pattern2[0]);
+ return TEST_FAILED;
+ }
+
+ rte_bitmap_clear(bmp, 11);
+ rte_bitmap_clear(bmp, 101);
+ rte_bitmap_clear(bmp, 501);
+
+ /* Ensure bitmap it empty. */
+ if (rte_bitmap_scan(bmp, &pos, &out_slab)) {
+ printf("Found pos %d in empty bitmap.\n", pos);
+ return TEST_FAILED;
+ }
+
+ return TEST_SUCCESS;
+}
+
+static int
test_bitmap_slab_set_get(struct rte_bitmap *bmp)
{
uint32_t pos = 0;
@@ -158,6 +223,9 @@ test_bitmap(void)
if (test_bitmap_scan_operations(bmp) < 0)
return TEST_FAILED;
+ if (test_bitmap_scan_operations2(bmp) < 0)
+ return TEST_FAILED;
+
return TEST_SUCCESS;
}
--
2.9.5
next reply other threads:[~2018-02-09 20:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-09 20:20 Chas Williams [this message]
2018-02-09 20:20 ` [PATCH 2/2] lib: fix bitmap scanning Chas Williams
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=20180209202003.28546-1-3chas3@gmail.com \
--to=3chas3@gmail.com \
--cc=chas3@att.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.