radix tree test suite: start adding multiorder tests
PATCH 113/162 radix tree test suite: start adding multiorder tests
From: Matthew Wilcox <[email protected]>
Subject: radix tree test suite: start adding multiorder tests
Test suite infrastructure for working with multiorder entries.
The test itself is pretty basic: Add an entry, check that all expected indices return that entry and that indices around that entry don't return an entry. Then delete the entry and check no index returns that entry. Tests a few edge conditions including the multiorder entry at index 0 and at a higher index. Also tests deleting through an alias as well as through the canonical index.
Signed-off-by Matthew Wilcox <[email protected]>
Reviewed-by Ross Zwisler <[email protected]>
Cc Konstantin Khlebnikov <[email protected]>
Cc Kirill Shutemov <[email protected]>
Cc Jan Kara <[email protected]>
Cc Neil Brown <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
tools/testing/radix-tree/Makefile | 2 tools/testing/radix-tree/main.c | 2 tools/testing/radix-tree/multiorder.c | 58 ++++++++++++++++++++++++ tools/testing/radix-tree/test.c | 13 ++++- tools/testing/radix-tree/test.h | 6 ++ 5 files changed, 76 insertions(+), 5 deletions(-)
tools/testing/radix-tree/Makefile renamed from tools/testing/radix-tree/Makefile~radix-tree-test-suite-start-adding-multiorder-tests +1 -1
@@ -3,7 +3,7 @@ CFLAGS += -I. -g -Wall -D_LGPL_SOURCE LDFLAGS += -lpthread -lurcu TARGETS = main OFILES = main.o radix-tree.o linux.o test.o tag_check.o find_next_bit.o \ - regression1.o regression2.o regression3.o + regression1.o regression2.o regression3.o multiorder.o targets: $(TARGETS)
tools/testing/radix-tree/main.c renamed from tools/testing/radix-tree/main.c~radix-tree-test-suite-start-adding-multiorder-tests +2 -0
@@ -275,6 +275,8 @@ static void single_thread_tests(bool lonint i;printf ("starting single_thread_tests: %d allocated\n" , nr_allocated); +multiorder_checks (); +printf ("after multiorder_check: %d allocated\n" , nr_allocated);locate_check ();printf ("after locate_check: %d allocated\n" , nr_allocated);tag_check ();
tools/testing/radix-tree/multiorder.c new file +58 -0
58 lines not on this page · raw message
tools/testing/radix-tree/test.c renamed from tools/testing/radix-tree/test.c~radix-tree-test-suite-start-adding-multiorder-tests +10 -3
@@ -24,14 +24,21 @@ int item_tag_get(struct radix_tree_rootreturn radix_tree_tag_get (root, index, tag); } -int __item_insert (struct radix_tree_root *root,struct item *item) +int __item_insert (struct radix_tree_root *root,struct item *item, +unsigned order) { -return radix_tree_insert (root, item->index, item); +return __radix_tree_insert (root, item->index, order, item); }int item_insert (struct radix_tree_root *root,unsigned long index) { -return __item_insert (root,item_create (index)); +return __item_insert (root,item_create (index),0 ); +} + +int item_insert_order (struct radix_tree_root *root,unsigned long index, +unsigned order) +{ +return __item_insert (root,item_create (index), order); }int item_delete (struct radix_tree_root *root,unsigned long index)
tools/testing/radix-tree/test.h renamed from tools/testing/radix-tree/test.h~radix-tree-test-suite-start-adding-multiorder-tests +5 -1
@@ -8,8 +8,11 @@ struct item { };struct item *item_create (unsigned long index); -int __item_insert (struct radix_tree_root *root,struct item *item); +int __item_insert (struct radix_tree_root *root,struct item *item, +unsigned order);int item_insert (struct radix_tree_root *root,unsigned long index); +int item_insert_order (struct radix_tree_root *root,unsigned long index, +unsigned order);int item_delete (struct radix_tree_root *root,unsigned long index);struct item *item_lookup (struct radix_tree_root *root,unsigned long index);
@@ -23,6 +26,7 @@ void item_full_scan(struct radix_tree_rovoid item_kill_tree (struct radix_tree_root *root);void tag_check (void ); +void multiorder_checks (void );struct item *item_tag_set (struct radix_tree_root *root,unsigned long index,int tag);
_