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

"Linux Kernel Mailing List" <[email protected]>
Newsgroups gmane.linux.kernel.commits.head
Message-ID <[email protected]>
Web:        https://git.kernel.org/torvalds/c/978f369c5c4777c32e686ecff5aaa5b677afc564
Commit:     978f369c5c4777c32e686ecff5aaa5b677afc564
Parent:     ee3527bd5e48e6c892abfdcb36969c1eb2fd4a6e
Refname:    refs/heads/master
Author:     Andy Shevchenko <[email protected]>
AuthorDate: Tue Feb 6 15:38:13 2018 -0800
Committer:  Linus Torvalds <[email protected]>
CommitDate: Tue Feb 6 18:32:44 2018 -0800

    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/[email protected]
    Signed-off-by: Andy Shevchenko <[email protected]>
    Reviewed-by: Yury Norov <[email protected]>
    Cc: Randy Dunlap <[email protected]>
    Cc: Rasmus Villemoes <[email protected]>
    Signed-off-by: Andrew Morton <[email protected]>
    Signed-off-by: Linus Torvalds <[email protected]>
---
 lib/test_bitmap.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c
index 9734af711816..6889fcc0e1f4 100644
--- a/lib/test_bitmap.c
+++ b/lib/test_bitmap.c
@@ -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();
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.