-
Notifications
You must be signed in to change notification settings - Fork 1
185 lines (155 loc) · 6.04 KB
/
test-rtt.yml
File metadata and controls
185 lines (155 loc) · 6.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
name: Test RTT
on:
push:
branches: [main]
paths:
- 'src/bmlab_toolkit/rtt_cli.py'
- 'src/bmlab_toolkit/jlink_programmer.py'
- 'src/bmlab_toolkit/programmer.py'
- 'src/bmlab_toolkit/constants.py'
- 'pyproject.toml'
- '.github/actions/setup-jlink-network/**'
- '.github/workflows/test-rtt.yml'
- '.github/workflows/fw.*'
pull_request:
paths:
- 'src/bmlab_toolkit/rtt_cli.py'
- 'src/bmlab_toolkit/jlink_programmer.py'
- 'src/bmlab_toolkit/programmer.py'
- 'src/bmlab_toolkit/constants.py'
- 'pyproject.toml'
- '.github/actions/setup-jlink-network/**'
- '.github/workflows/test-rtt.yml'
- '.github/workflows/fw.*'
workflow_dispatch:
permissions:
contents: read
packages: read
env:
VNET_BASE: 192.168.3
VNET_MASK: 24
jobs:
test-rtt:
runs-on: self-hosted
steps:
- name: Cleanup before start (containers)
if: always()
run: |
docker rm -f jlink100 jlink101 jlink102 2>/dev/null || true
docker network rm jlink-net 2>/dev/null || true
pkill -9 -f JLinkRemoteServer || true
sleep 2
- uses: actions/checkout@v5
- name: Install package
run: |
python3 -m venv .venv
. .venv/bin/activate
pip install -e ".[dev]"
- name: Detect devices and save serials
run: |
. .venv/bin/activate
bml scan | tee scan.txt
count=$(grep -c "Target: *STM32F103RE" scan.txt)
awk '/JLink Programmer/ {serial=""} /Serial:/ {serial=$2} /Target: *STM32F103RE/ && serial {print serial}' scan.txt | sort | uniq > serials.txt
if [ "$count" -ne 3 ]; then
echo "Test failed: expected 3 STM32F103RE, found $count"
cat scan.txt
exit 1
fi
- name: Flash firmware to all devices
run: |
. .venv/bin/activate
serial1=$(sed -n '1p' serials.txt)
serial2=$(sed -n '2p' serials.txt)
serial3=$(sed -n '3p' serials.txt)
bml flash .github/workflows/fw.bin --serial $serial1 $serial2 $serial3 --mcu STM32F103RE
- name: Test 1 — RTT single device by serial
run: |
. .venv/bin/activate
serial=$(sed -n '1p' serials.txt)
timeout 5 bml rtt --serial $serial --mcu STM32F103RE --timeout 3 | tee rtt-serial1.txt || true
if [ ! -s rtt-serial1.txt ]; then
echo "Test 1 failed: no RTT output"
exit 1
fi
- name: Test 2 — RTT auto-detect device
run: |
. .venv/bin/activate
serial=$(sed -n '1p' serials.txt)
timeout 5 bml rtt --serial $serial --timeout 3 | tee rtt-auto.txt || true
if [ ! -s rtt-auto.txt ]; then
echo "Test 2 failed: no RTT output"
exit 1
fi
- name: Test 3 — RTT multiple devices by serial (sequential)
run: |
. .venv/bin/activate
serial1=$(sed -n '1p' serials.txt)
serial2=$(sed -n '2p' serials.txt)
serial3=$(sed -n '3p' serials.txt)
echo "Testing serials: $serial1 $serial2 $serial3"
mkdir -p rtt_logs_serial
# Serial devices are processed sequentially (USB driver limitation)
# Each device: ~3s RTT + ~2s connect/disconnect = ~5s
# Total: 3 devices * 5s = 15s + 10s buffer = 25s
timeout 25 bml rtt --serial $serial1 $serial2 $serial3 --mcu STM32F103RE --output-dir rtt_logs_serial --timeout 3 || true
echo "Checking log files..."
ls -lh rtt_logs_serial/
# Check that log files were created
for s in $serial1 $serial2 $serial3; do
logfile="rtt_logs_serial/rtt_serial_${s}.log"
if [ ! -f "$logfile" ]; then
echo "Test 3 failed: log file not found: $logfile"
ls -la rtt_logs_serial/
exit 1
fi
done
- name: Setup JLink network containers
uses: ./.github/actions/setup-jlink-network
with:
serials-file: serials.txt
vnet-base: ${{ env.VNET_BASE }}
vnet-mask: ${{ env.VNET_MASK }}
- name: Flash firmware to network devices
run: |
. .venv/bin/activate
bml flash .github/workflows/fw.bin --ip $VNET_BASE.100 $VNET_BASE.101 $VNET_BASE.102 --mcu STM32F103RE
sleep 10
- name: Test 4 — RTT single device by IP
run: |
. .venv/bin/activate
timeout 60 bml rtt --ip $VNET_BASE.100 --timeout 3 | tee rtt-ip1.txt || true
if [ ! -s rtt-ip1.txt ]; then
echo "Test 4 failed: no RTT output"
cat rtt-ip1.txt
exit 1
fi
- name: Test 5 — RTT multiple devices by IP (parallel)
run: |
. .venv/bin/activate
mkdir -p rtt_logs_ip
timeout 60 bml rtt --ip $VNET_BASE.100 $VNET_BASE.101 $VNET_BASE.102 --output-dir rtt_logs_ip --timeout 3 || true
echo "Checking log files..."
ls -lh rtt_logs_ip/
# Check that log files were created for each IP
# Note: dots in IP are replaced with underscores in filename
for ip in 100 101 102; do
logfile="rtt_logs_ip/rtt_${VNET_BASE//./_}_${ip}.log"
if [ ! -f "$logfile" ]; then
echo "Test 5 failed: log file not found: $logfile"
ls -la rtt_logs_ip/
exit 1
fi
# Check that file has content
if [ ! -s "$logfile" ]; then
echo "Test 5 warning: log file is empty: $logfile"
fi
done
echo "Test 5 passed: all log files created"
- name: Cleanup after tests (containers)
if: always()
run: |
docker rm -f jlink100 jlink101 jlink102 2>/dev/null || true
docker network rm jlink-net 2>/dev/null || true
pkill -9 -f JLinkRemoteServer || true
sleep 2