diff options
Diffstat (limited to 'lib/test_xarray.c')
-rw-r--r-- | lib/test_xarray.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/test_xarray.c b/lib/test_xarray.c index e3c2d4d00b15..a96f67caa1c2 100644 --- a/lib/test_xarray.c +++ b/lib/test_xarray.c | |||
@@ -465,6 +465,39 @@ static noinline void check_find(struct xarray *xa) | |||
465 | check_multi_find_2(xa); | 465 | check_multi_find_2(xa); |
466 | } | 466 | } |
467 | 467 | ||
468 | static noinline void check_destroy(struct xarray *xa) | ||
469 | { | ||
470 | unsigned long index; | ||
471 | |||
472 | XA_BUG_ON(xa, !xa_empty(xa)); | ||
473 | |||
474 | /* Destroying an empty array is a no-op */ | ||
475 | xa_destroy(xa); | ||
476 | XA_BUG_ON(xa, !xa_empty(xa)); | ||
477 | |||
478 | /* Destroying an array with a single entry */ | ||
479 | for (index = 0; index < 1000; index++) { | ||
480 | xa_store_index(xa, index, GFP_KERNEL); | ||
481 | XA_BUG_ON(xa, xa_empty(xa)); | ||
482 | xa_destroy(xa); | ||
483 | XA_BUG_ON(xa, !xa_empty(xa)); | ||
484 | } | ||
485 | |||
486 | /* Destroying an array with a single entry at ULONG_MAX */ | ||
487 | xa_store(xa, ULONG_MAX, xa, GFP_KERNEL); | ||
488 | XA_BUG_ON(xa, xa_empty(xa)); | ||
489 | xa_destroy(xa); | ||
490 | XA_BUG_ON(xa, !xa_empty(xa)); | ||
491 | |||
492 | #ifdef CONFIG_XARRAY_MULTI | ||
493 | /* Destroying an array with a multi-index entry */ | ||
494 | xa_store_order(xa, 1 << 11, 11, xa, GFP_KERNEL); | ||
495 | XA_BUG_ON(xa, xa_empty(xa)); | ||
496 | xa_destroy(xa); | ||
497 | XA_BUG_ON(xa, !xa_empty(xa)); | ||
498 | #endif | ||
499 | } | ||
500 | |||
468 | static DEFINE_XARRAY(array); | 501 | static DEFINE_XARRAY(array); |
469 | 502 | ||
470 | static int xarray_checks(void) | 503 | static int xarray_checks(void) |
@@ -478,6 +511,7 @@ static int xarray_checks(void) | |||
478 | check_cmpxchg(&array); | 511 | check_cmpxchg(&array); |
479 | check_multi_store(&array); | 512 | check_multi_store(&array); |
480 | check_find(&array); | 513 | check_find(&array); |
514 | check_destroy(&array); | ||
481 | 515 | ||
482 | printk("XArray: %u of %u tests passed\n", tests_passed, tests_run); | 516 | printk("XArray: %u of %u tests passed\n", tests_passed, tests_run); |
483 | return (tests_run == tests_passed) ? 0 : -EINVAL; | 517 | return (tests_run == tests_passed) ? 0 : -EINVAL; |