diff --git a/CMakeLists.txt b/CMakeLists.txt index d9f07cef23b..1443e8ae082 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}) diff --git a/subsys/testsuite/ztest/Kconfig b/subsys/testsuite/ztest/Kconfig index 3dcb9ce593d..8f35ceb1500 100644 --- a/subsys/testsuite/ztest/Kconfig +++ b/subsys/testsuite/ztest/Kconfig @@ -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" diff --git a/tests/arch/arm/arm_interrupt/testcase.yaml b/tests/arch/arm/arm_interrupt/testcase.yaml index cf8f628310e..9b77a19ea6b 100644 --- a/tests/arch/arm/arm_interrupt/testcase.yaml +++ b/tests/arch/arm/arm_interrupt/testcase.yaml @@ -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: diff --git a/tests/arch/arm/arm_thread_swap/testcase.yaml b/tests/arch/arm/arm_thread_swap/testcase.yaml index 47810a6b540..d1dd199fdc4 100644 --- a/tests/arch/arm/arm_thread_swap/testcase.yaml +++ b/tests/arch/arm/arm_thread_swap/testcase.yaml @@ -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 diff --git a/tests/boards/nrf52_bsim/egu/prj.conf b/tests/boards/nrf52_bsim/egu/prj.conf index bcc4d42973f..88cef86f71b 100644 --- a/tests/boards/nrf52_bsim/egu/prj.conf +++ b/tests/boards/nrf52_bsim/egu/prj.conf @@ -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 diff --git a/tests/subsys/logging/log_stack/testcase.yaml b/tests/subsys/logging/log_stack/testcase.yaml index 5b2a84df706..852553db167 100644 --- a/tests/subsys/logging/log_stack/testcase.yaml +++ b/tests/subsys/logging/log_stack/testcase.yaml @@ -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