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:
Fabio Baltieri 2023-05-17 10:28:16 +00:00 committed by Anas Nashif
commit f5830f3c3f
6 changed files with 24 additions and 0 deletions

View file

@ -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})