public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/4] bitmap: Add bitmap_zero()/bitmap_clear() test cases
@ 2018-01-09 17:24 Andy Shevchenko
  2018-01-09 17:24 ` [PATCH v1 2/4] bitmap: Add bitmap_fill()/bitmap_set() " Andy Shevchenko
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Andy Shevchenko @ 2018-01-09 17:24 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel, Rasmus Villemoes, Randy Dunlap,
	Yury Norov
  Cc: Andy Shevchenko

Explicitly test bitmap_zero() and bitmap_clear() functions.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 lib/test_bitmap.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

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,
 #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();
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2018-01-11 12:53 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-09 17:24 [PATCH v1 1/4] bitmap: Add bitmap_zero()/bitmap_clear() test cases Andy Shevchenko
2018-01-09 17:24 ` [PATCH v1 2/4] bitmap: Add bitmap_fill()/bitmap_set() " Andy Shevchenko
2018-01-09 17:24 ` [PATCH v1 3/4] bitmap: Clean up test_zero_fill_copy() test case and rename Andy Shevchenko
2018-01-09 17:24 ` [PATCH v1 4/4] bitmap: Make bitmap_fill() and bitmap_zero() consistent Andy Shevchenko
2018-01-10  8:49   ` Yury Norov
2018-01-10 13:17     ` Andy Shevchenko
2018-01-11 11:57       ` Yury Norov
2018-01-11 12:46         ` Andy Shevchenko
2018-01-10  9:34 ` [PATCH v1 1/4] bitmap: Add bitmap_zero()/bitmap_clear() test cases Yury Norov
2018-01-10 13:11   ` Andy Shevchenko
2018-01-11 12:07     ` Yury Norov
2018-01-11 12:32       ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox