summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-20 14:52:50 -0300
committerGabriel Schneider <[email protected]>2026-11-20 17:38:54 -0300
commitaa05797120cef3cd883ce053d56ba00fe866c009 (patch)
tree59db38cd8c02fc162bbc92f1411e7853512765a0 /test
parent1f731da28bd9983cc414839bd32372d183438164 (diff)
downloadpardes-aa05797120cef3cd883ce053d56ba00fe866c009.tar.gz
pardes-aa05797120cef3cd883ce053d56ba00fe866c009.zip
pair: a hang-up is a close (P36): a terminal client (`runClient`) blocks HUP and TERM before its join makes a thread and winchWatch takes both as `quit`, which in a client now sets the goodbye's close (as a window's close button does, and as SDL already makes a window client's TERM), so its terminal closed, its ssh dropped under it or a TERM says goodbye with the close, puts the terminal back and exits 0, and the session, a pair's not kept (daemon.State `pair`), ends when that was its last client; with other clients or kept it runs on, and a client killed outright stays a loss (no goodbye: it runs on, listed); without PARDES_PAIR the close is read by no session, so the own path's terminal closed still detaches its session, the one change a user sees there being a `pardes attach` client's TERM: a goodbye and exit 0 where it died of the signal; and a client exec'd at an Upgrade (runtime/client.zig `execAgain`) clears its signal mask first, since the mask crosses an exec and a build that sigwaits no TERM would never take one (found by `--upgrade` new->old with clients: the exec'd terminal client ignored the test's TERM for 20 s; with the clear both ways pass); test/daemon.py `pair_rows` gains 2.2 B's not-kept column (a client's terminal closed, not the last: runs on; the pair's own client killed -9: runs on, listed `(tty)`; the last client TERMed: exit 0, its terminal put back, the session ended; a pair upgraded, its terminal closed: ended) and the own path's rows (an attach client TERMed: the session on; its terminal closed: `(tty, detached)`); on the change before, `--pair` fails at the TERMed client's status (-15); here: tui core-test 861/1016 (155 skipped), shell-test 1058/1061, term 17/17, pane 183/184, kitty 45/45, behaviour-test and --replay 275/275, process-test 0 of 144 failed, soak --clients 5 diverged 0, unequal 0, checked/wrong 1874/0 1937/0, quiet checks 597/0 673/0 779/0, unlisted 0, corpus 22 of 22, no leak, --bytes --clients 5 the same (quiet checks 693/0 586/0 802/0), daemon.py plain (launch, pair, pair_rows), --far, --relink, --manage, --window-clients, --gui (gui_pair) pass, an idle terminal pair wakes 0 and 0 times in 2 s, gui unit-test 1654/1658 with only BaselineHarnessMismatch, --games, --upgrade with clients both ways against the base built with -Dembed-sources=true (another semantics) pass, nothing left behind by any mode (load 4-18)
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'test')
-rw-r--r--test/daemon.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/daemon.py b/test/daemon.py
index ce2ffbf1..aef37d0a 100644
--- a/test/daemon.py
+++ b/test/daemon.py
@@ -770,6 +770,48 @@ def pair_rows(binary):
assert subprocess.run([binary, 'kill', 'kd'], env=env, capture_output=True, timeout=30).returncode == 0
wait_for('kd ended', lambda: not alive(kd), timeout=30)
print('pair rows: `new --detach` kept from birth (ps: (tty, kept)); its client ended by HUP, by TERM: it runs on')
+ # Not kept: a client's close (its terminal closed, a TERM) ends the
+ # session when it was the last; a KILL is a loss, it runs on.
+ t, c, nine, session, pane = started('nk', env)
+ assert ended_by('HUP', *attached('nk')) == 0
+ assert alive(session) and state_of('nk') == '(tty)', ('not its last client', listed())
+ os.kill(c.pid, signal.SIGKILL)
+ c.wait(timeout=10)
+ wait_for('the client unlisted', lambda: f'client {c.pid} ' not in listed())
+ assert alive(session) and state_of('nk') == '(tty)', ('a loss', listed())
+ assert ended_by('TERM', *attached('nk')) == 0
+ wait_for('the session ended at its last client\'s close', lambda: not alive(session), timeout=20)
+ assert state_of('nk') is None, listed()
+ nine.socket.close()
+ print('pair rows: not kept: a client\'s terminal closed (not the last): it runs on; its own killed -9: it runs on, '
+ 'listed; the last client TERMed (exit 0, its terminal put back): the session ended')
+ # The pair's own terminal closed after an Upgrade: its last client's
+ # close, which the Upgrade did not make kept.
+ t, c, nine, session, pane = started('nk2', env)
+ nine = upgraded('nk2', nine, session)
+ wait_for('the client joined again', lambda: b'joined again' in t.text(), timeout=30)
+ nine.socket.close()
+ t.close()
+ terms.remove(t)
+ assert c.wait(timeout=20) == 0, c.returncode
+ wait_for('the session ended with its terminal', lambda: not alive(session), timeout=20)
+ print('pair rows: not kept, upgraded: its terminal closed (exit 0): the session ended')
+ # Without the variable nothing changes: an attach client's TERM
+ # leaves the session running, and its own terminal closed detaches it.
+ own_env = {k: v for k, v in env.items() if k != 'PARDES_PAIR'}
+ t, c, nine, session, pane = started('own', own_env)
+ assert state_of('own') == '(tty, has a frontend)', listed()
+ assert ended_by('TERM', *attached('own')) == 0
+ assert alive(session) and state_of('own') == '(tty, has a frontend)', listed()
+ nine.socket.close()
+ t.close()
+ terms.remove(t)
+ c.wait(timeout=20)
+ wait_for('the own session detached', lambda: state_of('own') == '(tty, detached)')
+ assert alive(session)
+ assert subprocess.run([binary, 'kill', 'own'], env=env, capture_output=True, timeout=30).returncode == 0
+ wait_for('the own session ended', lambda: not alive(session), timeout=30)
+ print('pair rows: without the variable: an attach client TERMed, the session on; its terminal closed, it detached (ps: (tty, detached))')
# A pair: not kept, and not across an Upgrade either; a Detach typed
# in its client keeps it, across an Upgrade too.
t, c, nine, session, pane = started('rows', env)