diff options
author | Rehas Sachdeva <aquannie@gmail.com> | 2017-02-20 06:40:00 -0500 |
---|---|---|
committer | Matthew Wilcox <mawilcox@microsoft.com> | 2017-03-07 13:18:19 -0500 |
commit | 166bb1f532fd9fe1b81c6b411ad5d5c9dd21a685 (patch) | |
tree | 88c78261a7976af4533989e52ae104f206fa63b5 /tools/testing/radix-tree/idr-test.c | |
parent | 2eacc79c27eb683c4a3ded80c2629387ee0d4e04 (diff) |
radix tree test suite: Add tests for ida_simple_get() and ida_simple_remove()
Assert that ida_simple_get() allocates an id in the passed range or returns
error on failure, and ida_simple_remove() releases an allocated id.
Signed-off-by: Rehas Sachdeva <aquannie@gmail.com>
Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
Diffstat (limited to 'tools/testing/radix-tree/idr-test.c')
-rw-r--r-- | tools/testing/radix-tree/idr-test.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tools/testing/radix-tree/idr-test.c b/tools/testing/radix-tree/idr-test.c index f20690ac3a97..86de901fa5c6 100644 --- a/tools/testing/radix-tree/idr-test.c +++ b/tools/testing/radix-tree/idr-test.c | |||
@@ -387,6 +387,24 @@ void ida_check_random(void) | |||
387 | goto repeat; | 387 | goto repeat; |
388 | } | 388 | } |
389 | 389 | ||
390 | void ida_simple_get_remove_test(void) | ||
391 | { | ||
392 | DEFINE_IDA(ida); | ||
393 | unsigned long i; | ||
394 | |||
395 | for (i = 0; i < 10000; i++) { | ||
396 | assert(ida_simple_get(&ida, 0, 20000, GFP_KERNEL) == i); | ||
397 | } | ||
398 | assert(ida_simple_get(&ida, 5, 30, GFP_KERNEL) < 0); | ||
399 | |||
400 | for (i = 0; i < 10000; i++) { | ||
401 | ida_simple_remove(&ida, i); | ||
402 | } | ||
403 | assert(ida_is_empty(&ida)); | ||
404 | |||
405 | ida_destroy(&ida); | ||
406 | } | ||
407 | |||
390 | void ida_checks(void) | 408 | void ida_checks(void) |
391 | { | 409 | { |
392 | DEFINE_IDA(ida); | 410 | DEFINE_IDA(ida); |
@@ -453,6 +471,7 @@ void ida_checks(void) | |||
453 | ida_check_max(); | 471 | ida_check_max(); |
454 | ida_check_conv(); | 472 | ida_check_conv(); |
455 | ida_check_random(); | 473 | ida_check_random(); |
474 | ida_simple_get_remove_test(); | ||
456 | 475 | ||
457 | radix_tree_cpu_dead(1); | 476 | radix_tree_cpu_dead(1); |
458 | } | 477 | } |