]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
radix tree test suite: Add tests for ida_simple_get() and ida_simple_remove()
authorRehas Sachdeva <aquannie@gmail.com>
Mon, 20 Feb 2017 11:40:00 +0000 (06:40 -0500)
committerMatthew Wilcox <mawilcox@microsoft.com>
Tue, 7 Mar 2017 18:18:19 +0000 (13:18 -0500)
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>
tools/testing/radix-tree/idr-test.c

index f20690ac3a97754c62e0b68d1404a072f09770e9..86de901fa5c6bec809332ad04df8b11cc4ff2d9a 100644 (file)
@@ -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);
 }