aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rbtree_test.c
diff options
context:
space:
mode:
authorCody P Schafer <cody@linux.vnet.ibm.com>2013-09-11 17:25:17 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-11 18:59:20 -0400
commita791a62fdf288b2658646e2052400d456874790e (patch)
tree8412e41213fca92c65f56e6f312ef8b9545cf35c /lib/rbtree_test.c
parent2b529089257705499207ce7da9d0e3ae26a844ba (diff)
rbtree_test: add test for postorder iteration
Just check that we examine all nodes in the tree for the postorder iteration. Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com> Reviewed-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Cc: David Woodhouse <David.Woodhouse@intel.com> Cc: Rik van Riel <riel@redhat.com> Cc: Michel Lespinasse <walken@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/rbtree_test.c')
-rw-r--r--lib/rbtree_test.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/rbtree_test.c b/lib/rbtree_test.c
index 122f02f9941b..31dd4ccd3baa 100644
--- a/lib/rbtree_test.c
+++ b/lib/rbtree_test.c
@@ -114,6 +114,16 @@ static int black_path_count(struct rb_node *rb)
114 return count; 114 return count;
115} 115}
116 116
117static void check_postorder(int nr_nodes)
118{
119 struct rb_node *rb;
120 int count = 0;
121 for (rb = rb_first_postorder(&root); rb; rb = rb_next_postorder(rb))
122 count++;
123
124 WARN_ON_ONCE(count != nr_nodes);
125}
126
117static void check(int nr_nodes) 127static void check(int nr_nodes)
118{ 128{
119 struct rb_node *rb; 129 struct rb_node *rb;
@@ -136,6 +146,8 @@ static void check(int nr_nodes)
136 146
137 WARN_ON_ONCE(count != nr_nodes); 147 WARN_ON_ONCE(count != nr_nodes);
138 WARN_ON_ONCE(count < (1 << black_path_count(rb_last(&root))) - 1); 148 WARN_ON_ONCE(count < (1 << black_path_count(rb_last(&root))) - 1);
149
150 check_postorder(nr_nodes);
139} 151}
140 152
141static void check_augmented(int nr_nodes) 153static void check_augmented(int nr_nodes)