From 6584181f5c2125ee0ab7d4c43ee613258d1ccc0f Mon Sep 17 00:00:00 2001 From: Markus Fritsche Date: Wed, 22 Jul 2026 23:55:44 +0200 Subject: [PATCH] tests: add large-payload and nonexistent-command tests (2 red) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds tests that expose the pipe-buffer deadlock: - 65,792 bytes (64 KiB + 1) hangs instead of completing - 1 MiB body hangs - Nonexistent command exits nonzero 15 passed, 2 failed (expected — deadlock not yet fixed) --- tests/test_sicd_protocol.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/test_sicd_protocol.py b/tests/test_sicd_protocol.py index 25ab1f4..55c3af8 100644 --- a/tests/test_sicd_protocol.py +++ b/tests/test_sicd_protocol.py @@ -140,3 +140,28 @@ def test_empty_payload_command_gets_immediate_eof(): r = run_sicd(frame(b"cat", b"")) assert r.returncode == 0, f"expected exit 0, got {r.returncode}, stderr={r.stderr!r}" assert r.stdout == b"" + +def test_large_payload_64k_plus_1_no_deadlock(): + """Payload+trailing exceeding the 64 KiB pipe buffer must not deadlock. + The child reads from stdin, so the parent must pump through a pipe + after fork — not pre-write the entire blob into a pipe and block.""" + body = bytes(range(256)) * 257 # 65,792 bytes > 65,536 pipe buffer + r = run_sicd(frame(b"cat", b"") + body) + assert r.returncode == 0, f"expected exit 0, got {r.returncode}, stderr={r.stderr!r}" + assert len(r.stdout) == len(body), f"expected {len(body)} bytes, got {len(r.stdout)}" + + +def test_multi_mib_payload_no_deadlock(): + """1 MiB body after an empty-payload frame must stream through without + hanging or truncating — pins the streaming pump loop, not just the + pipe-buffer edge.""" + body = bytes(range(256)) * 4096 # 1 MiB + r = run_sicd(frame(b"cat", b"") + body) + assert r.returncode == 0, f"expected exit 0, got {r.returncode}, stderr={r.stderr!r}" + assert r.stdout == body + + +def test_nonexistent_command_exits_nonzero(): + """Exec of a command that does not exist must not hang or exit 0.""" + r = run_sicd(frame(b"__nonexistent_command_42__", b"")) + assert r.returncode != 0, f"expected non-zero exit, got {r.returncode}"