diff options
author | Matthew Wilcox <mawilcox@microsoft.com> | 2016-09-22 14:53:34 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-09-25 14:49:16 -0400 |
commit | 62fd5258ebe3ea240371234955a6e2cc99e0b6c3 (patch) | |
tree | c138367e16b619c13a21fdb562b541936d4a4136 | |
parent | 9c0e28a7be656d737fb18998e2dcb0b8ce595643 (diff) |
radix tree test suite: Test radix_tree_replace_slot() for multiorder entries
When we replace a multiorder entry, check that all indices reflect the
new value.
Also, compile the test suite with -O2, which shows other problems with
the code due to some dodgy pointer operations in the radix tree code.
Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | tools/testing/radix-tree/Makefile | 2 | ||||
-rw-r--r-- | tools/testing/radix-tree/multiorder.c | 16 |
2 files changed, 13 insertions, 5 deletions
diff --git a/tools/testing/radix-tree/Makefile b/tools/testing/radix-tree/Makefile index 3b530467148e..9d0919ed52a4 100644 --- a/tools/testing/radix-tree/Makefile +++ b/tools/testing/radix-tree/Makefile | |||
@@ -1,5 +1,5 @@ | |||
1 | 1 | ||
2 | CFLAGS += -I. -g -Wall -D_LGPL_SOURCE | 2 | CFLAGS += -I. -g -O2 -Wall -D_LGPL_SOURCE |
3 | LDFLAGS += -lpthread -lurcu | 3 | LDFLAGS += -lpthread -lurcu |
4 | TARGETS = main | 4 | TARGETS = main |
5 | OFILES = main.o radix-tree.o linux.o test.o tag_check.o find_next_bit.o \ | 5 | OFILES = main.o radix-tree.o linux.o test.o tag_check.o find_next_bit.o \ |
diff --git a/tools/testing/radix-tree/multiorder.c b/tools/testing/radix-tree/multiorder.c index 39d9b9568fe2..05d7bc488971 100644 --- a/tools/testing/radix-tree/multiorder.c +++ b/tools/testing/radix-tree/multiorder.c | |||
@@ -124,6 +124,8 @@ static void multiorder_check(unsigned long index, int order) | |||
124 | unsigned long i; | 124 | unsigned long i; |
125 | unsigned long min = index & ~((1UL << order) - 1); | 125 | unsigned long min = index & ~((1UL << order) - 1); |
126 | unsigned long max = min + (1UL << order); | 126 | unsigned long max = min + (1UL << order); |
127 | void **slot; | ||
128 | struct item *item2 = item_create(min); | ||
127 | RADIX_TREE(tree, GFP_KERNEL); | 129 | RADIX_TREE(tree, GFP_KERNEL); |
128 | 130 | ||
129 | printf("Multiorder index %ld, order %d\n", index, order); | 131 | printf("Multiorder index %ld, order %d\n", index, order); |
@@ -139,13 +141,19 @@ static void multiorder_check(unsigned long index, int order) | |||
139 | item_check_absent(&tree, i); | 141 | item_check_absent(&tree, i); |
140 | for (i = max; i < 2*max; i++) | 142 | for (i = max; i < 2*max; i++) |
141 | item_check_absent(&tree, i); | 143 | item_check_absent(&tree, i); |
144 | for (i = min; i < max; i++) | ||
145 | assert(radix_tree_insert(&tree, i, item2) == -EEXIST); | ||
146 | |||
147 | slot = radix_tree_lookup_slot(&tree, index); | ||
148 | free(*slot); | ||
149 | radix_tree_replace_slot(slot, item2); | ||
142 | for (i = min; i < max; i++) { | 150 | for (i = min; i < max; i++) { |
143 | static void *entry = (void *) | 151 | struct item *item = item_lookup(&tree, i); |
144 | (0xA0 | RADIX_TREE_EXCEPTIONAL_ENTRY); | 152 | assert(item != 0); |
145 | assert(radix_tree_insert(&tree, i, entry) == -EEXIST); | 153 | assert(item->index == min); |
146 | } | 154 | } |
147 | 155 | ||
148 | assert(item_delete(&tree, index) != 0); | 156 | assert(item_delete(&tree, min) != 0); |
149 | 157 | ||
150 | for (i = 0; i < 2*max; i++) | 158 | for (i = 0; i < 2*max; i++) |
151 | item_check_absent(&tree, i); | 159 | item_check_absent(&tree, i); |