-
Notifications
You must be signed in to change notification settings - Fork 1
117 lines (101 loc) · 4.48 KB
/
test.yml
File metadata and controls
117 lines (101 loc) · 4.48 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
name: Test Builds
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
env:
VNET_BASE: 192.168.2
VNET_MASK: 24
jobs:
test-build:
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
- name: Build release distributions
run: |
python3 -m venv .venv
. .venv/bin/activate
pip install -e ".[dev]"
- name: Test 1 — bmlab-scan (no arguments)
run: |
. .venv/bin/activate
bmlab-scan | tee scan1.txt
count=$(grep -c "Target: *STM32F103RE" scan1.txt)
awk '/JLink Programmer/ {serial=""} /Serial:/ {serial=$2} /Target: *STM32F103RE/ && serial {print serial}' scan1.txt | sort | uniq > serials.txt
if [ "$count" -eq 3 ]; then
echo "Test 1 passed"
else
echo "Test 1 failed: found $count STM32F103RE"; cat scan1.txt; exit 1
fi
- name: Test 2 — bmlab-scan -p jlink
run: |
. .venv/bin/activate
bmlab-scan -p jlink | tee scan2.txt
diff scan1.txt scan2.txt
if [ $? -ne 0 ]; then
echo "Test 2 failed: output differs from Test 1"
exit 1
else
echo "Test 2 passed"
fi
- name: Test 3 — Start JLinkRemoteServer and scan via network
run: |
. .venv/bin/activate
serial=$(head -n1 serials.txt)
echo "Using serial: $serial"
nohup JLinkRemoteServer -select usb=$serial -device STM32F103RE -endian little -speed 4000 -if swd > remote_server.log 2>&1 &
sleep 3
bmlab-scan --network 127.0.0.1/32 | tee scan3.txt
cat remote_server.log
grep -q "Target: *STM32F103RE" scan3.txt
grep -q "IP: *127.0.0.1" scan3.txt
if [ $? -ne 0 ]; then
cat scan3.txt
fi
- name: Test 4 — bmlab-scan --network 127.0.0.1/32 -p jlink
run: |
. .venv/bin/activate
nohup JLinkRemoteServer -select usb=$serial -device STM32F103RE -endian little -speed 4000 -if swd > remote_server.log 2>&1 &
sleep 3
bmlab-scan --network 127.0.0.1/32 -p jlink | tee scan4.txt
diff scan3.txt scan4.txt
- name: Test 5 — bmlab-scan --network 127.0.0.2/32 (negative)
run: |
. .venv/bin/activate
! bmlab-scan --network 127.0.0.2/32 | tee scan5.txt | grep -q "STM32F103RE"
grep -qi "No JLink Remote Servers found on the network." scan5.txt
- name: Build JLinkRemoteServer Docker image
run: |
docker build -t my-jlink-image -f .github/workflows/jlinkRemoteServerEmu.dockerfile .
- name: Setup JLinkRemoteServer Docker containers for Tests 6-7
run: |
docker network inspect jlink-net >/dev/null 2>&1 || \
docker network create --subnet=$VNET_BASE.0/$VNET_MASK jlink-net
for ip in 100 101 102; do
docker run -d --rm --name jlink$ip --network jlink-net --ip $VNET_BASE.$ip \
my-jlink-image \
-select usb=SERIAL$ip -device STM32F103RE -endian little -speed 4000 -if swd
done
- name: Test 6 — Multiple RemoteServers, bmlab-scan --network $VNET_BASE.0/$VNET_MASK
run: |
. .venv/bin/activate
serial1=$(sed -n '1p' serials.txt)
serial2=$(sed -n '2p' serials.txt)
serial3=$(sed -n '3p' serials.txt)
nohup JLinkRemoteServer -select usb=$serial1 -device STM32F103RE -endian little -speed 4000 -if swd > remote_server_100.log 2>&1 &
nohup JLinkRemoteServer -select usb=$serial2 -device STM32F103RE -endian little -speed 4000 -if swd > remote_server_101.log 2>&1 &
nohup JLinkRemoteServer -select usb=$serial3 -device STM32F103RE -endian little -speed 4000 -if swd > remote_server_102.log 2>&1 &
sleep 5
# It is assumed that RemoteServers are already running on .100, .101, .102
bmlab-scan --network $VNET_BASE.0/$VNET_MASK | tee scan6.txt
for ip in 100 101 102; do
grep -q "$VNET_BASE.$ip" scan6.txt || (echo "No result for .$ip"; exit 1)
done
- name: Test 7 — bmlab-scan --network $VNET_BASE.0/$VNET_MASK --start-ip 100 --end-ip 150
run: |
. .venv/bin/activate
bmlab-scan --network $VNET_BASE.0/$VNET_MASK --start-ip 100 --end-ip 150 | tee scan7.txt
for ip in 100 101 102; do
grep -q "$VNET_BASE.$ip" scan7.txt || (echo "No result for .$ip"; exit 1)
done