mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-23 12:43:55 +08:00
idr-test: Convert ida_check_nomem to new API
We can't move this test to kernel space because there's no way to force kmalloc to fail. But we can use the new API and check this works when the test is in userspace. Signed-off-by: Matthew Wilcox <willy@infradead.org>
This commit is contained in:
parent
8ab8ba38d4
commit
06b0111366
@ -320,19 +320,20 @@ void ida_dump(struct ida *);
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Check that we get the correct error when we run out of memory doing
|
* Check that we get the correct error when we run out of memory doing
|
||||||
* allocations. To ensure we run out of memory, just "forget" to preload.
|
* allocations. In userspace, GFP_NOWAIT will always fail an allocation.
|
||||||
* The first test is for not having a bitmap available, and the second test
|
* The first test is for not having a bitmap available, and the second test
|
||||||
* is for not being able to allocate a level of the radix tree.
|
* is for not being able to allocate a level of the radix tree.
|
||||||
*/
|
*/
|
||||||
void ida_check_nomem(void)
|
void ida_check_nomem(void)
|
||||||
{
|
{
|
||||||
DEFINE_IDA(ida);
|
DEFINE_IDA(ida);
|
||||||
int id, err;
|
int id;
|
||||||
|
|
||||||
err = ida_get_new_above(&ida, 256, &id);
|
id = ida_alloc_min(&ida, 256, GFP_NOWAIT);
|
||||||
assert(err == -EAGAIN);
|
IDA_BUG_ON(&ida, id != -ENOMEM);
|
||||||
err = ida_get_new_above(&ida, 1UL << 30, &id);
|
id = ida_alloc_min(&ida, 1UL << 30, GFP_NOWAIT);
|
||||||
assert(err == -EAGAIN);
|
IDA_BUG_ON(&ida, id != -ENOMEM);
|
||||||
|
IDA_BUG_ON(&ida, !ida_is_empty(&ida));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user