Skip to content

Commit db56c88

Browse files
committed
Enhance CI workflow with comprehensive tests for JLink STM32F103RE devices
1 parent b51b6b4 commit db56c88

File tree

1 file changed

+68
-13
lines changed

1 file changed

+68
-13
lines changed

.github/workflows/test.yml

Lines changed: 68 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,73 @@ jobs:
1616
- name: Build release distributions
1717
run: |
1818
python3 -m venv .venv
19-
source .venv/bin/activate
19+
. .venv/bin/activate
2020
pip install -e ".[dev]"
21-
22-
- name: Check for three JLink STM32F103RE devices
23-
run: |
24-
source .venv/bin/activate
25-
bmlab-scan --log-level DEBUG | tee scan_output.txt
26-
count=$(grep -c "Target: *STM32F103RE" scan_output.txt)
27-
if [ "$count" -eq 3 ]; then
28-
echo "Found exactly three JLink STM32F103RE devices."
21+
22+
- name: Test 1 — bmlab-scan (no arguments)
23+
run: |
24+
. .venv/bin/activate
25+
bmlab-scan | tee scan1.txt
26+
count=$(grep -c "Target: *STM32F103RE" scan1.txt)
27+
serials=$(grep -A2 "Target: *STM32F103RE" scan1.txt | grep -oE 'Serial: *[0-9]+' | awk '{print $2}' | sort | uniq | wc -l)
28+
if [ "$count" -eq 3 ] && [ "$serials" -eq 3 ]; then
29+
echo "Test 1 passed"
2930
else
30-
echo "Error: Found $count JLink STM32F103RE devices, expected 3."
31-
cat scan_output.txt
32-
exit 1
33-
fi
31+
echo "Test 1 failed: found $count STM32F103RE, $serials unique serials"; cat scan1.txt; exit 1
32+
fi
33+
34+
- name: Test 2 — bmlab-scan -p jlink
35+
run: |
36+
. .venv/bin/activate
37+
bmlab-scan -p jlink | tee scan2.txt
38+
diff scan1.txt scan2.txt
39+
40+
- name: Test 3 — Start JLinkRemoteServer and scan via network
41+
run: |
42+
. .venv/bin/activate
43+
nohup JLinkRemoteServer -select usb=771850347 -device STM32F103RE -endian little -speed 4000 -if swd > remote_server.log 2>&1 &
44+
sleep 3
45+
bmlab-scan --network 127.0.0.1/32 | tee scan3.txt
46+
grep -q "Target: *STM32F103RE" scan3.txt
47+
grep -q "Serial: *771850347" scan3.txt
48+
49+
- name: Test 4 — bmlab-scan --network 127.0.0.1/32 -p jlink
50+
run: |
51+
. .venv/bin/activate
52+
bmlab-scan --network 127.0.0.1/32 -p jlink | tee scan4.txt
53+
diff scan3.txt scan4.txt
54+
55+
- name: Test 5 — bmlab-scan --network 127.0.0.2/32 (negative)
56+
run: |
57+
. .venv/bin/activate
58+
! bmlab-scan --network 127.0.0.2/32 | tee scan5.txt | grep -q "STM32F103RE"
59+
grep -qi "no devices found" scan5.txt
60+
61+
- name: Setup virtual network for Tests 6-7
62+
run: |
63+
sudo ip addr add 192.168.2.100/24 dev lo
64+
sudo ip addr add 192.168.2.101/24 dev lo
65+
sudo ip addr add 192.168.2.102/24 dev lo
66+
67+
nohup JLinkRemoteServer -select usb=771851115 -device STM32F103RE -endian little -speed 4000 -if swd -ip 192.168.2.100 > remote_server_100.log 2>&1 &
68+
nohup JLinkRemoteServer -select usb=772440188 -device STM32F103RE -endian little -speed 4000 -if swd -ip 192.168.2.101 > remote_server_101.log 2>&1 &
69+
nohup JLinkRemoteServer -select usb=771851371 -device STM32F103RE -endian little -speed 4000 -if swd -ip 192.168.2.102 > remote_server_102.log 2>&1 &
70+
71+
sleep 5
72+
73+
- name: Test 6 — Multiple RemoteServers, bmlab-scan --network 192.168.2.0/24
74+
run: |
75+
. .venv/bin/activate
76+
# Предполагается, что RemoteServers уже запущены на .100, .101, .102
77+
bmlab-scan --network 192.168.2.0/24 | tee scan6.txt
78+
for ip in 100 101 102; do
79+
grep -q "192.168.2.$ip" scan6.txt || (echo "No result for .$ip"; exit 1)
80+
done
81+
82+
- name: Test 7 — bmlab-scan --network 192.168.2.0/24 --start-ip 100 --end-ip 150
83+
run: |
84+
. .venv/bin/activate
85+
bmlab-scan --network 192.168.2.0/24 --start-ip 100 --end-ip 150 | tee scan7.txt
86+
for ip in 100 101 102; do
87+
grep -q "192.168.2.$ip" scan7.txt || (echo "No result for .$ip"; exit 1)
88+
done

0 commit comments

Comments
 (0)