ztest: error out when building tests with no compiler optimizations
Many tests are known to fail when built and no compiler optimizations. Add a CMake check to error out when building a ztest based test with no optimization, ask not file issues about it but also adds an opt-out option to bypass the error for tests are actually designed to work in this setup. Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This commit is contained in:
parent
243a9dfba4
commit
f5830f3c3f
|
@ -704,6 +704,14 @@ endif()
|
|||
|
||||
if(CONFIG_ZTEST)
|
||||
list(APPEND SYSCALL_INCLUDE_DIRS ${ZEPHYR_BASE}/subsys/testsuite/ztest/include)
|
||||
|
||||
if(CONFIG_NO_OPTIMIZATIONS AND NOT CONFIG_ZTEST_ALLOW_NO_OPTIMIZATIONS)
|
||||
message(FATAL_ERROR "Running tests with CONFIG_NO_OPTIMIZATIONS is not "
|
||||
"supported and known to break many tests, please do not file issues about "
|
||||
"it. If you really mean to do this also enable "
|
||||
"CONFIG_ZTEST_ALLOW_NO_OPTIMIZATIONS.")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
foreach(d ${SYSCALL_INCLUDE_DIRS})
|
||||
|
|
|
@ -103,6 +103,14 @@ config ZTEST_NO_YIELD
|
|||
yielding to the idle thread may put the board into a low power state
|
||||
where a debugger cannot connect to it.
|
||||
|
||||
config ZTEST_ALLOW_NO_OPTIMIZATIONS
|
||||
bool "Allow running tests with CONFIG_NO_OPTIMIZATIONS"
|
||||
depends on NO_OPTIMIZATIONS
|
||||
help
|
||||
Do not error out when building a test without compiler optimization.
|
||||
This is normally not supported, please don't file issues when running
|
||||
tests that are not explicitly tuned to work in this configuration.
|
||||
|
||||
if ZTEST_NEW_API
|
||||
|
||||
menu "ztest provided rules"
|
||||
|
|
|
@ -13,6 +13,7 @@ tests:
|
|||
filter: not CONFIG_TRUSTED_EXECUTION_NONSECURE
|
||||
extra_configs:
|
||||
- CONFIG_NO_OPTIMIZATIONS=y
|
||||
- CONFIG_ZTEST_ALLOW_NO_OPTIMIZATIONS=y
|
||||
- CONFIG_IDLE_STACK_SIZE=512
|
||||
- CONFIG_MAIN_STACK_SIZE=2048
|
||||
arch.interrupt.extra_exception_info:
|
||||
|
|
|
@ -11,6 +11,7 @@ tests:
|
|||
filter: not CONFIG_TRUSTED_EXECUTION_NONSECURE
|
||||
extra_configs:
|
||||
- CONFIG_NO_OPTIMIZATIONS=y
|
||||
- CONFIG_ZTEST_ALLOW_NO_OPTIMIZATIONS=y
|
||||
- CONFIG_IDLE_STACK_SIZE=512
|
||||
- CONFIG_MAIN_STACK_SIZE=2048
|
||||
min_flash: 192
|
||||
|
@ -25,6 +26,7 @@ tests:
|
|||
- CONFIG_FPU=y
|
||||
- CONFIG_FPU_SHARING=y
|
||||
- CONFIG_NO_OPTIMIZATIONS=y
|
||||
- CONFIG_ZTEST_ALLOW_NO_OPTIMIZATIONS=y
|
||||
- CONFIG_IDLE_STACK_SIZE=512
|
||||
- CONFIG_MAIN_STACK_SIZE=2048
|
||||
min_flash: 192
|
||||
|
|
|
@ -2,3 +2,4 @@ CONFIG_ZTEST=y
|
|||
CONFIG_ZTEST_NEW_API=y
|
||||
CONFIG_GEN_IRQ_VECTOR_TABLE=y
|
||||
CONFIG_DYNAMIC_INTERRUPTS=y
|
||||
CONFIG_ZTEST_ALLOW_NO_OPTIMIZATIONS=y
|
||||
|
|
|
@ -16,6 +16,7 @@ tests:
|
|||
extra_configs:
|
||||
- CONFIG_LOG_MODE_DEFERRED=y
|
||||
- CONFIG_NO_OPTIMIZATIONS=y
|
||||
- CONFIG_ZTEST_ALLOW_NO_OPTIMIZATIONS=y
|
||||
- CONFIG_IDLE_STACK_SIZE=2048
|
||||
logging.log_stack_immediate:
|
||||
extra_configs:
|
||||
|
@ -25,6 +26,7 @@ tests:
|
|||
extra_configs:
|
||||
- CONFIG_LOG_MODE_IMMEDIATE=y
|
||||
- CONFIG_NO_OPTIMIZATIONS=y
|
||||
- CONFIG_ZTEST_ALLOW_NO_OPTIMIZATIONS=y
|
||||
- CONFIG_IDLE_STACK_SIZE=2048
|
||||
logging.log_stack_deferred_cpp:
|
||||
extra_configs:
|
||||
|
@ -35,6 +37,7 @@ tests:
|
|||
extra_configs:
|
||||
- CONFIG_LOG_MODE_DEFERRED=y
|
||||
- CONFIG_NO_OPTIMIZATIONS=y
|
||||
- CONFIG_ZTEST_ALLOW_NO_OPTIMIZATIONS=y
|
||||
- CONFIG_CPP=y
|
||||
logging.log_stack_immediate_cpp:
|
||||
extra_configs:
|
||||
|
@ -45,4 +48,5 @@ tests:
|
|||
extra_configs:
|
||||
- CONFIG_LOG_MODE_IMMEDIATE=y
|
||||
- CONFIG_NO_OPTIMIZATIONS=y
|
||||
- CONFIG_ZTEST_ALLOW_NO_OPTIMIZATIONS=y
|
||||
- CONFIG_CPP=y
|
||||
|
|
Loading…
Reference in a new issue