Blame SOURCES/kvm-tests-add-tests-for-hbitmap_next_zero-with-specified.patch

7711c0
From 3f336fb2dbf569591917be5a01fa8f760fa8ee77 Mon Sep 17 00:00:00 2001
7711c0
From: John Snow <jsnow@redhat.com>
7711c0
Date: Wed, 20 Mar 2019 21:48:30 +0100
7711c0
Subject: [PATCH 037/163] tests: add tests for hbitmap_next_zero with specified
7711c0
 end parameter
7711c0
7711c0
RH-Author: John Snow <jsnow@redhat.com>
7711c0
Message-id: <20190320214838.22027-3-jsnow@redhat.com>
7711c0
Patchwork-id: 84994
7711c0
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 02/10] tests: add tests for hbitmap_next_zero with specified end parameter
7711c0
Bugzilla: 1691048
7711c0
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
7711c0
RH-Acked-by: Max Reitz <mreitz@redhat.com>
7711c0
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
7711c0
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
7711c0
7711c0
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
7711c0
(cherry picked from commit fa9c2da29404be9baeb7b8f88fed3cb232688cd9)
7711c0
Signed-off-by: John Snow <jsnow@redhat.com>
7711c0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
---
7711c0
 tests/test-hbitmap.c | 32 ++++++++++++++++++++++++++++----
7711c0
 1 file changed, 28 insertions(+), 4 deletions(-)
7711c0
7711c0
diff --git a/tests/test-hbitmap.c b/tests/test-hbitmap.c
7711c0
index b04a45a..c0da31a 100644
7711c0
--- a/tests/test-hbitmap.c
7711c0
+++ b/tests/test-hbitmap.c
7711c0
@@ -937,31 +937,49 @@ static void test_hbitmap_iter_and_reset(TestHBitmapData *data,
7711c0
     check_hbitmap_iter_next(&hbi;;
7711c0
 }
7711c0
 
7711c0
-static void test_hbitmap_next_zero_check(TestHBitmapData *data, int64_t start)
7711c0
+static void test_hbitmap_next_zero_check_range(TestHBitmapData *data,
7711c0
+                                               uint64_t start,
7711c0
+                                               uint64_t count)
7711c0
 {
7711c0
-    int64_t ret1 = hbitmap_next_zero(data->hb, start, UINT64_MAX);
7711c0
+    int64_t ret1 = hbitmap_next_zero(data->hb, start, count);
7711c0
     int64_t ret2 = start;
7711c0
-    for ( ; ret2 < data->size && hbitmap_get(data->hb, ret2); ret2++) {
7711c0
+    int64_t end = start >= data->size || data->size - start < count ?
7711c0
+                data->size : start + count;
7711c0
+
7711c0
+    for ( ; ret2 < end && hbitmap_get(data->hb, ret2); ret2++) {
7711c0
         ;
7711c0
     }
7711c0
-    if (ret2 == data->size) {
7711c0
+    if (ret2 == end) {
7711c0
         ret2 = -1;
7711c0
     }
7711c0
 
7711c0
     g_assert_cmpint(ret1, ==, ret2);
7711c0
 }
7711c0
 
7711c0
+static void test_hbitmap_next_zero_check(TestHBitmapData *data, int64_t start)
7711c0
+{
7711c0
+    test_hbitmap_next_zero_check_range(data, start, UINT64_MAX);
7711c0
+}
7711c0
+
7711c0
 static void test_hbitmap_next_zero_do(TestHBitmapData *data, int granularity)
7711c0
 {
7711c0
     hbitmap_test_init(data, L3, granularity);
7711c0
     test_hbitmap_next_zero_check(data, 0);
7711c0
     test_hbitmap_next_zero_check(data, L3 - 1);
7711c0
+    test_hbitmap_next_zero_check_range(data, 0, 1);
7711c0
+    test_hbitmap_next_zero_check_range(data, L3 - 1, 1);
7711c0
 
7711c0
     hbitmap_set(data->hb, L2, 1);
7711c0
     test_hbitmap_next_zero_check(data, 0);
7711c0
     test_hbitmap_next_zero_check(data, L2 - 1);
7711c0
     test_hbitmap_next_zero_check(data, L2);
7711c0
     test_hbitmap_next_zero_check(data, L2 + 1);
7711c0
+    test_hbitmap_next_zero_check_range(data, 0, 1);
7711c0
+    test_hbitmap_next_zero_check_range(data, 0, L2);
7711c0
+    test_hbitmap_next_zero_check_range(data, L2 - 1, 1);
7711c0
+    test_hbitmap_next_zero_check_range(data, L2 - 1, 2);
7711c0
+    test_hbitmap_next_zero_check_range(data, L2, 1);
7711c0
+    test_hbitmap_next_zero_check_range(data, L2 + 1, 1);
7711c0
 
7711c0
     hbitmap_set(data->hb, L2 + 5, L1);
7711c0
     test_hbitmap_next_zero_check(data, 0);
7711c0
@@ -970,6 +988,10 @@ static void test_hbitmap_next_zero_do(TestHBitmapData *data, int granularity)
7711c0
     test_hbitmap_next_zero_check(data, L2 + 5);
7711c0
     test_hbitmap_next_zero_check(data, L2 + L1 - 1);
7711c0
     test_hbitmap_next_zero_check(data, L2 + L1);
7711c0
+    test_hbitmap_next_zero_check_range(data, L2, 6);
7711c0
+    test_hbitmap_next_zero_check_range(data, L2 + 1, 3);
7711c0
+    test_hbitmap_next_zero_check_range(data, L2 + 4, L1);
7711c0
+    test_hbitmap_next_zero_check_range(data, L2 + 5, L1);
7711c0
 
7711c0
     hbitmap_set(data->hb, L2 * 2, L3 - L2 * 2);
7711c0
     test_hbitmap_next_zero_check(data, L2 * 2 - L1);
7711c0
@@ -977,6 +999,8 @@ static void test_hbitmap_next_zero_do(TestHBitmapData *data, int granularity)
7711c0
     test_hbitmap_next_zero_check(data, L2 * 2 - 1);
7711c0
     test_hbitmap_next_zero_check(data, L2 * 2);
7711c0
     test_hbitmap_next_zero_check(data, L3 - 1);
7711c0
+    test_hbitmap_next_zero_check_range(data, L2 * 2 - L1, L1 + 1);
7711c0
+    test_hbitmap_next_zero_check_range(data, L2 * 2, L2);
7711c0
 
7711c0
     hbitmap_set(data->hb, 0, L3);
7711c0
     test_hbitmap_next_zero_check(data, 0);
7711c0
-- 
7711c0
1.8.3.1
7711c0