diff options
author | Matthew Wilcox <willy@infradead.org> | 2018-06-18 23:23:37 +0200 |
---|---|---|
committer | Matthew Wilcox <willy@infradead.org> | 2018-08-22 05:54:20 +0200 |
commit | 0a3856392cff1542170b5bc37211c9a21fd0c3f6 (patch) | |
tree | 90504985f74c89f359565305cc0c49ae88215d2f /lib/test_ida.c | |
parent | idr-test: Convert ida_check_nomem to new API (diff) | |
download | linux-0a3856392cff1542170b5bc37211c9a21fd0c3f6.tar.xz linux-0a3856392cff1542170b5bc37211c9a21fd0c3f6.zip |
test_ida: Move ida_check_leaf
Convert to new API and move to kernel space. Take the opportunity to
test the situation a little more thoroughly (ie at different offsets).
Signed-off-by: Matthew Wilcox <willy@infradead.org>
Diffstat (limited to 'lib/test_ida.c')
-rw-r--r-- | lib/test_ida.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/test_ida.c b/lib/test_ida.c index 8c9a0672696b..1988f91a20c8 100644 --- a/lib/test_ida.c +++ b/lib/test_ida.c @@ -25,11 +25,36 @@ void ida_dump(struct ida *ida) { } } \ } while (0) +/* + * Check what happens when we fill a leaf and then delete it. This may + * discover mishandling of IDR_FREE. + */ +static void ida_check_leaf(struct ida *ida, unsigned int base) +{ + unsigned long i; + + for (i = 0; i < IDA_BITMAP_BITS; i++) { + IDA_BUG_ON(ida, ida_alloc_min(ida, base, GFP_KERNEL) != + base + i); + } + + ida_destroy(ida); + IDA_BUG_ON(ida, !ida_is_empty(ida)); + + IDA_BUG_ON(ida, ida_alloc(ida, GFP_KERNEL) != 0); + IDA_BUG_ON(ida, ida_is_empty(ida)); + ida_free(ida, 0); + IDA_BUG_ON(ida, !ida_is_empty(ida)); +} + static int ida_checks(void) { DEFINE_IDA(ida); IDA_BUG_ON(&ida, !ida_is_empty(&ida)); + ida_check_leaf(&ida, 0); + ida_check_leaf(&ida, 1024); + ida_check_leaf(&ida, 1024 * 64); printk("IDA: %u of %u tests passed\n", tests_passed, tests_run); return (tests_run != tests_passed) ? 0 : -EINVAL; |