mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 02:32:09 -04:00
xarray: Move multiorder_check to in-kernel tests
This version is a little less thorough in order to be a little quicker, but tests the important edge cases. Also test adding a multiorder entry at a non-canonical index, and erasing it. Signed-off-by: Matthew Wilcox <[email protected]>
This commit is contained in:
parent
93eb07f72c
commit
4f06d6302d
2 changed files with 44 additions and 48 deletions
|
|
@ -422,6 +422,43 @@ static noinline void check_xas_erase(struct xarray *xa)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_XARRAY_MULTI
|
||||
static noinline void check_multi_store_1(struct xarray *xa, unsigned long index,
|
||||
unsigned int order)
|
||||
{
|
||||
XA_STATE(xas, xa, index);
|
||||
unsigned long min = index & ~((1UL << order) - 1);
|
||||
unsigned long max = min + (1UL << order);
|
||||
|
||||
xa_store_order(xa, index, order, xa_mk_value(index), GFP_KERNEL);
|
||||
XA_BUG_ON(xa, xa_load(xa, min) != xa_mk_value(index));
|
||||
XA_BUG_ON(xa, xa_load(xa, max - 1) != xa_mk_value(index));
|
||||
XA_BUG_ON(xa, xa_load(xa, max) != NULL);
|
||||
XA_BUG_ON(xa, xa_load(xa, min - 1) != NULL);
|
||||
|
||||
XA_BUG_ON(xa, xas_store(&xas, xa_mk_value(min)) != xa_mk_value(index));
|
||||
XA_BUG_ON(xa, xa_load(xa, min) != xa_mk_value(min));
|
||||
XA_BUG_ON(xa, xa_load(xa, max - 1) != xa_mk_value(min));
|
||||
XA_BUG_ON(xa, xa_load(xa, max) != NULL);
|
||||
XA_BUG_ON(xa, xa_load(xa, min - 1) != NULL);
|
||||
|
||||
xa_erase_index(xa, min);
|
||||
XA_BUG_ON(xa, !xa_empty(xa));
|
||||
}
|
||||
|
||||
static noinline void check_multi_store_2(struct xarray *xa, unsigned long index,
|
||||
unsigned int order)
|
||||
{
|
||||
XA_STATE(xas, xa, index);
|
||||
xa_store_order(xa, index, order, xa_mk_value(0), GFP_KERNEL);
|
||||
|
||||
XA_BUG_ON(xa, xas_store(&xas, xa_mk_value(1)) != xa_mk_value(0));
|
||||
XA_BUG_ON(xa, xas.xa_index != index);
|
||||
XA_BUG_ON(xa, xas_store(&xas, NULL) != xa_mk_value(1));
|
||||
XA_BUG_ON(xa, !xa_empty(xa));
|
||||
}
|
||||
#endif
|
||||
|
||||
static noinline void check_multi_store(struct xarray *xa)
|
||||
{
|
||||
#ifdef CONFIG_XARRAY_MULTI
|
||||
|
|
@ -487,6 +524,13 @@ static noinline void check_multi_store(struct xarray *xa)
|
|||
XA_BUG_ON(xa, !xa_empty(xa));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 20; i++) {
|
||||
check_multi_store_1(xa, 200, i);
|
||||
check_multi_store_1(xa, 0, i);
|
||||
check_multi_store_1(xa, (1UL << i) + 1, i);
|
||||
}
|
||||
check_multi_store_2(xa, 4095, 9);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue