[PATCH 6/6] test: self: malloc: adapt to addition of MALLOC_MAX_SIZE
Ahmad Fatoum
a.fatoum at pengutronix.de
Thu Feb 20 12:30:32 PST 2025
Now that we enforce a maximum allocation size, adapt the tests to
account for this.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
test/self/malloc.c | 27 +++++++++++----------------
1 file changed, 11 insertions(+), 16 deletions(-)
diff --git a/test/self/malloc.c b/test/self/malloc.c
index 0feec810185f..79a32b5d97c7 100644
--- a/test/self/malloc.c
+++ b/test/self/malloc.c
@@ -84,16 +84,17 @@ static void test_malloc(void)
p = expect_alloc_ok(malloc(1));
free(p);
- if (mem_malloc_size) {
- tmp = expect_alloc_fail(malloc(RELOC_HIDE(SIZE_MAX, 0)));
- free(tmp);
+ p = expect_alloc_fail(malloc(RELOC_HIDE(SIZE_MAX, 0)));
+ free(p);
- if (0xf0000000 > mem_malloc_size) {
- tmp = expect_alloc_fail(malloc(RELOC_HIDE(0xf0000000, 0)));
- free(tmp);
- }
+ p = expect_alloc_fail(malloc(RELOC_HIDE(MALLOC_MAX_SIZE, 1)));
+ free(p);
+
+ if (mem_malloc_size) {
+ tmp = expect_alloc_fail(malloc(RELOC_HIDE(MALLOC_MAX_SIZE, -1)));
+ free(tmp);
} else {
- skipped_tests += 2;
+ skipped_tests++;
}
free(realloc(NULL, 1));
@@ -110,16 +111,10 @@ static void test_malloc(void)
tmp = expect_alloc_fail(realloc(p, mem_malloc_size));
free(tmp);
- if (0xf0000000 > mem_malloc_size) {
- tmp = expect_alloc_fail(realloc(p, RELOC_HIDE(0xf0000000, 0)));
- free(tmp);
- }
-
- tmp = expect_alloc_fail(realloc(p, RELOC_HIDE(SIZE_MAX, 0)));
+ tmp = expect_alloc_fail(realloc(p, RELOC_HIDE(MALLOC_MAX_SIZE, -1)));
free(tmp);
-
} else {
- skipped_tests += 3;
+ skipped_tests += 2;
}
free(p);
--
2.39.5
More information about the barebox
mailing list