Skip to content

Commit

Permalink
cmocka/cmake: add $SIMULATOR to fix "make test" on host
Browse files Browse the repository at this point in the history
Before this it was required to find and run the executables one by one

Signed-off-by: Marc Herbert <[email protected]>
  • Loading branch information
marc-hb committed Jul 25, 2021
1 parent 899128f commit 49b2631
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion test/cmocka/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@ add_library(cmocka STATIC IMPORTED)
if(BUILD_UNIT_TESTS_HOST)
set(UT_CC_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/cmocka-host-gcc-toolchain.cmake)
set(UT_TOOLCHAIN "")
# TODO: add an option to support valgrind.
# In the mean time use scripts/run-mocks.sh for valgrind.
set(SIMULATOR "")
elseif(BUILD_UNIT_TESTS_XTENSA_GCC)
# GCC xtensa build for future Qemu.
set(UT_CC_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/cmocka-xtensa-gcc-toolchain.cmake)
set(UT_TOOLCHAIN "-DTOOLCHAIN=${TOOLCHAIN}")
set(SIMULATOR xt-run --exit_with_target_code)
else()
# xtensa XCC build for xt-run.
set(UT_CC_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/cmocka-xtensa-xt-toolchain.cmake)
set(UT_TOOLCHAIN "")
set(SIMULATOR xt-run --exit_with_target_code)
endif()

if(DEFINED CMOCKA_DIRECTORY)
Expand Down Expand Up @@ -102,7 +107,7 @@ function(cmocka_test test_name)
# Cmocka requires this define for stdint.h that defines uintptr
target_compile_definitions(${test_name} PRIVATE -D_UINTPTR_T_DEFINED)

add_test(NAME ${test_name} COMMAND xt-run --exit_with_target_code ${test_name})
add_test(NAME ${test_name} COMMAND ${SIMULATOR} ${test_name})

sof_append_relative_path_definitions(${test_name})
endfunction()
Expand Down

0 comments on commit 49b2631

Please sign in to comment.