cmake: unittest: add -t run support

Add support to run unit tests directly from `west build`, for
environments where `west build -t run-test` (which runs the binary under
valgrind) is inappropriate or unavailable (WSL).

`west build -t run` also has the muscle-memory advantage of being the
same target name as the `native_sim` boards.

Signed-off-by: Jordan Yates <jordan@embeint.com>
This commit is contained in:
Jordan Yates 2025-01-11 16:58:29 +10:00 committed by Benjamin Cabé
commit 1556596def

View file

@ -162,6 +162,13 @@ if(VALGRIND_PROGRAM)
)
endif()
add_custom_target(run
COMMAND
$<TARGET_FILE:testbinary>
DEPENDS testbinary
WORKING_DIRECTORY ${APPLICATION_BINARY_DIR}
)
add_custom_target(run-test
COMMAND
${VALGRIND} ${VALGRIND_FLAGS}