Re: [PATCH v2 1/5] memblock tests: add range tests for memblock_alloc_exact_nid_raw

From: David Hildenbrand
Date: Tue Oct 11 2022 - 05:36:25 EST


On 11.10.22 06:19, Rebecca Mckeever wrote:
On Mon, Oct 10, 2022 at 01:16:03PM +0200, David Hildenbrand wrote:
On 03.10.22 01:41, Rebecca Mckeever wrote:
Add tests for memblock_alloc_exact_nid_raw() that are very similar to
the range tests for memblock_alloc_try_nid_raw().

Signed-off-by: Rebecca Mckeever <remckee0@xxxxxxxxx>
---
tools/testing/memblock/Makefile | 2 +-
tools/testing/memblock/main.c | 2 +
.../memblock/tests/alloc_exact_nid_api.c | 1208 +++++++++++++++++
.../memblock/tests/alloc_exact_nid_api.h | 9 +
4 files changed, 1220 insertions(+), 1 deletion(-)
create mode 100644 tools/testing/memblock/tests/alloc_exact_nid_api.c
create mode 100644 tools/testing/memblock/tests/alloc_exact_nid_api.h

diff --git a/tools/testing/memblock/Makefile b/tools/testing/memblock/Makefile
index 246f7ac8489b..2310ac4d080e 100644
--- a/tools/testing/memblock/Makefile
+++ b/tools/testing/memblock/Makefile
@@ -7,7 +7,7 @@ CFLAGS += -I. -I../../include -Wall -O2 -fsanitize=address \
LDFLAGS += -fsanitize=address -fsanitize=undefined
TARGETS = main
TEST_OFILES = tests/alloc_nid_api.o tests/alloc_helpers_api.o tests/alloc_api.o \
- tests/basic_api.o tests/common.o
+ tests/basic_api.o tests/common.o tests/alloc_exact_nid_api.o
DEP_OFILES = memblock.o lib/slab.o mmzone.o slab.o
OFILES = main.o $(DEP_OFILES) $(TEST_OFILES)
EXTR_SRC = ../../../mm/memblock.c
diff --git a/tools/testing/memblock/main.c b/tools/testing/memblock/main.c
index 4ca1024342b1..278f9dec5008 100644
--- a/tools/testing/memblock/main.c
+++ b/tools/testing/memblock/main.c
@@ -3,6 +3,7 @@
#include "tests/alloc_api.h"
#include "tests/alloc_helpers_api.h"
#include "tests/alloc_nid_api.h"
+#include "tests/alloc_exact_nid_api.h"
#include "tests/common.h"
int main(int argc, char **argv)
@@ -12,6 +13,7 @@ int main(int argc, char **argv)
memblock_alloc_checks();
memblock_alloc_helpers_checks();
memblock_alloc_nid_checks();
+ memblock_alloc_exact_nid_checks();
return 0;
}


memblock_alloc_exact_nid_raw(NUMA_NO_NODE) behaves exactly the way
memblock_alloc_try_nid_raw(NUMA_NO_NODE) behaves -- which is essentially
memblock_alloc_raw().

So do we really need a separate set of tests for these?

Instead of a separate set of tests, I could add a flag for
memblock_alloc_exact_nid_raw() to test_flags so that the range tests in
alloc_nid_api.c could be run with that flag. Do you think I should do
that, or omit tests for memblock_alloc_exact_nid_raw(NUMA_NO_NODE)
altogether?

Good question. From an API point of view, it makes sense to test that API somehow. With implementation in mind, it doesn't make too much sense to test it twice.

Whatever you prefer :) Just wanted to point out that separate tests don't make sense -- using a flag would be cleaner.

--
Thanks,

David / dhildenb