mirror of
https://github.com/D-Modem/courier-emu.git
synced 2026-11-28 20:38:07 -08:00
624 tests across 51 files, 5-12 minutes, and this session showed what that
was worth: the 403 datapump carried a zero transmit level through every one
of them, and what found it was ATGLK2=0000:0C00 on the board. A green suite
here says the harness still does what it did, not that it matches the
hardware.
So the rule for what stays is: a test earns its place by pinning a fact
established against hardware or against a file format, cheaply, where a
refactor could break it silently. Fourteen files, thirty test functions,
32 collected - test_ac01_codec and test_dsp_board_ndx each run one of theirs
over both board images. 4.4 seconds.
formats xmf identity, sector checksum, Microwire round-trip and
write-enable, the 302 records and the 403 block offset,
flash program/erase 10
constants the instruction/timer-tick round trip, the timer gate,
AC01 reset registers and both B-register rate paths,
ASIC port decode 7
measured DSP the NDX/ARCR board probes and PA7, mailbox tag/data on
58-5e, the 1c commit bit, host cells not data memory,
the datapump family table 7
end to end the ROM reset stub, the C52 payload, the supervisor's
download through the bridge, 302 to its service loop,
fixture forwarding 5
board tools flash_dump address coverage and target selection,
ram_dump's opt-in and peripheral-window guard 3
What went is everything asserting main211/XMF behaviour - there is no 211
hardware, so those expectations are inferences that can never be settled -
along with the multi-second full-boot runs, the probe and sampler files, and
the ISDN/NAC/XMP and SV25 recovery tests, which cover machines this work is
not about. All of it is in the history if a specific one is wanted back.
Two things fixed in passing. README pointed at tests/test_nac.py as the
assertion behind the NAC/XMP cross-check; it now says to re-check that with
nac-info. And `make test` ran `unittest discover`, which never saw
pytest-style module-level tests - 369 of the old 624, and it would have seen
17 of these 30 - so it runs pytest now.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
98 lines
2.7 KiB
Python
98 lines
2.7 KiB
Python
import json
|
|
|
|
import pytest
|
|
import courier_emu.flash_dump as fd
|
|
|
|
from courier_emu import flash_dump as dump
|
|
|
|
|
|
def response(address, data, terminal="ERROR"):
|
|
command = dump.command_for(address)
|
|
segment = (address & 0xF0000) >> 4
|
|
offset = address & 0xFFFF
|
|
lines = [command.lower()] + [
|
|
f" {segment:04X}:{offset+i:04X} {data[i:i+16].hex(' ').upper()}"
|
|
for i in range(0, 256, 16)
|
|
] + [terminal]
|
|
return ("\r\n".join(lines) + "\r\n").encode()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_address_sequence_covers_flash_without_offset_wrap():
|
|
commands = [dump.command_for(a) for a in range(0x80000, 0x100000, 256)]
|
|
assert len(set(commands)) == 2048
|
|
assert commands[0] == "ATGLK2=8000:0000"
|
|
assert commands[255:257] == ["ATGLK2=8000:FF00", "ATGLK2=9000:0000"]
|
|
assert commands[-1] == "ATGLK2=F000:FF00"
|
|
for address in (0xFF00, 0x7FF00, 0x100000, 0x80001):
|
|
with pytest.raises(ValueError):
|
|
dump.command_for(address)
|
|
|
|
|
|
class FakePort:
|
|
device = "test-port"
|
|
baud = 115200
|
|
|
|
def __init__(self, unstable=False):
|
|
self.commands = []
|
|
self.unstable = unstable
|
|
first, reset = dump.TARGETS[("7.3.14", "3.0.13")]
|
|
self.pages = {
|
|
0x80000: first + bytes(256 - len(first)),
|
|
0x80100: bytes(240) + reset,
|
|
}
|
|
|
|
def drain(self):
|
|
return b""
|
|
|
|
def query(self, command):
|
|
self.commands.append(command)
|
|
if command == "AT":
|
|
return b"AT\r\nOK\r\n"
|
|
if command == "ATI7":
|
|
return b"Courier\r\nClock Freq 20.16Mhz\r\nFlash ROM 512k\r\nSupervisor rev 7.3.14\r\nDSP rev 3.0.13\r\nOK\r\n"
|
|
segment, offset = (int(v, 16) for v in command.split("=")[1].split(":"))
|
|
address = segment * 16 + offset
|
|
data = self.pages[address]
|
|
if self.unstable and self.commands.count(command) % 2 == 0:
|
|
data = data[:128] + bytes([data[128] ^ 1]) + data[129:]
|
|
return response(address, data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_known_firmware_targets_are_selected_by_revision():
|
|
stock = (b"Courier\r\nClock Freq 20.16Mhz\r\nFlash ROM 512k\r\n"
|
|
b"Supervisor rev 7.3.14\r\nDSP rev 3.0.13\r\nOK\r\n")
|
|
idsdl = (b"Courier\r\nClock Freq 20.16Mhz\r\nFlash ROM 512k\r\n"
|
|
b"Supervisor rev 7.4.16\r\nDSP rev 3.1.2\r\nOK\r\n")
|
|
assert dump.validate_identity(stock)[1] == ("7.3.14", "3.0.13")
|
|
assert dump.validate_identity(idsdl)[1] == ("7.4.16", "3.1.2")
|
|
# The two builds end with different reset vectors, so the anchor check
|
|
# cannot pass for a board running firmware it was not selected for.
|
|
assert dump.TARGETS[("7.3.14", "3.0.13")] != dump.TARGETS[("7.4.16", "3.1.2")]
|
|
|
|
|
|
|
|
|
|
|
|
# The tick probe's commands, and everything it must never send.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|