Skip to content

Commit 2c52355

Browse files
committed
lib/bitmap: add test for bitmap_{from,to}_arr64
Test newly added bitmap_{from,to}_arr64() functions similarly to already existing bitmap_{from,to}_arr32() tests. CC: Alexander Gordeev <[email protected]> CC: Andy Shevchenko <[email protected]> CC: Christian Borntraeger <[email protected]> CC: Claudio Imbrenda <[email protected]> CC: David Hildenbrand <[email protected]> CC: Heiko Carstens <[email protected]> CC: Janosch Frank <[email protected]> CC: Rasmus Villemoes <[email protected]> CC: Sven Schnelle <[email protected]> CC: Vasily Gorbik <[email protected]> Signed-off-by: Yury Norov <[email protected]>
1 parent 0a97953 commit 2c52355

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

lib/test_bitmap.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,30 @@ static void __init test_bitmap_arr32(void)
585585
}
586586
}
587587

588+
static void __init test_bitmap_arr64(void)
589+
{
590+
unsigned int nbits, next_bit;
591+
u64 arr[EXP1_IN_BITS / 64];
592+
DECLARE_BITMAP(bmap2, EXP1_IN_BITS);
593+
594+
memset(arr, 0xa5, sizeof(arr));
595+
596+
for (nbits = 0; nbits < EXP1_IN_BITS; ++nbits) {
597+
memset(bmap2, 0xff, sizeof(arr));
598+
bitmap_to_arr64(arr, exp1, nbits);
599+
bitmap_from_arr64(bmap2, arr, nbits);
600+
expect_eq_bitmap(bmap2, exp1, nbits);
601+
602+
next_bit = find_next_bit(bmap2, round_up(nbits, BITS_PER_LONG), nbits);
603+
if (next_bit < round_up(nbits, BITS_PER_LONG))
604+
pr_err("bitmap_copy_arr64(nbits == %d:"
605+
" tail is not safely cleared: %d\n", nbits, next_bit);
606+
607+
if (nbits < EXP1_IN_BITS - 64)
608+
expect_eq_uint(arr[DIV_ROUND_UP(nbits, 64)], 0xa5a5a5a5);
609+
}
610+
}
611+
588612
static void noinline __init test_mem_optimisations(void)
589613
{
590614
DECLARE_BITMAP(bmap1, 1024);
@@ -852,6 +876,7 @@ static void __init selftest(void)
852876
test_copy();
853877
test_replace();
854878
test_bitmap_arr32();
879+
test_bitmap_arr64();
855880
test_bitmap_parse();
856881
test_bitmap_parselist();
857882
test_bitmap_printlist();

0 commit comments

Comments
 (0)