]> git.proxmox.com Git - mirror_qemu.git/commitdiff
test-bitmap: test set 1 bit case for bitmap_set
authorWei Yang <richardw.yang@linux.intel.com>
Wed, 14 Aug 2019 00:27:23 +0000 (08:27 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 20 Aug 2019 18:00:51 +0000 (20:00 +0200)
All current bitmap_set test cases set range across word, while the
handle of a range within one word is different from that.

Add case to set 1 bit as a represent for set range within one word.

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
tests/test-bitmap.c

index 18aa584591e8902f7482156939eb7b08f70899ac..087e02a26c7c4d81a0774b913b3ce4935882b315 100644 (file)
@@ -67,6 +67,18 @@ static void bitmap_set_case(bmap_set_func set_func)
 
     bmap = bitmap_new(BMAP_SIZE);
 
+    /* Set one bit at offset in second word */
+    for (offset = 0; offset <= BITS_PER_LONG; offset++) {
+        bitmap_clear(bmap, 0, BMAP_SIZE);
+        set_func(bmap, BITS_PER_LONG + offset, 1);
+        g_assert_cmpint(find_first_bit(bmap, 2 * BITS_PER_LONG),
+                        ==, BITS_PER_LONG + offset);
+        g_assert_cmpint(find_next_zero_bit(bmap,
+                                           3 * BITS_PER_LONG,
+                                           BITS_PER_LONG + offset),
+                        ==, BITS_PER_LONG + offset + 1);
+    }
+
     /* Both Aligned, set bits [BITS_PER_LONG, 3*BITS_PER_LONG] */
     set_func(bmap, BITS_PER_LONG, 2 * BITS_PER_LONG);
     g_assert_cmpuint(bmap[1], ==, -1ul);