Skip to content

Commit fa41ec0

Browse files
IRISZZWnashif
authored andcommitted
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 <[email protected]>
1 parent 0f69123 commit fa41ec0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/lib/mem_alloc/src/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ void test_malloc(void)
146146
iptr = NULL;
147147
}
148148
#if (CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE == 0)
149-
void test_no_mem_malloc(void)
149+
__no_optimization void test_no_mem_malloc(void)
150150
{
151151
int *iptr = NULL;
152152

@@ -155,7 +155,7 @@ void test_no_mem_malloc(void)
155155
free(iptr);
156156
iptr = NULL;
157157
}
158-
void test_no_mem_realloc(void)
158+
__no_optimization void test_no_mem_realloc(void)
159159
{
160160
char *ptr = NULL;
161161
char *reloc_ptr = NULL;
@@ -237,7 +237,7 @@ void test_calloc(void)
237237
#define CALLOC_BUFLEN (200)
238238
static ZTEST_BMEM unsigned char zerobuf[CALLOC_BUFLEN];
239239

240-
void test_calloc(void)
240+
__no_optimization void test_calloc(void)
241241
{
242242
char *cptr = NULL;
243243

0 commit comments

Comments
 (0)