99# being connected when modules are loaded at runtime).
1010#
1111# Usage:
12- # ./scripts/run_renode_tests.sh [SOURCE_DIR [BUILD_DIR]]
12+ # ./scripts/run_renode_tests.sh [OPTIONS] [ SOURCE_DIR [BUILD_DIR]]
1313#
14- # SOURCE_DIR Path to the project root.
15- # Defaults to the parent directory of this script.
16- # BUILD_DIR Path to the build directory.
17- # Defaults to SOURCE_DIR/build.
14+ # --skip-build Skip the cmake configure + build steps. Use this when the
15+ # firmware has already been built (e.g. in a prior CI step)
16+ # and only the Renode emulation part needs to be run.
17+ # SOURCE_DIR Path to the project root.
18+ # Defaults to the parent directory of this script.
19+ # BUILD_DIR Path to the build directory.
20+ # Defaults to SOURCE_DIR/build.
1821
1922set -e
2023
2124SCRIPT_DIR=" $( cd " $( dirname " $0 " ) " && pwd) "
25+
26+ SKIP_BUILD=0
27+ POSITIONAL=()
28+ for arg in " $@ " ; do
29+ case " $arg " in
30+ --skip-build) SKIP_BUILD=1 ;;
31+ * ) POSITIONAL+=(" $arg " ) ;;
32+ esac
33+ done
34+ set -- " ${POSITIONAL[@]} "
35+
2236SOURCE_DIR=" ${1:- $(cd " $SCRIPT_DIR /.." && pwd)} "
2337BUILD_DIR=" ${2:- $SOURCE_DIR / build} "
2438
@@ -37,6 +51,7 @@ echo "=============================================="
3751echo " Source dir : $SOURCE_DIR "
3852echo " Build dir : $BUILD_DIR "
3953echo " Board : $BOARD "
54+ echo " Skip build : $SKIP_BUILD "
4055echo " "
4156
4257# Cleanup helper – kill any lingering background processes on exit
@@ -50,31 +65,44 @@ cleanup() {
5065}
5166trap cleanup EXIT
5267
53- # -------------------------------------------------------
54- # Step 1 – Build firmware with emulation mode enabled
55- # -------------------------------------------------------
56- echo " [1/4] Building firmware (BOARD=$BOARD , DMBOOT_EMULATION=ON)..."
57- cmake -DCMAKE_BUILD_TYPE=Debug \
58- -DBOARD=" $BOARD " \
59- -DDMBOOT_EMULATION=ON \
60- -S " $SOURCE_DIR " \
61- -B " $BUILD_DIR "
62- cmake --build " $BUILD_DIR " --config Debug
63- echo " ✓ Build completed"
64- echo " "
65-
66- # -------------------------------------------------------
67- # Step 2 – Verify install-firmware target
68- # -------------------------------------------------------
69- echo " [2/4] Testing install-firmware target..."
70- cmake --build " $BUILD_DIR " --target install-firmware
71- if [ ! -f " $BUILD_DIR /renode_firmware.elf" ]; then
72- echo " ✗ renode_firmware.elf not found after install-firmware"
73- exit 1
68+ if [ " $SKIP_BUILD " -eq 0 ]; then
69+ # -------------------------------------------------------
70+ # Step 1 – Build firmware with emulation mode enabled
71+ # -------------------------------------------------------
72+ echo " [1/4] Building firmware (BOARD=$BOARD , DMBOOT_EMULATION=ON)..."
73+ cmake -DCMAKE_BUILD_TYPE=Debug \
74+ -DBOARD=" $BOARD " \
75+ -DDMBOOT_EMULATION=ON \
76+ -S " $SOURCE_DIR " \
77+ -B " $BUILD_DIR "
78+ cmake --build " $BUILD_DIR " --config Debug
79+ echo " ✓ Build completed"
80+ echo " "
81+
82+ # -------------------------------------------------------
83+ # Step 2 – Verify install-firmware target
84+ # -------------------------------------------------------
85+ echo " [2/4] Testing install-firmware target..."
86+ cmake --build " $BUILD_DIR " --target install-firmware
87+ if [ ! -f " $BUILD_DIR /renode_firmware.elf" ]; then
88+ echo " ✗ renode_firmware.elf not found after install-firmware"
89+ exit 1
90+ fi
91+ ls -lh " $BUILD_DIR /renode_firmware.elf"
92+ echo " ✓ install-firmware target works correctly"
93+ echo " "
94+ else
95+ # --skip-build: just verify the firmware exists
96+ echo " [1/4] Skipping build (--skip-build specified)"
97+ if [ ! -f " $BUILD_DIR /renode_firmware.elf" ]; then
98+ echo " ✗ renode_firmware.elf not found at $BUILD_DIR /renode_firmware.elf"
99+ echo " Run without --skip-build or build the firmware first."
100+ exit 1
101+ fi
102+ ls -lh " $BUILD_DIR /renode_firmware.elf"
103+ echo " ✓ Firmware found"
104+ echo " "
74105fi
75- ls -lh " $BUILD_DIR /renode_firmware.elf"
76- echo " ✓ install-firmware target works correctly"
77- echo " "
78106
79107# -------------------------------------------------------
80108# Step 3 – Start Renode in the background
0 commit comments