1# SPDX-License-Identifier: Apache-2.0
2
3find_program(
4  RENODE
5  renode
6  )
7
8set(RENODE_FLAGS
9  --disable-xwt
10  --port -2
11  --pid-file renode.pid
12  )
13
14# Check if there is any Renode script overlay defined for the target board
15set(resc_overlay_file ${APPLICATION_SOURCE_DIR}/boards/${BOARD}.resc)
16if(EXISTS ${resc_overlay_file})
17  set(RENODE_OVERLAY include "@${resc_overlay_file}\;")
18  message(STATUS "Found Renode script overlay: ${resc_overlay_file}")
19endif()
20
21add_custom_target(run_renode
22  COMMAND
23  ${RENODE}
24  ${RENODE_FLAGS}
25  -e '$$bin=@${APPLICATION_BINARY_DIR}/zephyr/${KERNEL_ELF_NAME}\; include @${RENODE_SCRIPT}\; ${RENODE_OVERLAY} s'
26  WORKING_DIRECTORY ${APPLICATION_BINARY_DIR}
27  DEPENDS ${logical_target_for_zephyr_elf}
28  USES_TERMINAL
29  )
30
31find_program(
32  RENODE_TEST
33  renode-test
34  )
35
36set(RENODE_TEST_FLAGS
37  --variable ELF:@${APPLICATION_BINARY_DIR}/zephyr/${KERNEL_ELF_NAME}
38  --variable RESC:@${RENODE_SCRIPT}
39  --variable UART:${RENODE_UART}
40  --variable KEYWORDS:${ZEPHYR_BASE}/tests/robot/common.robot
41  --results-dir ${APPLICATION_BINARY_DIR}
42  )
43
44add_custom_target(run_renode_test
45  COMMAND /bin/sh -c "\
46    if [ -z $$ROBOT_FILES ] \;\
47    then\
48        echo ''\;\
49        echo '--- Error: Robot file path is required to run Robot tests in Renode. To provide the path please set the ROBOT_FILES variable.'\;\
50        echo '--- To rerun the test with west execute:'\;\
51        echo '--- ROBOT_FILES=\\<FILES\\> west build -p -b \\<BOARD\\> -s \\<SOURCE_DIR\\> -t run_renode_test'\;\
52        echo ''\;\
53        exit 1\;\
54    fi\;"
55  COMMAND
56  ${RENODE_TEST}
57  ${RENODE_TEST_FLAGS}
58  ${APPLICATION_SOURCE_DIR}/$$ROBOT_FILES
59  WORKING_DIRECTORY ${APPLICATION_BINARY_DIR}
60  DEPENDS ${logical_target_for_zephyr_elf}
61  USES_TERMINAL
62  )
63