]> 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)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 30 Oct 2020 18:56:27 +0000 (14:56 -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 87e6bd90350856fbeb5cc58e55bd3f03e7f3cecc..88131b4edc2f2d33f0be3d9f48dd6fe05c7a3a95 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();