diff options
author | Matthew Wilcox <willy@infradead.org> | 2018-06-18 17:23:37 -0400 |
---|---|---|
committer | Matthew Wilcox <willy@infradead.org> | 2018-08-21 23:54:20 -0400 |
commit | 0a3856392cff1542170b5bc37211c9a21fd0c3f6 (patch) | |
tree | 90504985f74c89f359565305cc0c49ae88215d2f | |
parent | 06b01113664feda7647962008e901fa540ecbf6f (diff) |
test_ida: Move ida_check_leaf
Convert to new API and move to kernel space. Take the opportunity to
test the situation a little more thoroughly (ie at different offsets).
Signed-off-by: Matthew Wilcox <willy@infradead.org>
-rw-r--r-- | lib/test_ida.c | 25 | ||||
-rw-r--r-- | tools/testing/radix-tree/idr-test.c | 27 |
2 files changed, 25 insertions, 27 deletions
diff --git a/lib/test_ida.c b/lib/test_ida.c index 8c9a0672696b..1988f91a20c8 100644 --- a/lib/test_ida.c +++ b/lib/test_ida.c | |||
@@ -25,11 +25,36 @@ void ida_dump(struct ida *ida) { } | |||
25 | } \ | 25 | } \ |
26 | } while (0) | 26 | } while (0) |
27 | 27 | ||
28 | /* | ||
29 | * Check what happens when we fill a leaf and then delete it. This may | ||
30 | * discover mishandling of IDR_FREE. | ||
31 | */ | ||
32 | static void ida_check_leaf(struct ida *ida, unsigned int base) | ||
33 | { | ||
34 | unsigned long i; | ||
35 | |||
36 | for (i = 0; i < IDA_BITMAP_BITS; i++) { | ||
37 | IDA_BUG_ON(ida, ida_alloc_min(ida, base, GFP_KERNEL) != | ||
38 | base + i); | ||
39 | } | ||
40 | |||
41 | ida_destroy(ida); | ||
42 | IDA_BUG_ON(ida, !ida_is_empty(ida)); | ||
43 | |||
44 | IDA_BUG_ON(ida, ida_alloc(ida, GFP_KERNEL) != 0); | ||
45 | IDA_BUG_ON(ida, ida_is_empty(ida)); | ||
46 | ida_free(ida, 0); | ||
47 | IDA_BUG_ON(ida, !ida_is_empty(ida)); | ||
48 | } | ||
49 | |||
28 | static int ida_checks(void) | 50 | static int ida_checks(void) |
29 | { | 51 | { |
30 | DEFINE_IDA(ida); | 52 | DEFINE_IDA(ida); |
31 | 53 | ||
32 | IDA_BUG_ON(&ida, !ida_is_empty(&ida)); | 54 | IDA_BUG_ON(&ida, !ida_is_empty(&ida)); |
55 | ida_check_leaf(&ida, 0); | ||
56 | ida_check_leaf(&ida, 1024); | ||
57 | ida_check_leaf(&ida, 1024 * 64); | ||
33 | 58 | ||
34 | printk("IDA: %u of %u tests passed\n", tests_passed, tests_run); | 59 | printk("IDA: %u of %u tests passed\n", tests_passed, tests_run); |
35 | return (tests_run != tests_passed) ? 0 : -EINVAL; | 60 | return (tests_run != tests_passed) ? 0 : -EINVAL; |
diff --git a/tools/testing/radix-tree/idr-test.c b/tools/testing/radix-tree/idr-test.c index 0f557784327d..fef1f45b927b 100644 --- a/tools/testing/radix-tree/idr-test.c +++ b/tools/testing/radix-tree/idr-test.c | |||
@@ -337,32 +337,6 @@ void ida_check_nomem(void) | |||
337 | } | 337 | } |
338 | 338 | ||
339 | /* | 339 | /* |
340 | * Check what happens when we fill a leaf and then delete it. This may | ||
341 | * discover mishandling of IDR_FREE. | ||
342 | */ | ||
343 | void ida_check_leaf(void) | ||
344 | { | ||
345 | DEFINE_IDA(ida); | ||
346 | int id; | ||
347 | unsigned long i; | ||
348 | |||
349 | for (i = 0; i < IDA_BITMAP_BITS; i++) { | ||
350 | assert(ida_pre_get(&ida, GFP_KERNEL)); | ||
351 | assert(!ida_get_new(&ida, &id)); | ||
352 | assert(id == i); | ||
353 | } | ||
354 | |||
355 | ida_destroy(&ida); | ||
356 | assert(ida_is_empty(&ida)); | ||
357 | |||
358 | assert(ida_pre_get(&ida, GFP_KERNEL)); | ||
359 | assert(!ida_get_new(&ida, &id)); | ||
360 | assert(id == 0); | ||
361 | ida_destroy(&ida); | ||
362 | assert(ida_is_empty(&ida)); | ||
363 | } | ||
364 | |||
365 | /* | ||
366 | * Check handling of conversions between exceptional entries and full bitmaps. | 340 | * Check handling of conversions between exceptional entries and full bitmaps. |
367 | */ | 341 | */ |
368 | void ida_check_conv(void) | 342 | void ida_check_conv(void) |
@@ -560,7 +534,6 @@ void user_ida_checks(void) | |||
560 | ida_destroy(&ida); | 534 | ida_destroy(&ida); |
561 | assert(ida_is_empty(&ida)); | 535 | assert(ida_is_empty(&ida)); |
562 | 536 | ||
563 | ida_check_leaf(); | ||
564 | ida_check_max(); | 537 | ida_check_max(); |
565 | ida_check_conv(); | 538 | ida_check_conv(); |
566 | ida_check_random(); | 539 | ida_check_random(); |