aboutsummaryrefslogtreecommitdiffstats
path: root/lib/test_bitmap.c
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2018-02-06 18:38:10 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2018-02-06 21:32:44 -0500
commitee3527bd5e48e6c892abfdcb36969c1eb2fd4a6e (patch)
treecf77fc12d2ee68da5b89e0af9d6423e0a7d42cb2 /lib/test_bitmap.c
parent3aa56885e51683a19c8aa71739fd279b3f501cd7 (diff)
lib/test_bitmap.c: add bitmap_zero()/bitmap_clear() test cases
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>
Diffstat (limited to 'lib/test_bitmap.c')
-rw-r--r--lib/test_bitmap.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c
index de7ef2996a07..9734af711816 100644
--- a/lib/test_bitmap.c
+++ b/lib/test_bitmap.c
@@ -105,6 +105,35 @@ __check_eq_u32_array(const char *srcfile, unsigned int line,
105#define expect_eq_pbl(...) __expect_eq(pbl, ##__VA_ARGS__) 105#define expect_eq_pbl(...) __expect_eq(pbl, ##__VA_ARGS__)
106#define expect_eq_u32_array(...) __expect_eq(u32_array, ##__VA_ARGS__) 106#define expect_eq_u32_array(...) __expect_eq(u32_array, ##__VA_ARGS__)
107 107
108static void __init test_zero_clear(void)
109{
110 DECLARE_BITMAP(bmap, 1024);
111
112 /* Known way to set all bits */
113 memset(bmap, 0xff, 128);
114
115 expect_eq_pbl("0-22", bmap, 23);
116 expect_eq_pbl("0-1023", bmap, 1024);
117
118 /* single-word bitmaps */
119 bitmap_clear(bmap, 0, 9);
120 expect_eq_pbl("9-1023", bmap, 1024);
121
122 bitmap_zero(bmap, 35);
123 expect_eq_pbl("64-1023", bmap, 1024);
124
125 /* cross boundaries operations */
126 bitmap_clear(bmap, 79, 19);
127 expect_eq_pbl("64-78,98-1023", bmap, 1024);
128
129 bitmap_zero(bmap, 115);
130 expect_eq_pbl("128-1023", bmap, 1024);
131
132 /* Zeroing entire area */
133 bitmap_zero(bmap, 1024);
134 expect_eq_pbl("", bmap, 1024);
135}
136
108static void __init test_zero_fill_copy(void) 137static void __init test_zero_fill_copy(void)
109{ 138{
110 DECLARE_BITMAP(bmap1, 1024); 139 DECLARE_BITMAP(bmap1, 1024);
@@ -309,6 +338,7 @@ static void noinline __init test_mem_optimisations(void)
309 338
310static int __init test_bitmap_init(void) 339static int __init test_bitmap_init(void)
311{ 340{
341 test_zero_clear();
312 test_zero_fill_copy(); 342 test_zero_fill_copy();
313 test_bitmap_arr32(); 343 test_bitmap_arr32();
314 test_bitmap_parselist(); 344 test_bitmap_parselist();