From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chas Williams <3chas3@gmail.com> Subject: [PATCH 1/2] test/bitmap: add additional tests Date: Fri, 9 Feb 2018 15:20:02 -0500 Message-ID: <20180209202003.28546-1-3chas3@gmail.com> Cc: cristian.dumitrescu@intel.com, "Charles (Chas) Williams" To: dev@dpdk.org Return-path: Received: from mail-qk0-f195.google.com (mail-qk0-f195.google.com [209.85.220.195]) by dpdk.org (Postfix) with ESMTP id 9C4491B88F for ; Fri, 9 Feb 2018 21:20:09 +0100 (CET) Received: by mail-qk0-f195.google.com with SMTP id n188so11531406qkn.11 for ; Fri, 09 Feb 2018 12:20:09 -0800 (PST) List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: "Charles (Chas) Williams" 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 --- 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