tests: mem_protest: workaround aggressive optimization
We have some static variables var, zeroed_var and bss_var in mem_partition.c and we only assert the value of them in the same file, so the compiler may pre-calculate it in compile stage, it's fine usually. But for variable zeroed_var (= 20420), we force to put it in bss section in link stage, the value will change in bss clean stage, so we will get a wrong result. Let's add volatile for these variables to disable pre-calculation. Signed-off-by: Watson Zeng <zhiwei@synopsys.com>
This commit is contained in:
parent
2945ccb7e2
commit
e451bf44fe
1 changed files with 6 additions and 3 deletions
|
@ -7,9 +7,12 @@
|
||||||
#include <kernel.h>
|
#include <kernel.h>
|
||||||
#include "mem_protect.h"
|
#include "mem_protect.h"
|
||||||
|
|
||||||
static K_APP_DMEM(ztest_mem_partition) int var = 1356;
|
/* Add volatile to disable pre-calculation in compile stage in some
|
||||||
static K_APP_BMEM(ztest_mem_partition) int zeroed_var = 20420;
|
* toolchain, such as arcmwdt toolchain.
|
||||||
static K_APP_BMEM(ztest_mem_partition) int bss_var;
|
*/
|
||||||
|
static volatile K_APP_DMEM(ztest_mem_partition) int var = 1356;
|
||||||
|
static volatile K_APP_BMEM(ztest_mem_partition) int zeroed_var = 20420;
|
||||||
|
static volatile K_APP_BMEM(ztest_mem_partition) int bss_var;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Test assigning global data and BSS variables to memory partitions
|
* @brief Test assigning global data and BSS variables to memory partitions
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue