]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: New check_find2 test
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Sun, 13 Oct 2019 03:24:44 +0000 (23:24 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Sun, 13 Oct 2019 03:26:31 +0000 (23:26 -0400)
This is supposed to test various different conditions, but it currently
falls over trying to iterate a tree with no entries in it.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
lib/test_maple_tree.c

index 429159847fba91857c39562b226ce459c37b4880..c94aab1ae86150adacf245477f238e7e4fe73f81 100644 (file)
@@ -465,6 +465,28 @@ static noinline void check_find(struct maple_tree *mt)
        mtree_destroy(mt);
 }
 
+static noinline void check_find_2(struct maple_tree *mt)
+{
+       unsigned long i, j;
+       void *entry;
+       MA_STATE(mas, mt, 0, 0);
+
+       mas_for_each(&mas, entry, ULONG_MAX)
+               MT_BUG_ON(mt, true);
+
+       for (i = 0; i < 256; i++) {
+               mtree_insert_index(mt, i, GFP_KERNEL);
+               j = 0;
+               mas_set(&mas, 0);
+               mas_for_each(&mas, entry, ULONG_MAX) {
+                       MT_BUG_ON(mt, entry != xa_mk_value(j));
+                       j++;
+               }
+               MT_BUG_ON(mt, j != i + 1);
+       }
+
+       mtree_destroy(mt);
+}
 
 #define erase_ptr(i) entry[i%2]
 #define erase_check_load(mt, i) check_load(mt, set[i], entry[i%2])
@@ -1158,6 +1180,7 @@ static int maple_tree_seed(void)
        check_mid_split(&tree);
 
        check_find(&tree);
+       check_find_2(&tree);
 
        rcu_barrier();