Cancel the message in flight, and the small things from the review
rb9704_cancel() and `rb9704 cancel` ask the modem to abandon the MO in flight; the modem's final status reaches mo_done as -ECANCELED. The library's async path has no timeout, so this is how an application frees a modem that has gone quiet mid-send. The status snapshot carries the in-flight message's id and start time for the application to decide with. rb9704_begin zeroes moQueuedMessages: rbBegin empties the queue but not the count, and a count above zero makes every later send queue without transmitting. The fake modem's mo-hold and mo-release stand in for a modem that has taken a message and said nothing more; a test drives cancel through it. Also: the shell's send buffer is a shell line, not a fourth message buffer; the bridge's TX-disable race has a comment; the CLI turns a Cloudloop error (a bad token's 200 reply included), an unopenable port and a one-word jspr line into one line and exit 1; conftest reads request.node; pyproject uses the current license spelling.
This commit is contained in:
1 parent
509b9b5b6d
commit
f97fcab74b
13 files changed
+235
-34
No files matched your search
@@ -203,7 +203,7 @@ def zephyr(request):
|
||||
cfg = request.config
|
||||
if request.param == "none":
|
||||
pytest.skip("no Zephyr target: --zephyr-exe or --board-console")
|
||||
topics = getattr(request, "node").get_closest_marker("topics")
|
||||
topics = request.node.get_closest_marker("topics")
|
||||
topics = topics.args[0] if topics else "244"
|
||||
if request.param == "board" and not cfg.getoption("--board-modem"):
|
||||
pytest.skip("--board-console needs --board-modem")
|
||||
|
||||
@@ -85,6 +85,33 @@ def test_mo_with_a_bad_crc():
|
||||
assert any(e.startswith("MOBAD 244") for e in w.events)
|
||||
|
||||
|
||||
def mo_whole(w, payload):
|
||||
whole = with_crc(payload)
|
||||
w.put('PUT messageOriginate {"topic_id":244, "message_length":%d, "request_reference":1}'
|
||||
% len(whole))
|
||||
mid = w.lines()[0][2]["message_id"]
|
||||
w.put('PUT messageOriginateSegment {"topic_id":244, "message_id":%d, "segment_length":%d,'
|
||||
' "segment_start":0, "data":"%s"}' % (mid, len(whole), base64.b64encode(whole).decode()))
|
||||
return mid
|
||||
|
||||
|
||||
def test_held_mo_is_released_or_cancelled():
|
||||
w = Wire()
|
||||
w.m.control("mo-hold")
|
||||
mid = mo_whole(w, b"held")
|
||||
assert [t for _, t, _ in w.lines()] == ["messageOriginateSegment"] # no status yet
|
||||
w.put('PUT messageOriginateStatus {"topic_id":244, "message_id":%d, "action":"cancel"}' % mid)
|
||||
got = w.lines()
|
||||
assert got[-1][1:] == ("messageOriginateStatus", {"topic_id": 244, "message_id": mid,
|
||||
"final_mo_status":
|
||||
"message_cancelled_in_transit"})
|
||||
w.m.control("mo-hold")
|
||||
mid = mo_whole(w, b"held-again")
|
||||
w.lines()
|
||||
w.m.control("mo-release")
|
||||
assert w.lines()[-1][2]["final_mo_status"] == "mo_ack_received"
|
||||
|
||||
|
||||
def test_unprovisioned_topic_is_refused():
|
||||
w = Wire(topics=())
|
||||
w.put('PUT messageOriginate {"topic_id":244, "message_length":7, "request_reference":1}')
|
||||
|
||||
@@ -78,6 +78,30 @@ def test_send_refused_by_the_modem(zephyr):
|
||||
c.out.expect(r"send: -\d+ EIO")
|
||||
|
||||
|
||||
def test_cancel_a_send_the_modem_sits_on(zephyr):
|
||||
"""The modem took the message and said nothing more, as one waiting for
|
||||
a satellite does; cancel frees the module, and a send then goes."""
|
||||
c, f = zephyr
|
||||
begin(zephyr)
|
||||
f.cmd("mo-hold")
|
||||
c.sh("rb9704 send 244 stuck")
|
||||
c.out.expect(r"send: ok")
|
||||
m = f.out.expect(r"^MO 244 (\d+) ")
|
||||
c.sh("rb9704 info")
|
||||
c.out.expect(r"info: -\d+ EBUSY")
|
||||
c.sh("rb9704 status")
|
||||
c.out.expect(r"one in flight: topic 244 id %s" % m.group(1))
|
||||
c.sh("rb9704 cancel")
|
||||
c.out.expect(r"cancel: ok")
|
||||
c.out.expect(r"mo done topic 244 id %s result -\d+" % m.group(1))
|
||||
c.sh("rb9704 cancel")
|
||||
c.out.expect(r"cancel: -\d+ ENOENT")
|
||||
c.sh("rb9704 send 244 after-cancel")
|
||||
c.out.expect(r"send: ok")
|
||||
f.out.expect(r"^MO 244 \d+ ")
|
||||
c.out.expect(r"result 0")
|
||||
|
||||
|
||||
def test_topic_below_64_is_refused_here(zephyr):
|
||||
c, f = zephyr
|
||||
begin(zephyr)
|
||||
|
||||
Reference in new issue
Block a user