diff options
author | Karolina Drobnik <karolinadrobnik@gmail.com> | 2022-02-02 14:03:14 +0300 |
---|---|---|
committer | Mike Rapoport <rppt@linux.ibm.com> | 2022-02-21 09:26:04 +0300 |
commit | e393c093ec7640dc42ad63fb414a9680b69f26f1 (patch) | |
tree | 2c5de75248f4e843000697a3630d8b345d730596 /tools/testing/memblock/tests | |
parent | b4d968931e5e07cdff262bfd9b60291d072ad0d7 (diff) | |
download | linux-e393c093ec7640dc42ad63fb414a9680b69f26f1.tar.xz |
memblock tests: Add memblock_add_node test
Add a simple test for NUMA-aware variant of memblock_add function.
Signed-off-by: Karolina Drobnik <karolinadrobnik@gmail.com>
Signed-off-by: Mike Rapoport <rppt@kernel.org>
Link: https://lore.kernel.org/r/e2d0e6dd264c8c169242b556f7c5b12153f3dee5.1643796665.git.karolinadrobnik@gmail.com
Diffstat (limited to 'tools/testing/memblock/tests')
-rw-r--r-- | tools/testing/memblock/tests/basic_api.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tools/testing/memblock/tests/basic_api.c b/tools/testing/memblock/tests/basic_api.c index 8a0d2ffa4e21..2194a141cfe6 100644 --- a/tools/testing/memblock/tests/basic_api.c +++ b/tools/testing/memblock/tests/basic_api.c @@ -56,6 +56,39 @@ static int memblock_add_simple_check(void) } /* + * A simple test that adds a memory block of a specified base address, size + * NUMA node and memory flags to the collection of available memory regions. + * It checks if the new entry, region counter and total memory size have + * expected values. + */ +static int memblock_add_node_simple_check(void) +{ + struct memblock_region *rgn; + + rgn = &memblock.memory.regions[0]; + + struct region r = { + .base = SZ_1M, + .size = SZ_16M + }; + + reset_memblock(); + memblock_add_node(r.base, r.size, 1, MEMBLOCK_HOTPLUG); + + assert(rgn->base == r.base); + assert(rgn->size == r.size); +#ifdef CONFIG_NUMA + assert(rgn->nid == 1); +#endif + assert(rgn->flags == MEMBLOCK_HOTPLUG); + + assert(memblock.memory.cnt == 1); + assert(memblock.memory.total_size == r.size); + + return 0; +} + +/* * A test that tries to add two memory blocks that don't overlap with one * another. It checks if two correctly initialized entries were added to the * collection of available memory regions (memblock.memory) and if this @@ -230,6 +263,7 @@ static int memblock_add_twice_check(void) static int memblock_add_checks(void) { memblock_add_simple_check(); + memblock_add_node_simple_check(); memblock_add_disjoint_check(); memblock_add_overlap_top_check(); memblock_add_overlap_bottom_check(); |