rbtest: timed small messages, one 50 kB message, and MT checks

`rbtest` in the shell sample sends test messages with a 16-byte header
and a counting ramp, so every byte can be checked at the other end.
`rbtest small` sends a few 32-byte messages and logs how long each took,
`rbtest large` sends one of up to 50000 bytes and only with `confirm`,
and `rbtest mt` shows the last MT and checks it. `rb9704 pattern make`
and `check` in python/ make and check the same messages.

rb9704_send_fill writes a message straight into the module's buffer, so
a large generated one is not held twice. overlay-large.conf raises the
limit to 50000 bytes; on the M5Stamp-C3 that links on the USB console
and not beside WiFi, which overflows by 11 kB.

Run against the fake modem on native_sim only; not yet on a real modem.
This commit is contained in:
scottp committed 2026-10-27 11:07:53 +11:00
1 parent 9f68104ac6
commit 144efe683e
15 files changed
+798 -6

No files matched your search

+29
View File
@@ -2,11 +2,14 @@
# Copyright (c) 2026 Scott Penrose <scottp@dd.com.au>
"""The rb9704 command line against the fake modem."""
import base64
import subprocess
import sys
import pytest
from rb9704tools import pattern
def run(*args, timeout=30):
return subprocess.run([sys.executable, "-m", "rb9704tools.cli", *args], capture_output=True,
@@ -46,3 +49,29 @@ def test_send_with_yes(fake):
assert r.returncode == 0, r.stdout + r.stderr
m = fake.out.expect(r"^MO 244 \d+ (\w+)")
assert bytes.fromhex(m.group(1)) == b"cli-hello"
def test_pattern_make_and_check():
r = run("pattern", "make", "--size", "1000", "--seq", "2", "--count", "3")
assert r.returncode == 0, r.stderr
hexed = r.stdout.strip()
data = bytes.fromhex(hexed)
assert len(data) == 1000 and data[:4] == b"RBT\x01"
# the ramp turns at 255 and comes back down
assert data[255] == 255 and data[256] == 254 and data[510] == 0
r = run("pattern", "check", "--hex", hexed)
assert r.returncode == 0, r.stdout + r.stderr
assert "M 2/3, 1000 bytes" in r.stdout and "every byte as expected" in r.stdout
b64 = base64.b64encode(data).decode().rstrip("=")
assert run("pattern", "check", "--b64", b64).returncode == 0
def test_pattern_check_finds_the_damage():
data = bytearray(pattern.make(100))
data[40] ^= 1
r = run("pattern", "check", "--hex", data.hex())
assert r.returncode != 0 and "byte 40" in r.stdout + r.stderr
r = run("pattern", "check", "--hex", pattern.make(100)[:90].hex())
assert r.returncode != 0 and "says 100 bytes, 90 arrived" in r.stdout + r.stderr
r = run("pattern", "check", "--hex", b"hello".hex())
assert r.returncode != 0 and "not a test message" in r.stdout + r.stderr