Skip to content

Commit 7fcd98a

Browse files
committed
add github workflow for cryoscope emulator + camerad loop
1 parent b71b1dc commit 7fcd98a

File tree

2 files changed

+121
-0
lines changed

2 files changed

+121
-0
lines changed
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Emulator integration tests
2+
3+
on:
4+
push:
5+
branches: [ "main", "mike/camera2-emulator" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
cryoscope-emulator-test:
11+
runs-on: ubuntu-latest
12+
timeout-minutes: 10
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
submodules: true
18+
19+
- name: Install dependencies
20+
run: |
21+
sudo apt-get update
22+
sudo apt-get install -y \
23+
libccfits-dev libcfitsio-dev libcurl4-openssl-dev \
24+
nlohmann-json3-dev libzmqpp-dev libzmq3-dev \
25+
libopencv-dev libboost-thread-dev libboost-chrono-dev
26+
27+
- name: Build camerad and emulator
28+
run: |
29+
mkdir build && cd build
30+
cmake .. -DINSTR=hispec_tracking_camera -DDETECTOR_TYPE=Hxrg
31+
make camerad emulator -j$(nproc)
32+
33+
- name: CryoScope synthetic test
34+
run: |
35+
bin/emulator Config/cryoscope/cryoscope.cfg -i generic &
36+
sleep 2
37+
bin/camerad --foreground --config Config/cryoscope/cryoscope.cfg &
38+
sleep 3
39+
40+
python3 << 'EOF'
41+
import socket, sys
42+
43+
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
44+
s.settimeout(120)
45+
s.connect(('localhost', 3031))
46+
47+
def cmd(c):
48+
s.sendall((c + '\n').encode())
49+
data = b''
50+
while True:
51+
try:
52+
chunk = s.recv(4096)
53+
if not chunk: break
54+
data += chunk
55+
if b'\n' in data: break
56+
except socket.timeout:
57+
break
58+
return data.decode().strip()
59+
60+
failed = False
61+
for c in ['open', 'load', 'power on', 'mode VIDEORXR', 'exptime 0.1',
62+
'exposuremode SINGLE', 'expose 1']:
63+
resp = cmd(c)
64+
status = 'OK' if 'DONE' in resp else 'FAIL'
65+
print(f' {status}: {c} -> {resp}')
66+
if status == 'FAIL':
67+
failed = True
68+
69+
s.close()
70+
sys.exit(1 if failed else 0)
71+
EOF
72+
73+
pkill -f 'bin/camerad' || true
74+
pkill -f 'bin/emulator' || true
75+
sleep 1
76+
77+
- name: CryoScope FITS playback test
78+
run: |
79+
cp Config/cryoscope/cryoscope.cfg /tmp/cryoscope_fits_test.cfg
80+
echo "EMULATOR_DATADIR=Config/cryoscope" >> /tmp/cryoscope_fits_test.cfg
81+
82+
bin/emulator /tmp/cryoscope_fits_test.cfg -i generic &
83+
sleep 2
84+
bin/camerad --foreground --config /tmp/cryoscope_fits_test.cfg &
85+
sleep 3
86+
87+
python3 << 'EOF'
88+
import socket, sys
89+
90+
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
91+
s.settimeout(120)
92+
s.connect(('localhost', 3031))
93+
94+
def cmd(c):
95+
s.sendall((c + '\n').encode())
96+
data = b''
97+
while True:
98+
try:
99+
chunk = s.recv(4096)
100+
if not chunk: break
101+
data += chunk
102+
if b'\n' in data: break
103+
except socket.timeout:
104+
break
105+
return data.decode().strip()
106+
107+
failed = False
108+
for c in ['open', 'load', 'power on', 'mode VIDEORXR', 'exptime 0.1',
109+
'exposuremode SINGLE', 'expose 1']:
110+
resp = cmd(c)
111+
status = 'OK' if 'DONE' in resp else 'FAIL'
112+
print(f' {status}: {c} -> {resp}')
113+
if status == 'FAIL':
114+
failed = True
115+
116+
s.close()
117+
sys.exit(1 if failed else 0)
118+
EOF
119+
120+
pkill -f 'bin/camerad' || true
121+
pkill -f 'bin/emulator' || true
2.46 MB
Binary file not shown.

0 commit comments

Comments
 (0)