diff options
author | Rehas Sachdeva <aquannie@gmail.com> | 2017-02-18 07:31:00 -0500 |
---|---|---|
committer | Matthew Wilcox <mawilcox@microsoft.com> | 2017-03-07 13:18:18 -0500 |
commit | 2eacc79c27eb683c4a3ded80c2629387ee0d4e04 (patch) | |
tree | 2605f9bed831cf303f256663a696423252005cc6 /tools/testing/radix-tree/idr-test.c | |
parent | 2d6be4abf514fc26c83d239c7f31da1f95e4a31d (diff) |
radix tree test suite: Add test for idr_get_next()
Assert that idr_get_next() returns the next populated entry in the tree with
an ID greater than or equal to the value pointed to by @nextid argument.
Signed-off-by: Rehas Sachdeva <aquannie@gmail.com>
Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
Diffstat (limited to 'tools/testing/radix-tree/idr-test.c')
-rw-r--r-- | tools/testing/radix-tree/idr-test.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tools/testing/radix-tree/idr-test.c b/tools/testing/radix-tree/idr-test.c index a26098c6123d..f20690ac3a97 100644 --- a/tools/testing/radix-tree/idr-test.c +++ b/tools/testing/radix-tree/idr-test.c | |||
@@ -153,6 +153,30 @@ void idr_nowait_test(void) | |||
153 | idr_destroy(&idr); | 153 | idr_destroy(&idr); |
154 | } | 154 | } |
155 | 155 | ||
156 | void idr_get_next_test(void) | ||
157 | { | ||
158 | unsigned long i; | ||
159 | int nextid; | ||
160 | DEFINE_IDR(idr); | ||
161 | |||
162 | int indices[] = {4, 7, 9, 15, 65, 128, 1000, 99999, 0}; | ||
163 | |||
164 | for(i = 0; indices[i]; i++) { | ||
165 | struct item *item = item_create(indices[i], 0); | ||
166 | assert(idr_alloc(&idr, item, indices[i], indices[i+1], | ||
167 | GFP_KERNEL) == indices[i]); | ||
168 | } | ||
169 | |||
170 | for(i = 0, nextid = 0; indices[i]; i++) { | ||
171 | idr_get_next(&idr, &nextid); | ||
172 | assert(nextid == indices[i]); | ||
173 | nextid++; | ||
174 | } | ||
175 | |||
176 | idr_for_each(&idr, item_idr_free, &idr); | ||
177 | idr_destroy(&idr); | ||
178 | } | ||
179 | |||
156 | void idr_checks(void) | 180 | void idr_checks(void) |
157 | { | 181 | { |
158 | unsigned long i; | 182 | unsigned long i; |
@@ -202,6 +226,7 @@ void idr_checks(void) | |||
202 | idr_alloc_test(); | 226 | idr_alloc_test(); |
203 | idr_null_test(); | 227 | idr_null_test(); |
204 | idr_nowait_test(); | 228 | idr_nowait_test(); |
229 | idr_get_next_test(); | ||
205 | } | 230 | } |
206 | 231 | ||
207 | /* | 232 | /* |