From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <3chas3@gmail.com> 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=cMkZIc2Hso5tMCqMuai7+ADjyl1K5VwmoshUYMybB88=; b=RsvWMsNqa2erPtvhpQuBDRkcJBeRYB6iYK6Jy5x9iy+XjHVCxTJMkEIty3RXhuommH SAkolbW+LyZ9KkcCjdBhpcTdCnsYFwiX+eNVLm9ATw6T//vBRg5ZzMitmZSs0mbcu0DP wigod1NBAyTu2tPbJeKjmXaSBstGKrsB9W+HKZU2zB/CTzKp6BxVMdwIePOjlaq2H9YU 4xBCYZq6ozXHSDWGRxVhz55UZMPMJKd8UIZjzF2q5cFN9nDqvEg8sFyhFnTWO07yzWI6 hnKI7FoE4vE2bPgO/gE3Rc5EYA1AJ9muK8U+clvyd/onjcAcQvEwzkQy+GtUsmLdqX8m n/5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=cMkZIc2Hso5tMCqMuai7+ADjyl1K5VwmoshUYMybB88=; b=ecvUgvn6PDcDXZiDVF58vEdD0CbgFktL2iCDqMVaQu3I1JbfRkQLqJka/cno8pT575 ZDctSecQYEm7lMsEU/vRPRLFsZ3JPisJ+2uLp6E+EUOmp2fzQnePTP+HG3ilybRX8lAA SkGUu5b/iVaYj7RWmQ+2cqY+3scYWnZ8/V7D5banPf2WMEi9k8uVeXLUF+zZhT2nv4K9 bO45ykzk6Z581sQgFMDeqcJNTw6K3HeItka3IY+JuhHh6zZM7SVGqVgc3v9Iv259yyjR 5FvUoH+PeBV+nhnXREg2aCNP+F67dk419o2UxcltIiKuJPSHD+fabyB4EAKRGo6OKYh8 ZHPQ== X-Gm-Message-State: APf1xPA3EvooVzLfeqCdY9dwVs60wAS1dYalwS9g/ESjsCA075UEtfdV qkdCHHk6WgB7/Mw1mrYb87ss1w== X-Google-Smtp-Source: AH8x225CBUq+s5UkX1muElq5muZQe9ra1TOvdf0ygH5GE5wY2VxQMN/OcJGWfU2H7wrnv2Te4P1NmA== X-Received: by 10.55.167.206 with SMTP id q197mr6003353qke.97.1518207608878; Fri, 09 Feb 2018 12:20:08 -0800 (PST) Received: from monolith.home (pool-173-79-224-159.washdc.fios.verizon.net. [173.79.224.159]) by smtp.gmail.com with ESMTPSA id l36sm2421598qte.55.2018.02.09.12.20.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Feb 2018 12:20:08 -0800 (PST) From: Chas Williams <3chas3@gmail.com> To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com, "Charles (Chas) Williams" Date: Fri, 9 Feb 2018 15:20:02 -0500 Message-Id: <20180209202003.28546-1-3chas3@gmail.com> X-Mailer: git-send-email 2.9.5 Subject: [dpdk-dev] [PATCH 1/2] test/bitmap: add additional tests X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Feb 2018 20:20:09 -0000 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