All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] test/bitmap: add additional tests
@ 2018-02-09 20:20 Chas Williams
  2018-02-09 20:20 ` [PATCH 2/2] lib: fix bitmap scanning Chas Williams
  0 siblings, 1 reply; 2+ messages in thread
From: Chas Williams @ 2018-02-09 20:20 UTC (permalink / raw)
  To: dev; +Cc: cristian.dumitrescu, Charles (Chas) Williams

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-02-09 20:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-09 20:20 [PATCH 1/2] test/bitmap: add additional tests Chas Williams
2018-02-09 20:20 ` [PATCH 2/2] lib: fix bitmap scanning Chas Williams

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.