summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/fs.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/test/fs.py b/test/fs.py
index ba43c606..2782407d 100644
--- a/test/fs.py
+++ b/test/fs.py
@@ -6,6 +6,7 @@ import os
import shutil
import select
import signal
+import socket
from pathlib import Path
import subprocess
import struct
@@ -1413,13 +1414,25 @@ def test(binary, quic=False):
# Killed with SIGTERM or SIGHUP, a tty editor puts its terminal
# back (main screen, cooked mode) before it dies: a nested one
# killed in a pane leaves that pane usable.
+ # ...and its 9P socket goes with it. One a dead editor left behind
+ # (no process has its pid) is swept at the next start; a live
+ # pid's, here this test's own, never is.
+ def unix_socket_file(path):
+ made = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+ made.bind(str(path))
+ made.close()
for sig in (signal.SIGTERM, signal.SIGHUP):
+ dead_socket = root / 'pardes-9p-2147483647.sock'
+ live_socket = root / f'pardes-9p-{os.getpid()}.sock'
+ for path in (dead_socket, live_socket):
+ if not path.exists():
+ unix_socket_file(path)
master, slave = os.openpty()
fcntl.ioctl(slave, termios.TIOCSWINSZ, struct.pack('HHHH', 24, 80, 0, 0))
cooked = termios.tcgetattr(slave)
env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_')}
env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), TERM='xterm-256color', PARDES_NOTIME='1')
- killed = subprocess.Popen([binary, '--tty', '--9p=killed', 'x.txt'], cwd=root, env=env,
+ killed = subprocess.Popen([binary, '--tty', 'x.txt'], cwd=root, env=env,
stdin=slave, stdout=slave, stderr=subprocess.DEVNULL,
start_new_session=True,
preexec_fn=lambda: fcntl.ioctl(0, termios.TIOCSCTTY, 0))
@@ -1431,8 +1444,13 @@ def test(binary, quic=False):
if select.select([master], [], [], .1)[0]:
seen += os.read(master, 65536)
time.sleep(.3)
+ own_socket = root / f'pardes-9p-{killed.pid}.sock'
+ assert own_socket.exists()
+ assert not dead_socket.exists()
+ assert live_socket.exists()
killed.send_signal(sig)
assert killed.wait(timeout=5) == -sig
+ assert not own_socket.exists(), own_socket
while select.select([master], [], [], .2)[0]:
try:
chunk = os.read(master, 65536)