aboutsummaryrefslogtreecommitdiff
path: root/tools/testing/memblock/tests/common.c
diff options
context:
space:
mode:
authorKarolina Drobnik <karolinadrobnik@gmail.com>2022-02-28 15:46:43 +0100
committerMike Rapoport <rppt@linux.ibm.com>2022-03-09 15:18:57 +0200
commit2c3dacba5d46ef0ff83fe6b82570c433910b63ab (patch)
tree6f9ecc3261af43f6e187cf2f7b97ca7419e8f61e /tools/testing/memblock/tests/common.c
parent2a7ceac9e58167fadc3496c5f694543d4bbe03ef (diff)
memblock tests: Split up reset_memblock function
All memblock data structure fields are reset in one function. In some test cases, it's preferred to reset memory region arrays without modifying other values like allocation direction flag. Extract two functions from reset_memblock, so it's possible to reset different parts of memblock: - reset_memblock_regions - reset region arrays and their counters - reset_memblock_attributes - set other fields to their default values Update checks in basic_api.c to use new definitions. Remove reset_memblock call from memblock_initialization_check, so the true initial values are tested. Signed-off-by: Karolina Drobnik <karolinadrobnik@gmail.com> Signed-off-by: Mike Rapoport <rppt@linux.ibm.com> Link: https://lore.kernel.org/r/5cc1ba9a0ade922dbf4ba450165b81a9ed17d4a9.1646055639.git.karolinadrobnik@gmail.com
Diffstat (limited to 'tools/testing/memblock/tests/common.c')
-rw-r--r--tools/testing/memblock/tests/common.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/tools/testing/memblock/tests/common.c b/tools/testing/memblock/tests/common.c
index 03de6eab0c3c..dd7e87c589fe 100644
--- a/tools/testing/memblock/tests/common.c
+++ b/tools/testing/memblock/tests/common.c
@@ -5,23 +5,25 @@
#define INIT_MEMBLOCK_REGIONS 128
#define INIT_MEMBLOCK_RESERVED_REGIONS INIT_MEMBLOCK_REGIONS
-void reset_memblock(void)
+void reset_memblock_regions(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;
+ memset(memblock.reserved.regions, 0,
+ memblock.reserved.cnt * sizeof(struct memblock_region));
memblock.reserved.cnt = 1;
memblock.reserved.max = INIT_MEMBLOCK_RESERVED_REGIONS;
- memblock.reserved.name = "reserved";
memblock.reserved.total_size = 0;
+}
+void reset_memblock_attributes(void)
+{
+ memblock.memory.name = "memory";
+ memblock.reserved.name = "reserved";
memblock.bottom_up = false;
memblock.current_limit = MEMBLOCK_ALLOC_ANYWHERE;
}