lib/test_printf.c: add test for large bitmaps
authorRasmus Villemoes <linux@rasmusvillemoes.dk>
Sat, 16 Jan 2016 00:59:06 +0000 (16:59 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 16 Jan 2016 19:17:29 +0000 (11:17 -0800)
Following "lib/vsprintf.c: expand field_width to 24 bits", let's add a
test to see that we now actually support bitmaps with 65536 bits.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Acked-by: Kees Cook <keescook@chromium.org>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Joe Perches <joe@perches.com>
Cc: Maurizio Lombardi <mlombard@redhat.com>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
lib/test_printf.c

index 3e21170d327da194c02f8f895dd53dfc1bb84a09..60740c10c3e8bb215b799b8cd71c394ae12e0f95 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/slab.h>
 #include <linux/string.h>
 
+#include <linux/bitmap.h>
 #include <linux/socket.h>
 #include <linux/in.h>
 
@@ -340,6 +341,20 @@ struct_clk(void)
 {
 }
 
+static void __init
+large_bitmap(void)
+{
+       const int nbits = 1 << 16;
+       unsigned long *bits = kcalloc(BITS_TO_LONGS(nbits), sizeof(long), GFP_KERNEL);
+       if (!bits)
+               return;
+
+       bitmap_set(bits, 1, 20);
+       bitmap_set(bits, 60000, 15);
+       test("1-20,60000-60014", "%*pbl", nbits, bits);
+       kfree(bits);
+}
+
 static void __init
 bitmap(void)
 {
@@ -359,6 +374,8 @@ bitmap(void)
        bitmap_fill(bits, 20);
        test("fffff|fffff", "%20pb|%*pb", bits, 20, bits);
        test("0-19|0-19", "%20pbl|%*pbl", bits, 20, bits);
+
+       large_bitmap();
 }
 
 static void __init