From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vivek Sharma Subject: [PATCH 2/2] test/bitmap: implement reverse bitmap scan test Date: Tue, 9 Oct 2018 13:24:59 +0530 Message-ID: <1539071699-29963-3-git-send-email-vivek.sharma@caviumnetworks.com> References: <1539071699-29963-1-git-send-email-vivek.sharma@caviumnetworks.com> Mime-Version: 1.0 Content-Type: text/plain Cc: cristian.dumitrescu@intel.com, Vivek Sharma To: dev@dpdk.org Return-path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0055.outbound.protection.outlook.com [104.47.32.55]) by dpdk.org (Postfix) with ESMTP id 22AF45F32 for ; Tue, 9 Oct 2018 09:55:24 +0200 (CEST) In-Reply-To: <1539071699-29963-1-git-send-email-vivek.sharma@caviumnetworks.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patch implements support for testing bitmap reverse scan. Bits in bitmap are changed to be an exact multiple of slab size. Signed-off-by: Vivek Sharma --- Prerequisite: * Note that this patchset is dependent on patch: 'http://patches.dpdk.org/patch/45307/' test/test/test_bitmap.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/test/test/test_bitmap.c b/test/test/test_bitmap.c index 95c5184..21a193b 100644 --- a/test/test/test_bitmap.c +++ b/test/test/test_bitmap.c @@ -11,7 +11,7 @@ #include "test.h" -#define MAX_BITS 1000 +#define MAX_BITS 1024 static int test_bitmap_scan_operations(struct rte_bitmap *bmp) @@ -74,6 +74,72 @@ test_bitmap_scan_operations(struct rte_bitmap *bmp) } static int +test_bitmap_scan_reverse_operations(struct rte_bitmap *bmp) +{ + uint32_t pos = 0; + uint64_t slab1_magic = 0xBADC0FFEEBADF00D; + uint64_t slab2_magic = 0xFEEDDEADDEADF00D; + uint64_t out_slab = 0; + + rte_bitmap_reset(bmp); + + rte_bitmap_set_slab(bmp, MAX_BITS - RTE_BITMAP_SLAB_BIT_SIZE, + slab2_magic); + rte_bitmap_set_slab(bmp, MAX_BITS - (2 * RTE_BITMAP_SLAB_BIT_SIZE), + slab1_magic); + + if (!rte_bitmap_scan_generic(bmp, &pos, &out_slab, + RTE_BITMAP_REV_SCAN)) { + printf("Failed to get slab from bitmap.\n"); + return TEST_FAILED; + } + + if (slab2_magic != out_slab) { + printf("Scan operation sanity failed.\n"); + return TEST_FAILED; + } + + if (!rte_bitmap_scan_generic(bmp, &pos, &out_slab, + RTE_BITMAP_REV_SCAN)) { + printf("Failed to get slab from bitmap.\n"); + return TEST_FAILED; + } + + if (slab1_magic != out_slab) { + printf("Scan operation sanity failed.\n"); + return TEST_FAILED; + } + + /* Wrap around */ + if (!rte_bitmap_scan_generic(bmp, &pos, &out_slab, + RTE_BITMAP_REV_SCAN)) { + printf("Failed to get slab from bitmap.\n"); + return TEST_FAILED; + } + + if (slab2_magic != out_slab) { + printf("Scan operation wrap around failed.\n"); + return TEST_FAILED; + } + + /* Scan reset check. */ + __rte_bitmap_scan_init_generic(bmp, RTE_BITMAP_REV_SCAN); + + if (!rte_bitmap_scan_generic(bmp, &pos, &out_slab, + RTE_BITMAP_REV_SCAN)) { + printf("Failed to get slab from bitmap.\n"); + return TEST_FAILED; + } + + if (slab2_magic != out_slab) { + printf("Scan reset operation failed.\n"); + return TEST_FAILED; + } + + return TEST_SUCCESS; +} + +static int test_bitmap_slab_set_get(struct rte_bitmap *bmp) { uint32_t pos = 0; @@ -176,6 +242,9 @@ test_bitmap(void) if (test_bitmap_scan_operations(bmp) < 0) return TEST_FAILED; + if (test_bitmap_scan_reverse_operations(bmp) < 0) + return TEST_FAILED; + rte_bitmap_free(bmp); rte_free(mem); -- 2.7.4