Skip to content

Commit

Permalink
cmake: unittest: add -t run support
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
JordanYates authored and kartben committed Jan 15, 2025
1 parent 03eb479 commit 1556596
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmake/modules/unittest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 1556596

Please sign in to comment.