diff options
| author | Karolina Drobnik <karolinadrobnik@gmail.com> | 2022-02-28 15:46:44 +0100 |
|---|---|---|
| committer | Mike Rapoport <rppt@linux.ibm.com> | 2022-03-09 15:18:57 +0200 |
| commit | 284d950dd6b0ea699608455e443341e82f9719c8 (patch) | |
| tree | 3e60c40114b193b67550ae10e823da7937829b1b /tools/testing/memblock/tests/common.c | |
| parent | 2c3dacba5d46ef0ff83fe6b82570c433910b63ab (diff) | |
| download | lwn-284d950dd6b0ea699608455e443341e82f9719c8.tar.gz lwn-284d950dd6b0ea699608455e443341e82f9719c8.zip | |
memblock tests: Add simulation of physical memory
Allocation functions that return virtual addresses (with an exception
of _raw variant) clear the allocated memory after reserving it. This
requires valid memory ranges in memblock.memory.
Introduce memory_block variable to store memory that can be registered
with memblock data structure. Move assert.h and size.h includes to common.h
to share them between the test files.
Signed-off-by: Karolina Drobnik <karolinadrobnik@gmail.com>
Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
Link: https://lore.kernel.org/r/dce115503c74a6936c44694b00014658a1bb6522.1646055639.git.karolinadrobnik@gmail.com
Diffstat (limited to 'tools/testing/memblock/tests/common.c')
| -rw-r--r-- | tools/testing/memblock/tests/common.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tools/testing/memblock/tests/common.c b/tools/testing/memblock/tests/common.c index dd7e87c589fe..62d3191f7c9a 100644 --- a/tools/testing/memblock/tests/common.c +++ b/tools/testing/memblock/tests/common.c @@ -5,6 +5,8 @@ #define INIT_MEMBLOCK_REGIONS 128 #define INIT_MEMBLOCK_RESERVED_REGIONS INIT_MEMBLOCK_REGIONS +static struct test_memory memory_block; + void reset_memblock_regions(void) { memset(memblock.memory.regions, 0, @@ -27,3 +29,20 @@ void reset_memblock_attributes(void) memblock.bottom_up = false; memblock.current_limit = MEMBLOCK_ALLOC_ANYWHERE; } + +void setup_memblock(void) +{ + reset_memblock_regions(); + memblock_add((phys_addr_t)memory_block.base, MEM_SIZE); +} + +void dummy_physical_memory_init(void) +{ + memory_block.base = malloc(MEM_SIZE); + assert(memory_block.base); +} + +void dummy_physical_memory_cleanup(void) +{ + free(memory_block.base); +} |
