From b0bfc5e19a4d7267bd2269979799893207dfe3fb Mon Sep 17 00:00:00 2001 From: deadwood Date: Fri, 27 Feb 2015 20:06:20 +0000 Subject: [PATCH] test/exec: adjust test scenario to situation not handled by TLSF git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@50153 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- test/exec/allocmem.c | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/test/exec/allocmem.c b/test/exec/allocmem.c index 66bf624674..ed45446f4c 100644 --- a/test/exec/allocmem.c +++ b/test/exec/allocmem.c @@ -16,19 +16,16 @@ */ #define output printf -static BOOL trash = FALSE; -static BOOL leak = FALSE; - -static inline void AccessTest(ULONG *ptr) +static inline void AccessTest(ULONG *ptr, BOOL trash) { if (!trash) - return; + return; ptr[-1] = 0x40302010; /* This should NOT cause mungwall warning */ ptr[0] = 0x01020304; /* This SHOULD produce mungwall warning */ } -static LONG test_allocabs(APTR block0) +static LONG test_allocabs(APTR block0, BOOL trash, BOOL leak, BOOL notlsf) { LONG result = RETURN_OK; APTR start, block1; @@ -40,7 +37,7 @@ static LONG test_allocabs(APTR block0) { output("Allocated at 0x%p, available memory: %lu bytes\n", block1, (unsigned long)AvailMem(MEMF_ANY)); - AccessTest(start + allocsize); + AccessTest(start + allocsize, trash); if (!leak) { @@ -64,11 +61,20 @@ static LONG test_allocabs(APTR block0) { output("Allocated at 0x%p, available memory: %lu bytes\n", block1, (unsigned long)AvailMem(MEMF_ANY)); - AccessTest(start + allocsize); + AccessTest(start + allocsize, trash); output("Freeing the block at 0x%p of %lu bytes...\n", start, (unsigned long)allocsize); - FreeMem(start, allocsize); - output("Done, available memory: %lu bytes\n", (unsigned long)AvailMem(MEMF_ANY)); + if (notlsf) + { + FreeMem(start, allocsize); + output("Done, available memory: %lu bytes\n", (unsigned long)AvailMem(MEMF_ANY)); + } + else + { + FreeMem(block1, allocsize + start - block1); + output("NOT SUPPORTED UNDER TLSF, freeing using returned address\n"); + output("Done, available memory: %lu bytes\n", (unsigned long)AvailMem(MEMF_ANY)); + } } else { @@ -85,6 +91,9 @@ int main(int argc, char **argv) LONG result = RETURN_OK; int i; APTR block0; + BOOL trash = FALSE; + BOOL leak = FALSE; + BOOL notlsf = FALSE; /* * Do some memory trashing if started with "trash" argument. @@ -94,9 +103,12 @@ int main(int argc, char **argv) for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "trash")) - trash = TRUE; - else if (!strcmp(argv[i], "leak")) - leak = TRUE; + trash = TRUE; + else if (!strcmp(argv[i], "leak")) + leak = TRUE; + else if (!strcmp(argv[i], "notlsf")) + notlsf = TRUE; + } /* We Forbid() in order to see how our allocations influence free memory size */ @@ -110,7 +122,7 @@ int main(int argc, char **argv) { output("Allocated at 0x%p, available memory: %lu bytes\n", block0, (unsigned long)AvailMem(MEMF_ANY)); - AccessTest(block0 + 256 * 1024); + AccessTest(block0 + 256 * 1024, trash); if (!leak) { @@ -125,7 +137,7 @@ int main(int argc, char **argv) result = RETURN_ERROR; } - if(test_allocabs(block0) != RETURN_OK) + if(test_allocabs(block0, trash, leak, notlsf) != RETURN_OK) result = RETURN_ERROR; output("\nTesting AllocMem(4096, MEMF_ANY|MEMF_REVERSE) ...\n"); @@ -141,7 +153,7 @@ int main(int argc, char **argv) result = RETURN_ERROR; } - AccessTest(block0 + 4096); + AccessTest(block0 + 4096, trash); if (!leak) { -- 2.11.4.GIT