From fa41ec052d26e2497fc29e28dc0202317d715f30 Mon Sep 17 00:00:00 2001 From: Watson Zeng Date: Mon, 24 May 2021 16:35:36 +0800 Subject: [PATCH] tests: mem_alloc: workaround aggressive optimization As we don't use memory allocated in test_calloc, test_no_mem_malloc, and test_no_mem_realloc. malloc call can be optimized away (that really happens with ARC MWDT toolchain). That breaks the test. So disable optimization for these functions. Signed-off-by: Watson Zeng --- tests/lib/mem_alloc/src/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/lib/mem_alloc/src/main.c b/tests/lib/mem_alloc/src/main.c index 7d48444c263..33ba50558d3 100644 --- a/tests/lib/mem_alloc/src/main.c +++ b/tests/lib/mem_alloc/src/main.c @@ -146,7 +146,7 @@ void test_malloc(void) iptr = NULL; } #if (CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE == 0) -void test_no_mem_malloc(void) +__no_optimization void test_no_mem_malloc(void) { int *iptr = NULL; @@ -155,7 +155,7 @@ void test_no_mem_malloc(void) free(iptr); iptr = NULL; } -void test_no_mem_realloc(void) +__no_optimization void test_no_mem_realloc(void) { char *ptr = NULL; char *reloc_ptr = NULL; @@ -237,7 +237,7 @@ void test_calloc(void) #define CALLOC_BUFLEN (200) static ZTEST_BMEM unsigned char zerobuf[CALLOC_BUFLEN]; -void test_calloc(void) +__no_optimization void test_calloc(void) { char *cptr = NULL;