diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/daemon.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/test/daemon.py b/test/daemon.py index 7f1adfdb..34c4c7a6 100644 --- a/test/daemon.py +++ b/test/daemon.py @@ -2870,6 +2870,46 @@ def cpu_ticks(pid): return int(stat[11]) + int(stat[12]) +def killed_session(binary): + """A terminal's session killed outright (KILL, as the OOM killer does): + the job its terminal waits on ends with it, and says nothing of its own + (no trace): the own path's stub dead of the same signal, as a job is + (daemon.zig `stubWait`, which aborted re-raising a KILL); a pair's + client let go of its session, 1.""" + scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' + scratch.mkdir(parents=True, exist_ok=True) + root = Path(tempfile.mkdtemp(prefix='rk-', dir=scratch)) + env = base_env() + env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), + TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1') + (root / 'config' / 'pardes').mkdir(parents=True) + (root / 'config' / 'pardes' / 'init').write_text('Shell bash\nMessageLinger 0\n') + notes = root / 'notes.txt' + notes.write_text(''.join(f'line {i} of the notes\n' for i in range(30))) + t = Term(30, 100) + try: + c = t.spawn([binary, '--9p=k', str(notes)], env) + sock = root / 'pardes-9p-k.sock' + wait_for('the socket', sock.exists) + with Client(sock) as nine: + session = int(dict(line.split(maxsplit=1) for line in nine.read('/status').decode().splitlines())['pid']) + wait_for('drawn', lambda: b'line 3 of the notes' in t.text(), timeout=30) + os.kill(session, signal.SIGKILL) + code = c.wait(timeout=30) + said = t.last() + assert b'panic' not in said and b'unreachable' not in said, said[-1500:] + assert code == (1 if WITH_PAIR else -signal.SIGKILL), (code, said[-600:]) + print(f'killed session: its terminal\'s job ended {code} with it, no trace') + finally: + for p in processes(root): + try: + os.kill(p, signal.SIGKILL) + except OSError: + pass + t.close() + shutil.rmtree(root, ignore_errors=True) + + def kitty_image(binary, secs=5): """A plain attach watching a terminal in which a program shows a kitty image (the corpus's scene 10's: 8x8 RGB, 10x4 cells): it @@ -4132,3 +4172,4 @@ if __name__ == '__main__': gui_pair(args[0]) else: main(sys.argv[1], int(sys.argv[2]) if len(sys.argv) > 2 else 50) + killed_session(sys.argv[1]) |
