From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-devel@nongnu.org, qemu-block@nongnu.org
Cc: pbonzini@redhat.com, eblake@redhat.com, jsnow@redhat.com,
famz@redhat.com, mreitz@redhat.com, kwolf@redhat.com,
jcody@redhat.com, vsementsov@virtuozzo.com, den@openvz.org
Subject: [Qemu-devel] [PATCH v2 2/7] tests: add tests for hbitmap_next_zero with non-zero count parameter
Date: Wed, 8 Aug 2018 15:49:20 +0300 [thread overview]
Message-ID: <20180808124925.21031-3-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20180808124925.21031-1-vsementsov@virtuozzo.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
tests/test-hbitmap.c | 31 +++++++++++++++++++++++++++----
1 file changed, 27 insertions(+), 4 deletions(-)
diff --git a/tests/test-hbitmap.c b/tests/test-hbitmap.c
index 888515b3bb..c11d160633 100644
--- a/tests/test-hbitmap.c
+++ b/tests/test-hbitmap.c
@@ -937,31 +937,48 @@ static void test_hbitmap_iter_and_reset(TestHBitmapData *data,
check_hbitmap_iter_next(&hbi);
}
-static void test_hbitmap_next_zero_check(TestHBitmapData *data, int64_t start)
+static void test_hbitmap_next_zero_check_range(TestHBitmapData *data,
+ int64_t start,
+ int64_t count)
{
- int64_t ret1 = hbitmap_next_zero(data->hb, start, 0);
+ int64_t ret1 = hbitmap_next_zero(data->hb, start, count);
int64_t ret2 = start;
- for ( ; ret2 < data->size && hbitmap_get(data->hb, ret2); ret2++) {
+ int64_t end = count ? start + count : data->size;
+
+ for ( ; ret2 < end && hbitmap_get(data->hb, ret2); ret2++) {
;
}
- if (ret2 == data->size) {
+ if (ret2 == end) {
ret2 = -1;
}
g_assert_cmpint(ret1, ==, ret2);
}
+static void test_hbitmap_next_zero_check(TestHBitmapData *data, int64_t start)
+{
+ test_hbitmap_next_zero_check_range(data, start, 0);
+}
+
static void test_hbitmap_next_zero_do(TestHBitmapData *data, int granularity)
{
hbitmap_test_init(data, L3, granularity);
test_hbitmap_next_zero_check(data, 0);
test_hbitmap_next_zero_check(data, L3 - 1);
+ test_hbitmap_next_zero_check_range(data, 0, 1);
+ test_hbitmap_next_zero_check_range(data, L3 - 1, 1);
hbitmap_set(data->hb, L2, 1);
test_hbitmap_next_zero_check(data, 0);
test_hbitmap_next_zero_check(data, L2 - 1);
test_hbitmap_next_zero_check(data, L2);
test_hbitmap_next_zero_check(data, L2 + 1);
+ test_hbitmap_next_zero_check_range(data, 0, 1);
+ test_hbitmap_next_zero_check_range(data, 0, L2);
+ test_hbitmap_next_zero_check_range(data, L2 - 1, 1);
+ test_hbitmap_next_zero_check_range(data, L2 - 1, 2);
+ test_hbitmap_next_zero_check_range(data, L2, 1);
+ test_hbitmap_next_zero_check_range(data, L2 + 1, 1);
hbitmap_set(data->hb, L2 + 5, L1);
test_hbitmap_next_zero_check(data, 0);
@@ -970,6 +987,10 @@ static void test_hbitmap_next_zero_do(TestHBitmapData *data, int granularity)
test_hbitmap_next_zero_check(data, L2 + 5);
test_hbitmap_next_zero_check(data, L2 + L1 - 1);
test_hbitmap_next_zero_check(data, L2 + L1);
+ test_hbitmap_next_zero_check_range(data, L2, 6);
+ test_hbitmap_next_zero_check_range(data, L2 + 1, 3);
+ test_hbitmap_next_zero_check_range(data, L2 + 4, L1);
+ test_hbitmap_next_zero_check_range(data, L2 + 5, L1);
hbitmap_set(data->hb, L2 * 2, L3 - L2 * 2);
test_hbitmap_next_zero_check(data, L2 * 2 - L1);
@@ -977,6 +998,8 @@ static void test_hbitmap_next_zero_do(TestHBitmapData *data, int granularity)
test_hbitmap_next_zero_check(data, L2 * 2 - 1);
test_hbitmap_next_zero_check(data, L2 * 2);
test_hbitmap_next_zero_check(data, L3 - 1);
+ test_hbitmap_next_zero_check_range(data, L2 * 2 - L1, L1 + 1);
+ test_hbitmap_next_zero_check_range(data, L2 * 2, L2);
hbitmap_set(data->hb, 0, L3);
test_hbitmap_next_zero_check(data, 0);
--
2.11.1
next prev parent reply other threads:[~2018-08-08 12:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-08 12:49 [Qemu-devel] [PATCH v2 0/7] dirty-bitmap: rewrite bdrv_dirty_iter_next_area Vladimir Sementsov-Ogievskiy
2018-08-08 12:49 ` [Qemu-devel] [PATCH v2 1/7] dirty-bitmap: improve bdrv_dirty_bitmap_next_zero Vladimir Sementsov-Ogievskiy
2018-08-08 12:49 ` Vladimir Sementsov-Ogievskiy [this message]
2018-08-08 12:49 ` [Qemu-devel] [PATCH v2 3/7] dirty-bitmap: add bdrv_dirty_bitmap_next_dirty_area Vladimir Sementsov-Ogievskiy
2018-08-10 17:05 ` Vladimir Sementsov-Ogievskiy
2018-08-13 15:42 ` Vladimir Sementsov-Ogievskiy
2018-08-08 12:49 ` [Qemu-devel] [PATCH v2 4/7] block/mirror: fix and improve do_sync_target_write Vladimir Sementsov-Ogievskiy
2018-08-08 12:49 ` [Qemu-devel] [PATCH v2 5/7] Revert "block/dirty-bitmap: Add bdrv_dirty_iter_next_area" Vladimir Sementsov-Ogievskiy
2018-08-08 12:49 ` [Qemu-devel] [PATCH v2 6/7] Revert "test-hbitmap: Add non-advancing iter_next tests" Vladimir Sementsov-Ogievskiy
2018-08-08 12:49 ` [Qemu-devel] [PATCH v2 7/7] Revert "hbitmap: Add @advance param to hbitmap_iter_next()" Vladimir Sementsov-Ogievskiy
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=20180808124925.21031-3-vsementsov@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=den@openvz.org \
--cc=eblake@redhat.com \
--cc=famz@redhat.com \
--cc=jcody@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).