zephyr/tests/cmake/zephyr_get/sysbuild.cmake
Grzegorz Swiderski 5ef7229a8c tests: cmake: Add zephyr_get
As `zephyr_get()` grows in complexity and significance, it must continue
working as expected. Unfortunately, it has a few minor bugs already, but
they will be taken care of in the next few commits. Before that, though,
let's go ahead and add a test suite for this function.

For now, some tests will pass by using incorrect values, annotated with
the `# BUG` comments; they will be removed in later patches. The purpose
of having them now is to make it easier to see what's about to be fixed.

Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
2023-08-16 15:01:57 +02:00

36 lines
1 KiB
CMake

# SPDX-License-Identifier: Apache-2.0
# Add a few copies of the same image, so that we can configure
# multiple instances of the same test suite with minor tweaks,
# including different arguments given to them via testcase.yaml.
foreach(suffix "2nd" "3rd")
set(image ${DEFAULT_IMAGE}_${suffix})
if(NOT TARGET ${image})
ExternalZephyrProject_Add(
APPLICATION ${image}
SOURCE_DIR ${APP_DIR}
)
list(APPEND IMAGES ${image})
endif()
endforeach()
function(test_report)
set(failures "")
foreach(image ${IMAGES})
sysbuild_get(ASSERT_FAIL_COUNT IMAGE ${image} CACHE)
if(ASSERT_FAIL_COUNT GREATER 0)
set(failures "${failures}\n - ${image}: ${ASSERT_FAIL_COUNT} assertion(s) failed")
endif()
unset(ASSERT_FAIL_COUNT)
endforeach()
if(failures)
message(FATAL_ERROR "Test failures per sysbuild image: ${failures}")
endif()
endfunction()
if(NOT DEFERRED_TEST_REPORT)
# Defer until all test suite copies have been executed.
cmake_language(DEFER ID_VAR DEFERRED_TEST_REPORT CALL test_report)
endif()