[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 2/8] tests: add tests for hbitmap_next_zero with spec
From: |
John Snow |
Subject: |
[Qemu-devel] [PULL 2/8] tests: add tests for hbitmap_next_zero with specified end parameter |
Date: |
Tue, 15 Jan 2019 20:01:00 -0500 |
From: Vladimir Sementsov-Ogievskiy <address@hidden>
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Signed-off-by: John Snow <address@hidden>
---
tests/test-hbitmap.c | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
diff --git a/tests/test-hbitmap.c b/tests/test-hbitmap.c
index b04a45a2de..c0da31a6bd 100644
--- a/tests/test-hbitmap.c
+++ b/tests/test-hbitmap.c
@@ -937,31 +937,49 @@ 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,
+ uint64_t start,
+ uint64_t count)
{
- int64_t ret1 = hbitmap_next_zero(data->hb, start, UINT64_MAX);
+ 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 = start >= data->size || data->size - start < count ?
+ data->size : start + count;
+
+ 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, UINT64_MAX);
+}
+
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 +988,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 +999,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.17.2
- [Qemu-devel] [PULL 0/8] Bitmaps patches, John Snow, 2019/01/15
- [Qemu-devel] [PULL 5/8] block/mirror: fix and improve do_sync_target_write, John Snow, 2019/01/15
- [Qemu-devel] [PULL 1/8] dirty-bitmap: improve bdrv_dirty_bitmap_next_zero, John Snow, 2019/01/15
- [Qemu-devel] [PULL 2/8] tests: add tests for hbitmap_next_zero with specified end parameter,
John Snow <=
- [Qemu-devel] [PULL 4/8] tests: add tests for hbitmap_next_dirty_area, John Snow, 2019/01/15
- [Qemu-devel] [PULL 6/8] Revert "block/dirty-bitmap: Add bdrv_dirty_iter_next_area", John Snow, 2019/01/15
- [Qemu-devel] [PULL 3/8] dirty-bitmap: add bdrv_dirty_bitmap_next_dirty_area, John Snow, 2019/01/15
- [Qemu-devel] [PULL 7/8] Revert "test-hbitmap: Add non-advancing iter_next tests", John Snow, 2019/01/15
- [Qemu-devel] [PULL 8/8] Revert "hbitmap: Add @advance param to hbitmap_iter_next()", John Snow, 2019/01/15
- Re: [Qemu-devel] [PULL 0/8] Bitmaps patches, Peter Maydell, 2019/01/17
- Re: [Qemu-devel] [PULL 0/8] Bitmaps patches, no-reply, 2019/01/21