build: downgrade the no optimization ztest error to warning

The current approach of failing the build on ztest with no optimization
broke coverage builds, and generally raised some concerns about being
too aggressive.

Downgrade the error to a warning and rework the option to inhibit the
warning, while also dropping it automatically for POSIX (that are not
really affected by stack size) and coverage run (that always runs with
no optimization).

Will reconsider this down the road if we still see issues filed for the
tests broken with no optimization and no further tuning.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This commit is contained in:
Fabio Baltieri 2023-05-23 08:15:58 +00:00 committed by Fabio Baltieri
parent c26f44ced3
commit b9ea2c2705
6 changed files with 19 additions and 20 deletions

View file

@ -705,11 +705,12 @@ 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.")
if(CONFIG_NO_OPTIMIZATIONS AND CONFIG_ZTEST_WARN_NO_OPTIMIZATIONS)
message(WARNING "Running tests with CONFIG_NO_OPTIMIZATIONS is generally "
"not supported and known to break in many cases due to stack overflow or "
"other problems. Please do not file issues about it unless the test is "
"specifically tuned to run in this configuration. To disable this warning "
"set CONFIG_ZTEST_WARN_NO_OPTIMIZATIONS=n.")
endif()
endif()

View file

@ -51,7 +51,4 @@ config UART_CONSOLE
endif # CONSOLE
config ZTEST_ALLOW_NO_OPTIMIZATIONS
default y if ZTEST
endif # BOARD_NRF52_BSIM

View file

@ -103,13 +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"
config ZTEST_WARN_NO_OPTIMIZATIONS
bool "Warn when running tests with CONFIG_NO_OPTIMIZATIONS"
default y if !(ARCH_POSIX || COVERAGE)
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.
Print a CMake warning when building ztests with no compiler
optimizations. Please don't file issues when running tests that are
not explicitly tuned to work in this configuration.
if ZTEST_NEW_API

View file

@ -13,7 +13,7 @@ tests:
filter: not CONFIG_TRUSTED_EXECUTION_NONSECURE
extra_configs:
- CONFIG_NO_OPTIMIZATIONS=y
- CONFIG_ZTEST_ALLOW_NO_OPTIMIZATIONS=y
- CONFIG_ZTEST_WARN_NO_OPTIMIZATIONS=n
- CONFIG_IDLE_STACK_SIZE=512
- CONFIG_MAIN_STACK_SIZE=2048
arch.interrupt.extra_exception_info:

View file

@ -11,7 +11,7 @@ tests:
filter: not CONFIG_TRUSTED_EXECUTION_NONSECURE
extra_configs:
- CONFIG_NO_OPTIMIZATIONS=y
- CONFIG_ZTEST_ALLOW_NO_OPTIMIZATIONS=y
- CONFIG_ZTEST_WARN_NO_OPTIMIZATIONS=n
- CONFIG_IDLE_STACK_SIZE=512
- CONFIG_MAIN_STACK_SIZE=2048
min_flash: 192
@ -26,7 +26,7 @@ tests:
- CONFIG_FPU=y
- CONFIG_FPU_SHARING=y
- CONFIG_NO_OPTIMIZATIONS=y
- CONFIG_ZTEST_ALLOW_NO_OPTIMIZATIONS=y
- CONFIG_ZTEST_WARN_NO_OPTIMIZATIONS=n
- CONFIG_IDLE_STACK_SIZE=512
- CONFIG_MAIN_STACK_SIZE=2048
min_flash: 192

View file

@ -16,7 +16,7 @@ tests:
extra_configs:
- CONFIG_LOG_MODE_DEFERRED=y
- CONFIG_NO_OPTIMIZATIONS=y
- CONFIG_ZTEST_ALLOW_NO_OPTIMIZATIONS=y
- CONFIG_ZTEST_WARN_NO_OPTIMIZATIONS=n
- CONFIG_IDLE_STACK_SIZE=2048
logging.log_stack_immediate:
extra_configs:
@ -26,7 +26,7 @@ tests:
extra_configs:
- CONFIG_LOG_MODE_IMMEDIATE=y
- CONFIG_NO_OPTIMIZATIONS=y
- CONFIG_ZTEST_ALLOW_NO_OPTIMIZATIONS=y
- CONFIG_ZTEST_WARN_NO_OPTIMIZATIONS=n
- CONFIG_IDLE_STACK_SIZE=2048
logging.log_stack_deferred_cpp:
extra_configs:
@ -37,7 +37,7 @@ tests:
extra_configs:
- CONFIG_LOG_MODE_DEFERRED=y
- CONFIG_NO_OPTIMIZATIONS=y
- CONFIG_ZTEST_ALLOW_NO_OPTIMIZATIONS=y
- CONFIG_ZTEST_WARN_NO_OPTIMIZATIONS=n
- CONFIG_CPP=y
logging.log_stack_immediate_cpp:
extra_configs:
@ -48,5 +48,5 @@ tests:
extra_configs:
- CONFIG_LOG_MODE_IMMEDIATE=y
- CONFIG_NO_OPTIMIZATIONS=y
- CONFIG_ZTEST_ALLOW_NO_OPTIMIZATIONS=y
- CONFIG_ZTEST_WARN_NO_OPTIMIZATIONS=n
- CONFIG_CPP=y