|
STAR
Cal STAR — firmware, DAQ server, and engine design
|
Classes | |
| class | FakeBoard |
| class | Results |
Functions | |
| str | find_ota_service () |
| int | pick_free_port () |
| bool | wait_until_listening (int port, float deadline) |
| str | send_command (int port, str line) |
| tuple[str, bytes] | make_firmware (str tmpdir, str name, int size) |
| None | run_flash (int port, str ip, str path, str behavior, Results r, str label, bool expect_ok, bytes|None verify_bytes) |
| int | main () |
Variables | |
| int | OTA_BOARD_PORT = 3232 |
| str | BOARD_IP = "127.0.0.1" |
| float | CONNECT_WAIT_S = 5.0 |
| float | REPLY_WAIT_S = 20.0 |
Fake-board test for the C++ ota_service (diablo_server/services/ota).
No hardware. Exercises the exact ethernet-flash wire format that a real ESP32-S3
board depends on, against a loopback TCP "fake board" that speaks the espota
handshake:
1. board accepts TCP on 127.0.0.1:3232 (OTA_PORT — a compile-time constant)
2. board reads a 4-byte BIG-ENDIAN firmware size
3. board reads exactly that many firmware bytes (ota_service sends in 4 KB chunks)
4. board replies "OK\\n" (or reboots without replying — also success)
The test launches the real ota_service binary, connects to its command port
(TCP, default 9997) and issues `OTA_FLASH:<ip>:<path>`, then asserts on both the
bytes the fake board received and the OK/ERR reply the service returns.
Covers: big-endian size header, multi-chunk streaming byte-fidelity, "OK"
detection, silent-reboot-is-success, board-error -> ERR, and the command
parser's error paths (missing file, connect refused, bad format, unknown cmd).
Run: python3 test/test_ota_flash.py (from daq-server/)
Binary is auto-discovered at build/bin/ota_service; override with OTA_SERVICE_BIN.
| str test_ota_flash.find_ota_service | ( | ) |
Definition at line 46 of file test_ota_flash.py.
Referenced by main().
| int test_ota_flash.main | ( | ) |
Definition at line 247 of file test_ota_flash.py.
References find_ota_service(), main(), make_firmware(), pick_free_port(), run_flash(), send_command(), time.time(), and wait_until_listening().
Referenced by main().
| tuple[str, bytes] test_ota_flash.make_firmware | ( | str | tmpdir, |
| str | name, | ||
| int | size ) |
Definition at line 206 of file test_ota_flash.py.
Referenced by main().
| int test_ota_flash.pick_free_port | ( | ) |
Definition at line 72 of file test_ota_flash.py.
Referenced by main().
| None test_ota_flash.run_flash | ( | int | port, |
| str | ip, | ||
| str | path, | ||
| str | behavior, | ||
| Results | r, | ||
| str | label, | ||
| bool | expect_ok, | ||
| bytes | None | verify_bytes ) |
Start a fake board, issue OTA_FLASH, and assert reply + received bytes.
Definition at line 215 of file test_ota_flash.py.
References send_command().
Referenced by main().
| str test_ota_flash.send_command | ( | int | port, |
| str | line ) |
Send one command line to ota_service; return its trimmed reply.
Definition at line 166 of file test_ota_flash.py.
Referenced by main(), and run_flash().
| bool test_ota_flash.wait_until_listening | ( | int | port, |
| float | deadline ) |
| str test_ota_flash.BOARD_IP = "127.0.0.1" |
Definition at line 38 of file test_ota_flash.py.
| float test_ota_flash.CONNECT_WAIT_S = 5.0 |
Definition at line 39 of file test_ota_flash.py.
| int test_ota_flash.OTA_BOARD_PORT = 3232 |
Definition at line 37 of file test_ota_flash.py.
| float test_ota_flash.REPLY_WAIT_S = 20.0 |
Definition at line 40 of file test_ota_flash.py.