Skip to content

Commit

Permalink
radix tree test suite: Add tests for ida_simple_get() and ida_simple_…
Browse files Browse the repository at this point in the history
…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 <[email protected]>
Signed-off-by: Matthew Wilcox <[email protected]>
  • Loading branch information
rehassachdeva authored and Matthew Wilcox committed Mar 7, 2017
1 parent 2eacc79 commit 166bb1f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tools/testing/radix-tree/idr-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,24 @@ void ida_check_random(void)
goto repeat;
}

void ida_simple_get_remove_test(void)
{
DEFINE_IDA(ida);
unsigned long i;

for (i = 0; i < 10000; i++) {
assert(ida_simple_get(&ida, 0, 20000, GFP_KERNEL) == i);
}
assert(ida_simple_get(&ida, 5, 30, GFP_KERNEL) < 0);

for (i = 0; i < 10000; i++) {
ida_simple_remove(&ida, i);
}
assert(ida_is_empty(&ida));

ida_destroy(&ida);
}

void ida_checks(void)
{
DEFINE_IDA(ida);
Expand Down Expand Up @@ -453,6 +471,7 @@ void ida_checks(void)
ida_check_max();
ida_check_conv();
ida_check_random();
ida_simple_get_remove_test();

radix_tree_cpu_dead(1);
}
Expand Down

0 comments on commit 166bb1f

Please sign in to comment.