mirror of
https://github.com/torvalds/linux.git
synced 2026-04-24 17:42:27 -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
27
tools/testing/memblock/tests/common.c
Normal file
27
tools/testing/memblock/tests/common.c
Normal file
@@ -0,0 +1,27 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#include "tests/common.h"
|
||||
#include <string.h>
|
||||
|
||||
#define INIT_MEMBLOCK_REGIONS 128
|
||||
#define INIT_MEMBLOCK_RESERVED_REGIONS INIT_MEMBLOCK_REGIONS
|
||||
|
||||
void reset_memblock(void)
|
||||
{
|
||||
memset(memblock.memory.regions, 0,
|
||||
memblock.memory.cnt * sizeof(struct memblock_region));
|
||||
memset(memblock.reserved.regions, 0,
|
||||
memblock.reserved.cnt * sizeof(struct memblock_region));
|
||||
|
||||
memblock.memory.cnt = 1;
|
||||
memblock.memory.max = INIT_MEMBLOCK_REGIONS;
|
||||
memblock.memory.name = "memory";
|
||||
memblock.memory.total_size = 0;
|
||||
|
||||
memblock.reserved.cnt = 1;
|
||||
memblock.reserved.max = INIT_MEMBLOCK_RESERVED_REGIONS;
|
||||
memblock.reserved.name = "reserved";
|
||||
memblock.reserved.total_size = 0;
|
||||
|
||||
memblock.bottom_up = false;
|
||||
memblock.current_limit = MEMBLOCK_ALLOC_ANYWHERE;
|
||||
}
|
||||
Reference in New Issue
Block a user