diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/daemon.py | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/test/daemon.py b/test/daemon.py index c465b52f..16c40ea9 100644 --- a/test/daemon.py +++ b/test/daemon.py @@ -48,6 +48,9 @@ private HOME and runtime directory: python3 -B test/daemon.py --window-clients <pardes> <pardes-gui> window replica clients (hidden, offscreen) of a terminal's session, at 0/30/80/207 ms, and a window's session serving replicas + python3 -B test/daemon.py --client-motion <pardes> <pardes-gui> + a run of pointer motions over a client window is a few inputs, not + one each (also run by --window-clients) """ import fcntl import json @@ -2145,6 +2148,82 @@ def window_clients(binary, gui_binary): shutil.rmtree(root, ignore_errors=True) +def client_motion(binary, gui_binary): + """A run of pointer motions over a client window is one move to its last + position, as the session's own window takes it (gui.zig waitInput): not + an input each, which the session steps one by one and sends every other + client as a unit each, every one of them replayed and drawn again (the + user's "resizing feels very slow with several clients", 2026-11-24: a + 1000 Hz mouse is a thousand inputs a second). 300 motions written at + once to a window client's test feed: the inputs it sent the session + (its PARDES_REPLICA_STATS) are a pass's each, a few, not 300; a terminal + client watching takes as few units.""" + scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' + scratch.mkdir(parents=True, exist_ok=True) + root = Path(tempfile.mkdtemp(prefix='cm-', dir=os.environ.get('TMPDIR') or 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(300))) + started, terms = [], [] + w = None + try: + sess = subprocess.Popen([binary, '--detach=files', str(notes)], env=env, cwd=root, stdin=subprocess.DEVNULL, + stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, start_new_session=True) + started.append(sess.pid) + sock = root / 'pardes-replica.sock' + wait_for('the replica socket', sock.exists) + wait_for('the session\'s 9P socket', (root / 'pardes-9p-files.sock').exists) + nine = Client(root / 'pardes-9p-files.sock') + pane = next(int(row.split()[0]) for row in nine.read('/index').splitlines() if row.split()[1] == b'text') + tt = Term(24, 80) + terms.append(tt) + t = tt.spawn([binary, f'--attach={sock}:files'], dict(env, PARDES_REPLICA_STATS=str(root / 't.stats'))) + started.append(t.pid) + wait_for('the terminal client\'s first frame', lambda: b'line 3 of the notes' in tt.text(), timeout=30) + stats = root / 'w.stats' + w = Window(root, 'w', [gui_binary, f'--attach={sock}:files'], dict(env, PARDES_REPLICA_STATS=str(stats))) + started.append(w.pid) + w.keys(b'jj') + wait_for('the window\'s keys in the session', lambda: b'line' in nine.read(f'/pane/{pane}/body'), timeout=30) + time.sleep(2) + motions = 300 + w.p.stdin.write(b''.join(f'\x1b]777;mouse;motion;0;{200 + 3 * i};{300 + i % 40}\x07'.encode() for i in range(motions))) + w.p.stdin.flush() + time.sleep(3) + assert w.close() == 0, w.said()[-800:] + said = checks(stats)[-1].split() + sent = int(said[said.index('inputs') + 1]) + tt_units = None + t.send_signal(signal.SIGHUP) + t.wait(timeout=10) + tl = checks(root / 't.stats') + if tl: + words = tl[-1].split() + tt_units = int(words[words.index('units') + 1]) + print(f'daemon: {motions} motions over a client window: it sent the session {sent} inputs; ' + f'the terminal client took {tt_units} units') + assert sent <= 40, (f'{motions} pointer motions over a client window were {sent} inputs to its session, ' + 'each a unit for every client: not coalesced as the session\'s own window does') + exit_session(nine, pane) + sess.wait(timeout=60) + nine.socket.close() + finally: + for tm in terms: + tm.close() + if w and w.p.poll() is None: + w.p.kill() + for pid in started + processes(root): + try: + os.kill(pid, signal.SIGKILL) + except OSError: + pass + shutil.rmtree(root, ignore_errors=True) + + def joins(path): """A replica client's joins (PARDES_REPLICA_STATS, a line a link): how many blobs each listed, how many it held already from the core it left @@ -4212,6 +4291,9 @@ if __name__ == '__main__': elif sys.argv[1:2] == ['--window-clients']: window_clients(sys.argv[2], sys.argv[3]) pdf_window(sys.argv[2], sys.argv[3]) + client_motion(sys.argv[2], sys.argv[3]) + elif sys.argv[1:2] == ['--client-motion']: + client_motion(sys.argv[2], sys.argv[3]) elif sys.argv[1:2] == ['--ping']: ping(sys.argv[2], sys.argv[3], sys.argv[4], int(sys.argv[5]) if len(sys.argv) > 5 else 50) elif sys.argv[1:2] == ['--pair-gui']: |
