]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
lib/test_bitmap.c: add bitmap_zero()/bitmap_clear() test cases
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tue, 6 Feb 2018 23:38:10 +0000 (15:38 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 7 Feb 2018 02:32:44 +0000 (18:32 -0800)
Explicitly test bitmap_zero() and bitmap_clear() functions.

Link: http://lkml.kernel.org/r/20180109172430.87452-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Yury Norov <ynorov@caviumnetworks.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
lib/test_bitmap.c

index de7ef2996a07ba31571d971779dc7f9031f66cdd..9734af71181690d2af72d7f8c20a70f82bfe5199 100644 (file)
@@ -105,6 +105,35 @@ __check_eq_u32_array(const char *srcfile, unsigned int line,
 #define expect_eq_pbl(...)             __expect_eq(pbl, ##__VA_ARGS__)
 #define expect_eq_u32_array(...)       __expect_eq(u32_array, ##__VA_ARGS__)
 
+static void __init test_zero_clear(void)
+{
+       DECLARE_BITMAP(bmap, 1024);
+
+       /* Known way to set all bits */
+       memset(bmap, 0xff, 128);
+
+       expect_eq_pbl("0-22", bmap, 23);
+       expect_eq_pbl("0-1023", bmap, 1024);
+
+       /* single-word bitmaps */
+       bitmap_clear(bmap, 0, 9);
+       expect_eq_pbl("9-1023", bmap, 1024);
+
+       bitmap_zero(bmap, 35);
+       expect_eq_pbl("64-1023", bmap, 1024);
+
+       /* cross boundaries operations */
+       bitmap_clear(bmap, 79, 19);
+       expect_eq_pbl("64-78,98-1023", bmap, 1024);
+
+       bitmap_zero(bmap, 115);
+       expect_eq_pbl("128-1023", bmap, 1024);
+
+       /* Zeroing entire area */
+       bitmap_zero(bmap, 1024);
+       expect_eq_pbl("", bmap, 1024);
+}
+
 static void __init test_zero_fill_copy(void)
 {
        DECLARE_BITMAP(bmap1, 1024);
@@ -309,6 +338,7 @@ static void noinline __init test_mem_optimisations(void)
 
 static int __init test_bitmap_init(void)
 {
+       test_zero_clear();
        test_zero_fill_copy();
        test_bitmap_arr32();
        test_bitmap_parselist();