summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/daemon.py28
1 files changed, 26 insertions, 2 deletions
diff --git a/test/daemon.py b/test/daemon.py
index f4f46286..9e9ea600 100644
--- a/test/daemon.py
+++ b/test/daemon.py
@@ -217,15 +217,39 @@ def main(binary, cycles):
time.sleep(.3)
assert alive(shell_pid), 'a killed session\'s shell is not hung up'
assert alive(daemon)
+ # Started from a shell, which leads the terminal's session and
+ # outlives the stub, as a terminal's shell does (on FreeBSD the
+ # leader's exit revokes the terminal for every process).
term = Term()
- stub = term.spawn([binary, '--tty', '--9p=fresh'], env)
- started.append(stub.pid)
+ stub_pid = root / 'stub.pid'
+ shell = term.spawn(['sh', '-c', '"$@" & echo $! > "$0"; wait; exec sleep 600',
+ str(stub_pid), binary, '--tty', '--9p=fresh'], env)
+ started.append(shell.pid)
sock = root / 'pardes-9p-fresh.sock'
wait_for('the second session', sock.exists)
+ stub = int(stub_pid.read_text())
+ started.append(stub)
client = Client(sock)
status = dict(line.split(maxsplit=1) for line in client.read('/status').decode().splitlines())
session = int(status['pid'])
started.append(session)
+ # Its stub killed outright, the terminal left open: the session
+ # (the stub's child) takes that as the terminal's end and detaches.
+ wait_for('the second session\'s first frame', lambda: b'\x1b[?1049h' in term.text())
+ drawn = len(term.text())
+ os.kill(stub, signal.SIGKILL)
+ wait_for('the stub gone', lambda: not alive(stub))
+ wait_for('the session detached from its killed stub', lambda: sized(client))
+ assert b'\x1b[?1049l' in term.text()[drawn:], 'the terminal is put back'
+ assert alive(session)
+ shell.kill()
+ shell.wait(timeout=10)
+ term.close()
+ term = Term()
+ stub = term.spawn([binary, '--attach=fresh'], env)
+ wait_for('the attached terminal\'s first frame', lambda: b'\x1b[?1049h' in term.text())
+ wait_for('the session sized to its new terminal', lambda: not sized(client))
+ print('daemon: a session whose stub was killed outright detached, and was attached again')
before = set(terminals(client))
client.write(f'/pane/{min(before)}/exec', b'Adopt\n')
adopted = wait_for('the adopted pane', lambda: set(terminals(client)) - before)