提交 166bb1f5 编写于 作者: R Rehas Sachdeva 提交者: Matthew Wilcox

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: NRehas Sachdeva <aquannie@gmail.com>
Signed-off-by: NMatthew Wilcox <mawilcox@microsoft.com>
上级 2eacc79c
......@@ -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);
......@@ -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);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册