-
Notifications
You must be signed in to change notification settings - Fork 1
163 lines (134 loc) · 5.34 KB
/
test-flash.yml
File metadata and controls
163 lines (134 loc) · 5.34 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
name: Test Flash
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
env:
VNET_BASE: 192.168.3
VNET_MASK: 24
jobs:
test-flash:
runs-on: self-hosted
steps:
- name: Cleanup before start
if: always()
run: |
pkill -9 -f JLinkRemoteServer || true
docker rm -f jlink100 jlink101 jlink102 2>/dev/null || true
docker network rm jlink-net 2>/dev/null || true
sleep 2
- uses: actions/checkout@v4
- 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
bmlab-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: Build JLinkRemoteServer Docker image
run: |
docker build -t my-jlink-image -f .github/workflows/jlinkRemoteServerEmu.dockerfile .
- name: Setup JLinkRemoteServer Docker containers
run: |
docker network rm jlink-net 2>/dev/null || true
docker network create --driver bridge --subnet=$VNET_BASE.0/$VNET_MASK --gateway=$VNET_BASE.1 jlink-net
serial1=$(sed -n '1p' serials.txt)
serial2=$(sed -n '2p' serials.txt)
serial3=$(sed -n '3p' serials.txt)
docker run -d --rm \
--device=/dev/bus/usb:/dev/bus/usb \
--name jlink100 \
--network jlink-net \
--ip $VNET_BASE.100 \
my-jlink-image \
-select usb=$serial1 -device STM32F103RE -endian little -speed 4000 -if swd
sleep 3
docker run -d --rm \
--device=/dev/bus/usb:/dev/bus/usb \
--name jlink101 \
--network jlink-net \
--ip $VNET_BASE.101 \
my-jlink-image \
-select usb=$serial2 -device STM32F103RE -endian little -speed 4000 -if swd
sleep 3
docker run -d --rm \
--device=/dev/bus/usb:/dev/bus/usb \
--name jlink102 \
--network jlink-net \
--ip $VNET_BASE.102 \
my-jlink-image \
-select usb=$serial3 -device STM32F103RE -endian little -speed 4000 -if swd
sleep 3
# - name: Verify network devices are available
# run: |
# . .venv/bin/activate
# bmlab-scan --network $VNET_BASE.0/$VNET_MASK | tee scan-network.txt
# f103_count=$(grep -c "Target:.*STM32F103RE" scan-network.txt || echo 0)
# if [ "$f103_count" -ne 3 ]; then
# echo "Expected 3 STM32F103RE devices, found $f103_count"
# cat scan-network.txt
# exit 1
# fi
# - name: Test 1 — Flash single device by IP
# run: |
# . .venv/bin/activate
# bmlab-flash .github/workflows/fw.bin --ip $VNET_BASE.100 --mcu STM32F103RE | tee flash1.txt
# if ! grep -q "Success" flash1.txt; then
# echo "Test 1 failed: flash not successful"
# cat flash1.txt
# exit 1
# fi
# - name: Test 2 — Flash two devices in parallel
# run: |
# . .venv/bin/activate
# bmlab-flash .github/workflows/fw.bin --ip $VNET_BASE.100 $VNET_BASE.101 --mcu STM32F103RE | tee flash2.txt
# success_count=$(grep -c "Success" flash2.txt || echo 0)
# if [ "$success_count" -ne 2 ]; then
# echo "Test 2 failed: expected 2 successful flashes, found $success_count"
# cat flash2.txt
# exit 1
# fi
# if ! grep -q "$VNET_BASE.100" flash2.txt; then
# echo "Test 2 failed: no result for $VNET_BASE.100"
# cat flash2.txt
# exit 1
# fi
# if ! grep -q "$VNET_BASE.101" flash2.txt; then
# echo "Test 2 failed: no result for $VNET_BASE.101"
# cat flash2.txt
# exit 1
# fi
- name: Test 3 — Flash three devices in parallel
run: |
. .venv/bin/activate
bmlab-flash .github/workflows/fw.bin --ip $VNET_BASE.100 $VNET_BASE.101 $VNET_BASE.102 --mcu STM32F103RE | tee flash3.txt
success_count=$(grep -c "Success" flash3.txt || echo 0)
if [ "$success_count" -ne 3 ]; then
echo "Test 3 failed: expected 3 successful flashes, found $success_count"
cat flash3.txt
exit 1
fi
for ip in 100 101 102; do
if ! grep -q "$VNET_BASE\.$ip" flash3.txt; then
echo "Test 3 failed: no result for $VNET_BASE.$ip"
cat flash3.txt
exit 1
fi
done
- name: Cleanup after tests
if: always()
run: |
docker rm -f jlink100 jlink101 jlink102 || true
docker network rm jlink-net || true
pkill -9 -f JLinkRemoteServer || true
sleep 2