Commit 978f369c authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Linus Torvalds

lib/test_bitmap.c: add bitmap_fill()/bitmap_set() test cases

Explicitly test bitmap_fill() and bitmap_set() functions.

For bitmap_fill() we expect a consistent behaviour as in bitmap_zero(),
i.e.  the trailing bits will be set up to unsigned long boundary.

Link: http://lkml.kernel.org/r/20180109172430.87452-2-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarYury Norov <ynorov@caviumnetworks.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent ee3527bd
......@@ -134,6 +134,35 @@ static void __init test_zero_clear(void)
expect_eq_pbl("", bmap, 1024);
}
static void __init test_fill_set(void)
{
DECLARE_BITMAP(bmap, 1024);
/* Known way to clear all bits */
memset(bmap, 0x00, 128);
expect_eq_pbl("", bmap, 23);
expect_eq_pbl("", bmap, 1024);
/* single-word bitmaps */
bitmap_set(bmap, 0, 9);
expect_eq_pbl("0-8", bmap, 1024);
bitmap_fill(bmap, 35);
expect_eq_pbl("0-63", bmap, 1024);
/* cross boundaries operations */
bitmap_set(bmap, 79, 19);
expect_eq_pbl("0-63,79-97", bmap, 1024);
bitmap_fill(bmap, 115);
expect_eq_pbl("0-127", bmap, 1024);
/* Zeroing entire area */
bitmap_fill(bmap, 1024);
expect_eq_pbl("0-1023", bmap, 1024);
}
static void __init test_zero_fill_copy(void)
{
DECLARE_BITMAP(bmap1, 1024);
......@@ -339,6 +368,7 @@ static void noinline __init test_mem_optimisations(void)
static int __init test_bitmap_init(void)
{
test_zero_clear();
test_fill_set();
test_zero_fill_copy();
test_bitmap_arr32();
test_bitmap_parselist();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment