Skip to content

Commit 61da033

Browse files
remckeerppt
authored andcommitted
memblock tests: introduce range tests for memblock_alloc_exact_nid_raw
Add TEST_F_EXACT flag, which specifies that tests should run memblock_alloc_exact_nid_raw(). Introduce range tests for memblock_alloc_exact_nid_raw() by using the TEST_F_EXACT flag to run the range tests in alloc_nid_api.c, since memblock_alloc_exact_nid_raw() and memblock_alloc_try_nid_raw() behave the same way when nid = NUMA_NO_NODE. Rename tests and other functions in alloc_nid_api.c by removing "_try". Since the test names will be displayed in verbose output, they need to be general enough to refer to any of the memblock functions that the tests may run. Acked-by: David Hildenbrand <[email protected]> Signed-off-by: Rebecca Mckeever <[email protected]> Signed-off-by: Mike Rapoport <[email protected]> Link: https://lore.kernel.org/r/5a4b6d1b6130ab7375314e1c45a6d5813dfdabbd.1667802195.git.remckee0@gmail.com
1 parent 62a56c5 commit 61da033

File tree

7 files changed

+320
-264
lines changed

7 files changed

+320
-264
lines changed

tools/testing/memblock/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ CFLAGS += -I. -I../../include -Wall -O2 -fsanitize=address \
77
LDFLAGS += -fsanitize=address -fsanitize=undefined
88
TARGETS = main
99
TEST_OFILES = tests/alloc_nid_api.o tests/alloc_helpers_api.o tests/alloc_api.o \
10-
tests/basic_api.o tests/common.o
10+
tests/basic_api.o tests/common.o tests/alloc_exact_nid_api.o
1111
DEP_OFILES = memblock.o lib/slab.o mmzone.o slab.o
1212
OFILES = main.o $(DEP_OFILES) $(TEST_OFILES)
1313
EXTR_SRC = ../../../mm/memblock.c

tools/testing/memblock/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "tests/alloc_api.h"
44
#include "tests/alloc_helpers_api.h"
55
#include "tests/alloc_nid_api.h"
6+
#include "tests/alloc_exact_nid_api.h"
67
#include "tests/common.h"
78

89
int main(int argc, char **argv)
@@ -12,6 +13,7 @@ int main(int argc, char **argv)
1213
memblock_alloc_checks();
1314
memblock_alloc_helpers_checks();
1415
memblock_alloc_nid_checks();
16+
memblock_alloc_exact_nid_checks();
1517

1618
return 0;
1719
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
#include "alloc_exact_nid_api.h"
3+
#include "alloc_nid_api.h"
4+
5+
#define FUNC_NAME "memblock_alloc_exact_nid_raw"
6+
7+
int memblock_alloc_exact_nid_checks(void)
8+
{
9+
prefix_reset();
10+
prefix_push(FUNC_NAME);
11+
12+
reset_memblock_attributes();
13+
dummy_physical_memory_init();
14+
15+
memblock_alloc_exact_nid_range_checks();
16+
17+
dummy_physical_memory_cleanup();
18+
19+
prefix_pop();
20+
21+
return 0;
22+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* SPDX-License-Identifier: GPL-2.0-or-later */
2+
#ifndef _MEMBLOCK_ALLOC_EXACT_NID_H
3+
#define _MEMBLOCK_ALLOC_EXACT_NID_H
4+
5+
#include "common.h"
6+
7+
int memblock_alloc_exact_nid_checks(void);
8+
9+
#endif

0 commit comments

Comments
 (0)