Skip to content

Commit a9325cb

Browse files
committed
Add support for multiple devices in RTT CLI and implement parallel execution
1 parent 4b6051a commit a9325cb

File tree

2 files changed

+359
-84
lines changed

2 files changed

+359
-84
lines changed

.github/workflows/test-rtt.yml

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
name: Test RTT
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
workflow_dispatch:
8+
9+
env:
10+
VNET_BASE: 192.168.3
11+
VNET_MASK: 24
12+
13+
jobs:
14+
test-rtt:
15+
runs-on: self-hosted
16+
17+
steps:
18+
- name: Cleanup before start
19+
if: always()
20+
run: |
21+
pkill -9 -f JLinkRemoteServer || true
22+
docker rm -f jlink100 jlink101 jlink102 2>/dev/null || true
23+
docker network rm jlink-net 2>/dev/null || true
24+
sleep 2
25+
26+
- uses: actions/checkout@v4
27+
28+
- name: Install package
29+
run: |
30+
python3 -m venv .venv
31+
. .venv/bin/activate
32+
pip install -e ".[dev]"
33+
34+
- name: Detect devices and save serials
35+
run: |
36+
. .venv/bin/activate
37+
bmlab-scan | tee scan.txt
38+
count=$(grep -c "Target: *STM32F103RE" scan.txt)
39+
awk '/JLink Programmer/ {serial=""} /Serial:/ {serial=$2} /Target: *STM32F103RE/ && serial {print serial}' scan.txt | sort | uniq > serials.txt
40+
41+
if [ "$count" -ne 3 ]; then
42+
echo "Test failed: expected 3 STM32F103RE, found $count"
43+
cat scan.txt
44+
exit 1
45+
fi
46+
47+
- name: Flash firmware to all devices
48+
run: |
49+
. .venv/bin/activate
50+
serial1=$(sed -n '1p' serials.txt)
51+
serial2=$(sed -n '2p' serials.txt)
52+
serial3=$(sed -n '3p' serials.txt)
53+
54+
bmlab-flash .github/workflows/fw.bin --serial $serial1 $serial2 $serial3 --mcu STM32F103RE
55+
56+
- name: Test 1 — RTT single device by serial
57+
run: |
58+
. .venv/bin/activate
59+
serial=$(sed -n '1p' serials.txt)
60+
timeout 5 bmlab-rtt --serial $serial --timeout 3 | tee rtt-serial1.txt || true
61+
62+
if [ ! -s rtt-serial1.txt ]; then
63+
echo "Test 1 failed: no RTT output"
64+
exit 1
65+
fi
66+
67+
- name: Test 2 — RTT auto-detect device
68+
run: |
69+
. .venv/bin/activate
70+
timeout 5 bmlab-rtt --timeout 3 | tee rtt-auto.txt || true
71+
72+
if [ ! -s rtt-auto.txt ]; then
73+
echo "Test 2 failed: no RTT output"
74+
exit 1
75+
fi
76+
77+
- name: Test 3 — RTT multiple devices by serial
78+
run: |
79+
. .venv/bin/activate
80+
serial1=$(sed -n '1p' serials.txt)
81+
serial2=$(sed -n '2p' serials.txt)
82+
serial3=$(sed -n '3p' serials.txt)
83+
84+
mkdir -p rtt_logs_serial
85+
timeout 10 bmlab-rtt --serial $serial1 $serial2 $serial3 --output-dir rtt_logs_serial --timeout 3 || true
86+
87+
# Check that log files were created
88+
for s in $serial1 $serial2 $serial3; do
89+
logfile="rtt_logs_serial/rtt_serial_${s}.log"
90+
if [ ! -f "$logfile" ]; then
91+
echo "Test 3 failed: log file not found: $logfile"
92+
ls -la rtt_logs_serial/
93+
exit 1
94+
fi
95+
done
96+
97+
- name: Setup JLink network containers
98+
uses: ./.github/actions/setup-jlink-network
99+
with:
100+
serials-file: serials.txt
101+
vnet-base: ${{ env.VNET_BASE }}
102+
vnet-mask: ${{ env.VNET_MASK }}
103+
104+
- name: Flash firmware to network devices
105+
run: |
106+
. .venv/bin/activate
107+
bmlab-flash .github/workflows/fw.bin --ip $VNET_BASE.100 $VNET_BASE.101 $VNET_BASE.102 --mcu STM32F103RE
108+
109+
- name: Test 4 — RTT single device by IP
110+
run: |
111+
. .venv/bin/activate
112+
timeout 5 bmlab-rtt --ip $VNET_BASE.100 --timeout 3 | tee rtt-ip1.txt || true
113+
114+
if [ ! -s rtt-ip1.txt ]; then
115+
echo "Test 4 failed: no RTT output"
116+
cat rtt-ip1.txt
117+
exit 1
118+
fi
119+
120+
- name: Test 5 — RTT multiple devices by IP (parallel)
121+
run: |
122+
. .venv/bin/activate
123+
mkdir -p rtt_logs_ip
124+
timeout 10 bmlab-rtt --ip $VNET_BASE.100 $VNET_BASE.101 $VNET_BASE.102 --output-dir rtt_logs_ip --timeout 3 || true
125+
126+
# Check that log files were created for each IP
127+
for ip in 100 101 102; do
128+
logfile="rtt_logs_ip/rtt_${VNET_BASE}_${ip}.log"
129+
if [ ! -f "$logfile" ]; then
130+
echo "Test 5 failed: log file not found: $logfile"
131+
ls -la rtt_logs_ip/
132+
exit 1
133+
fi
134+
135+
# Check that file has content
136+
if [ ! -s "$logfile" ]; then
137+
echo "Test 5 warning: log file is empty: $logfile"
138+
fi
139+
done
140+
141+
echo "Test 5 passed: all log files created"
142+
ls -lh rtt_logs_ip/
143+
144+
- name: Cleanup after tests
145+
if: always()
146+
run: |
147+
docker rm -f jlink100 jlink101 jlink102 || true
148+
docker network rm jlink-net || true
149+
pkill -9 -f JLinkRemoteServer || true
150+
sleep 2

0 commit comments

Comments
 (0)