mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-19 03:53:51 -04:00
memblock tests: Add memblock reset function
Memblock simulator needs to be able to reset memblock data structures between different test cases. Add a function that sets all fields to their default values. Add a test checking if memblock is being initialized to expected values. Signed-off-by: Karolina Drobnik <karolinadrobnik@gmail.com> Signed-off-by: Mike Rapoport <rppt@kernel.org> Link: https://lore.kernel.org/r/8c185aa7e0dd68c2c7e937c9a06c90ae413e240f.1643796665.git.karolinadrobnik@gmail.com
This commit is contained in:
committed by
Mike Rapoport
parent
16802e55de
commit
f3252a22d1
32
tools/testing/memblock/tests/basic_api.c
Normal file
32
tools/testing/memblock/tests/basic_api.c
Normal file
@@ -0,0 +1,32 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#include <string.h>
|
||||
#include <linux/memblock.h>
|
||||
#include "basic_api.h"
|
||||
|
||||
#define EXPECTED_MEMBLOCK_REGIONS 128
|
||||
|
||||
static int memblock_initialization_check(void)
|
||||
{
|
||||
reset_memblock();
|
||||
|
||||
assert(memblock.memory.regions);
|
||||
assert(memblock.memory.cnt == 1);
|
||||
assert(memblock.memory.max == EXPECTED_MEMBLOCK_REGIONS);
|
||||
assert(strcmp(memblock.memory.name, "memory") == 0);
|
||||
|
||||
assert(memblock.reserved.regions);
|
||||
assert(memblock.reserved.cnt == 1);
|
||||
assert(memblock.memory.max == EXPECTED_MEMBLOCK_REGIONS);
|
||||
assert(strcmp(memblock.reserved.name, "reserved") == 0);
|
||||
|
||||
assert(!memblock.bottom_up);
|
||||
assert(memblock.current_limit == MEMBLOCK_ALLOC_ANYWHERE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int memblock_basic_checks(void)
|
||||
{
|
||||
memblock_initialization_check();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user