tests/ztest/fail: Fix build for native_sim

The final executable output from the native_sim
(or native_posix) build is zephyr.exe
(in native_posix zephyr.elf happened to be just a copy of
the exe, but in native_sim it is an intermediate build step)

So we need to use the exe instead.

Note: As the exe is generated with a custom target, we need
to install it using install(FILES), which also requires the
destination and permissions to be listed manually. The
permissions set are just the cmake default permissions
for install(PROGRAMS).

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This commit is contained in:
Alberto Escolar Piedras 2023-11-16 11:26:22 +01:00 committed by Carles Cufí
commit 0b3a7bc7d4
2 changed files with 7 additions and 3 deletions

View file

@ -4,7 +4,7 @@
cmake_minimum_required(VERSION 3.20.0)
include(ExternalProject)
# Add the sources and set up the build for either unit testing or native_posix
# Add the sources and set up the build for either unit testing or native_sim
list(APPEND SOURCES src/main.cpp)
if(BOARD STREQUAL unit_testing)
find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
@ -17,7 +17,7 @@ else()
set(target app)
# Set the target binary for the 'core' external project. The path to this must match the one set
# below in ExternalProject_Add's CMAKE_INSTALL_PREFIX
add_compile_definitions(FAIL_TARGET_BINARY="${CMAKE_BINARY_DIR}/core/bin/zephyr.elf")
add_compile_definitions(FAIL_TARGET_BINARY="${CMAKE_BINARY_DIR}/core/bin/zephyr.exe")
endif()
# Create the project and set the sources for the target

View file

@ -35,5 +35,9 @@ else()
target_sources(app PRIVATE ${SOURCES})
target_include_directories(app PRIVATE include)
install(TARGETS ${logical_target_for_zephyr_elf})
install(FILES ${APPLICATION_BINARY_DIR}/zephyr/${KERNEL_EXE_NAME}
DESTINATION bin/
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ
WORLD_EXECUTE WORLD_READ
)
endif()