aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRasmus Villemoes <linux@rasmusvillemoes.dk>2016-01-15 19:59:06 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-01-16 14:17:29 -0500
commit857cca4d565d85857597ccf0b6f72cf0f06e046c (patch)
tree7a6e92ed503c2bc4328da3c34ba24dbd50a5ce5d
parentb79a7db37d560c9e4b6fdb5314cb8b226a2d6567 (diff)
lib/test_printf.c: add test for large bitmaps
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>
-rw-r--r--lib/test_printf.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/test_printf.c b/lib/test_printf.c
index 3e21170d327d..60740c10c3e8 100644
--- a/lib/test_printf.c
+++ b/lib/test_printf.c
@@ -12,6 +12,7 @@
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/string.h> 13#include <linux/string.h>
14 14
15#include <linux/bitmap.h>
15#include <linux/socket.h> 16#include <linux/socket.h>
16#include <linux/in.h> 17#include <linux/in.h>
17 18
@@ -341,6 +342,20 @@ struct_clk(void)
341} 342}
342 343
343static void __init 344static void __init
345large_bitmap(void)
346{
347 const int nbits = 1 << 16;
348 unsigned long *bits = kcalloc(BITS_TO_LONGS(nbits), sizeof(long), GFP_KERNEL);
349 if (!bits)
350 return;
351
352 bitmap_set(bits, 1, 20);
353 bitmap_set(bits, 60000, 15);
354 test("1-20,60000-60014", "%*pbl", nbits, bits);
355 kfree(bits);
356}
357
358static void __init
344bitmap(void) 359bitmap(void)
345{ 360{
346 DECLARE_BITMAP(bits, 20); 361 DECLARE_BITMAP(bits, 20);
@@ -359,6 +374,8 @@ bitmap(void)
359 bitmap_fill(bits, 20); 374 bitmap_fill(bits, 20);
360 test("fffff|fffff", "%20pb|%*pb", bits, 20, bits); 375 test("fffff|fffff", "%20pb|%*pb", bits, 20, bits);
361 test("0-19|0-19", "%20pbl|%*pbl", bits, 20, bits); 376 test("0-19|0-19", "%20pbl|%*pbl", bits, 20, bits);
377
378 large_bitmap();
362} 379}
363 380
364static void __init 381static void __init