memblock tests: Add memblock_alloc_try_nid tests for bottom up
authorKarolina Drobnik <karolinadrobnik@gmail.com>
Mon, 28 Feb 2022 14:46:50 +0000 (15:46 +0100)
committerMike Rapoport <rppt@linux.ibm.com>
Wed, 9 Mar 2022 13:55:35 +0000 (15:55 +0200)
commit9d8f6abe980f98ffccad80b11d46df2116d7a5fc
treed0389d5f86f2e959384fab56845e59d342d1014d
parent8f98435d674e5b7ec382914d2755849f5a95754b
memblock tests: Add memblock_alloc_try_nid tests for bottom up

Add checks for memblock_alloc_try_nid for bottom up allocation direction.
As the definition of this function is pretty close to the core
memblock_alloc_range_nid, the test cases implemented here cover most of
the code paths related to the memory allocations.

The tested scenarios are:
  - Region can be allocated within the requested range (both with aligned
    and misaligned boundaries)
  - Region can be allocated between two already existing entries
  - Not enough space between already reserved regions
  - Memory at the range boundaries is reserved but there is enough space
    to allocate a new region
  - The memory range is too narrow but memory can be allocated before
    the maximum address
  - Edge cases:
      + Minimum address is below memblock_start_of_DRAM()
      + Maximum address is above memblock_end_of_DRAM()

Add test case wrappers to test both directions in the same context.

Signed-off-by: Karolina Drobnik <karolinadrobnik@gmail.com>
Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
Link: https://lore.kernel.org/r/1c0ba11b8da5dc8f71ad45175c536fa4be720984.1646055639.git.karolinadrobnik@gmail.com
tools/testing/memblock/tests/alloc_nid_api.c