summaryrefslogtreecommitdiff
path: root/test/daemon.py
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-21 09:35:20 -0300
committerGabriel Schneider <[email protected]>2026-11-21 10:58:24 -0300
commit59ba1a8b24aab95cfec9046e042f3a34d5821e47 (patch)
tree4c002443d1e2a168b87f395be406043eb49a6aa0 /test/daemon.py
parent0ad6da7f9bf22136694e6015c93ccaf81dc12380 (diff)
downloadpardes-59ba1a8b24aab95cfec9046e042f3a34d5821e47.tar.gz
pardes-59ba1a8b24aab95cfec9046e042f3a34d5821e47.zip
test/daemon.py: an adopted shell's `echo $$` is asked once the shell answers (`adopted_pid`, the wait plain mode's own Adopt had): on a ReleaseSafe build of pardes-merge50 `--relink` failed 3 of 10 (`relink` twice, `answer_late` once), each run answered `error not run`, not another pid: the adoption sizes the shell twice (dev/Ptys.zig `take`), it draws its prompt again, and a run sent into a prompt redrawn under it reads as not run (core/ninep/pty.zig `noteMarks`, its ponytail), which a faster build reaches more often; the same wait in `relink`, `answer_late`, `upgrades`' last Adopt and plain mode's; no product change: no output in another pane, a script's run told plainly that it did not run; after: `--relink` on this line's ReleaseSafe build 10 of 10 (loads 1.3-7.0)
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'test/daemon.py')
-rw-r--r--test/daemon.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/test/daemon.py b/test/daemon.py
index 1be89d5b..fc03e3cb 100644
--- a/test/daemon.py
+++ b/test/daemon.py
@@ -143,6 +143,16 @@ def run(client, serial, line):
client.close(fid)
+def adopted_pid(client, pane):
+ """An adopted shell's `echo $$`, once it answers: sized twice at its
+ adoption (dev/Ptys.zig `take`), it draws its prompt again, and a run
+ sent into a prompt redrawn under it reads as not run (core/ninep/pty.zig
+ `noteMarks`)."""
+ wait_for('the adopted shell answers', lambda: run(client, pane, b'true\n') == b'exit 0\n')
+ said = run(client, pane, b'echo $$\n')
+ return said.split(b'\n')[1], said
+
+
# FreeBSD has no /proc: ps and procstat answer instead.
procfs = os.path.isdir('/proc/self')
@@ -1528,7 +1538,8 @@ def relink(binary):
before = set(terminals(own))
own.write(f'/pane/{min(before)}/exec', b'Adopt\n')
pane = wait_for('the adopted pane', lambda: set(terminals(own)) - before).pop()
- assert run(own, pane, b'echo $$\n').split(b'\n')[1] == str(shell_pid).encode()
+ pid, said = adopted_pid(own, pane)
+ assert pid == str(shell_pid).encode(), (said, shell_pid)
print(f'relink: a client attached to the session through the new daemon; killed outright, its shell {shell_pid} was adopted')
exit_session(own, pane)
stub.wait(timeout=10)
@@ -1602,7 +1613,8 @@ def answer_late(binary):
two.write(f'/pane/{min(before)}/exec', b'Adopt\n')
took = time.monotonic() - asked
pane = wait_for('the adopted pane', lambda: set(terminals(two)) - before).pop()
- assert run(two, pane, b'echo $$\n').split(b'\n')[1] == str(shell_pid).encode()
+ pid, said = adopted_pid(two, pane)
+ assert pid == str(shell_pid).encode(), (said, shell_pid)
print(f'answer late: an Adopt asked while the daemon was stopped waited {took:.1f} s for its answer, '
f'and shell {shell_pid} was adopted')
exit_session(two, pane)
@@ -2772,11 +2784,8 @@ def main(binary, cycles):
client.write(f'/pane/{min(before)}/exec', b'Adopt\n')
adopted = wait_for('the adopted pane', lambda: set(terminals(client)) - before)
pane = adopted.pop()
- # Sized twice (Ptys.take): a run into a prompt redrawn under it
- # reads as not run (core/ninep/pty.zig).
- wait_for('the adopted shell answers', lambda: run(client, pane, b'true\n') == b'exit 0\n')
- said = run(client, pane, b'echo $$\n')
- assert said.split(b'\n')[1] == str(shell_pid).encode(), said
+ pid, said = adopted_pid(client, pane)
+ assert pid == str(shell_pid).encode(), said
print(f'daemon: shell {shell_pid} outlived kill -9 of its session and was adopted')
# Attached again: a client. (After the runs: a pty/run under a
# client puts it off the session's state, and it joins again; one
@@ -3342,7 +3351,8 @@ def upgrades(old, new):
before = set(terminals(client))
client.write(f'/pane/{min(before)}/exec', b'Adopt\n')
pane = wait_for('the adopted pane', lambda: set(terminals(client)) - before).pop()
- assert run(client, pane, b'echo $$\n').split(b'\n')[1] == str(shell_pid).encode()
+ pid, said = adopted_pid(client, pane)
+ assert pid == str(shell_pid).encode(), (said, shell_pid)
print(f'upgrade: the upgraded daemon kept shell {shell_pid} through kill -9 of its session, and it was adopted')
client.write(f'/pane/{pane}/exec', b'Exit\n')
stub.wait(timeout=10)