summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-20 10:37:44 -0300
committerGabriel Schneider <[email protected]>2026-11-20 12:02:09 -0300
commit1d92d0151bf8206823074f73b9fa90e0220bff15 (patch)
treede2c2450bb36f036d6dff6e41e22ba659b6dca65 /test
parent6cf477bd75d242c7f7fea653d5f433872f7ca66f (diff)
downloadpardes-1d92d0151bf8206823074f73b9fa90e0220bff15.tar.gz
pardes-1d92d0151bf8206823074f73b9fa90e0220bff15.zip
tape: enter and leave read the field, step 9b (reports/pardes-handle-69-design.md sections 3.3, 3.4): an entry is recorded on the tape of the core it enters (for a session not made yet, its options' or, until 9c, the global's), unless nobody records it or it is a client's between its steps (the idle rule 9b-0 checked), and Entered carries the tape it entered, so leave needs neither the global nor a core that init did not make or deinit freed; the safe build still checks that a core stepped is the one the global says while the global is set; as 9b-0's list said, a client's core freed records nothing now, and an authority's core driven outside a Stepping scope records its entries as a real session's: one test leaned on that being unrecorded (test/panes.zig, a client's guessed PDF view: the effects its `jobs` drained after the open landed in the client's next unit and read as a misprediction; the drain is handed to the client as a unit of the session's own first, 2 lines); test/daemon.py --restore (new): a Restore with a client attached, the client let go, one attached after agrees and its keys reach the restored session (passes on step 7 and here); the tape's bytes do not move (semantics df1f0502317ed362, cross_replay both ways against step 7: 27 digests agree x3); tui core-test 857/1008 (151 skipped), shell-test 1048/1051, pane-test 183/184, term-test 17/17, kitty-test 45/45, behaviour-test 275/275 and --replay 275/275, process-test --replay 0 of 102, process-test 1 of 144 (pagercolor, on the known list), both soaks diverged 0 unequal 0 corpus 22 of 22 (bytes: the base's one now stop at 30 ms), daemon.py plain, --far (the Find: 0 mispredicted), --games, --window-clients, --upgrade both ways against merge31, addon-test 5/5; gui unit-test 1645/1649 (the perf check's BaselineHarnessMismatch); frames 77/77, perfab +0.051%, the 121 counts within 0.1% against tree2 (key-down on medium 10,039,587, render on medium 11,454,498: the extra load an entry is inside the noise)
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'test')
-rw-r--r--test/daemon.py66
-rw-r--r--test/panes.zig4
2 files changed, 70 insertions, 0 deletions
diff --git a/test/daemon.py b/test/daemon.py
index 887e6d0d..52c7d1e6 100644
--- a/test/daemon.py
+++ b/test/daemon.py
@@ -1493,6 +1493,70 @@ def far_find(binary):
shutil.rmtree(root, ignore_errors=True)
+def restore_client(binary):
+ """A Restore while a client is attached: the client is let go (its link
+ ends), the replacement core is the session's (its tape adopts it, its
+ options keep none), and a client attached after agrees with it, its
+ keys reaching it."""
+ scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn'
+ scratch.mkdir(parents=True, exist_ok=True)
+ root = Path(tempfile.mkdtemp(prefix='rr-', dir=scratch))
+ env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k}
+ env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), XDG_DATA_HOME=str(root / 'data'),
+ 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 = [], []
+ try:
+ sess = subprocess.Popen([binary, '--detach=back', str(notes)], env=env, cwd=root, stdin=subprocess.DEVNULL,
+ stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, start_new_session=True)
+ started.append(sess.pid)
+ wait_for('the replica socket', (root / 'pardes-replica.sock').exists)
+ wait_for('the session\'s 9P socket', (root / 'pardes-9p-back.sock').exists)
+ nine = Client(root / 'pardes-9p-back.sock')
+ text = next(int(row.split()[0]) for row in nine.read('/index').splitlines() if row.split()[1] == b'text')
+ def client(name):
+ t = Term(30, 100)
+ terms.append(t)
+ c = t.spawn([binary, f'--attach={root / "pardes-replica.sock"}:back'],
+ dict(env, PARDES_REPLICA_CHECK=str(root / f'{name}.check')))
+ started.append(c.pid)
+ wait_for(f'client {name}\'s first frame', lambda: b'line 3 of the notes' in t.text(), timeout=30)
+ time.sleep(.3)
+ return t, c
+ t, c = client('a')
+ nine.write(f'/pane/{text}/exec', b'Dump\n')
+ nine.write(f'/pane/{text}/exec', b'Restore\n')
+ wait_for('client a let go at the Restore', lambda: c.poll() is not None, timeout=30)
+ # The 9P link was the old core's.
+ nine.socket.close()
+ nine = reconnect(root / 'pardes-9p-back.sock')
+ text = next(int(row.split()[0]) for row in nine.read('/index').splitlines() if row.split()[1] == b'text')
+ t, c = client('r')
+ os.write(t.master, b'Oafter the restore\x1b')
+ texts = lambda: b''.join(nine.read(f'/pane/{row.split()[0].decode()}/body') for row in nine.read('/index').splitlines()
+ if row.split()[1] == b'text')
+ wait_for('the client\'s keys in the restored session', lambda: b'after the restore' in texts(), timeout=30)
+ seen = len(checks(root / 'r.check'))
+ wait_for('the client agrees once quiet', lambda: agreed(root / 'r.check', seen), timeout=60)
+ assert c.poll() is None, 'the client ended'
+ print(f'daemon: a Restore with a client attached: it was let go, and one attached after agreed ({len(checks(root / "r.check"))} checks), its keys in the restored session')
+ exit_session(nine, text)
+ sess.wait(timeout=60)
+ nine.socket.close()
+ finally:
+ for term in terms:
+ term.close()
+ for pid in started + processes(root):
+ try:
+ os.kill(pid, signal.SIGKILL)
+ except OSError:
+ pass
+ shutil.rmtree(root, ignore_errors=True)
+
+
def far_joins(sock, session, binary, n):
"""`n` far joins of one session in a row, each read whole (its blobs
asked for by none, its zstd frames unpacked) and answering a ping, then
@@ -2309,6 +2373,8 @@ if __name__ == '__main__':
far_find(sys.argv[2])
elif sys.argv[1:2] == ['--far-find']:
far_find(sys.argv[2])
+ elif sys.argv[1:2] == ['--restore']:
+ restore_client(sys.argv[2])
elif sys.argv[1:2] == ['--window-clients']:
window_clients(sys.argv[2], sys.argv[3])
pdf_window(sys.argv[2], sys.argv[3])
diff --git a/test/panes.zig b/test/panes.zig
index dbdbec2f..f4061590 100644
--- a/test/panes.zig
+++ b/test/panes.zig
@@ -3961,6 +3961,10 @@ const PdfAddon = struct {
}
};
const id = try opened(a, Land{ .a = a, .r = r });
+ // The effects `jobs` took last are the session's steps: a unit of
+ // its own before the client's input.
+ a.seq += 1;
+ r.confirm(try a.unit(0, a.seq));
const guessed = r.stats.mispredicted;
const stopped = r.stats.stopped;
const told = a.core.panes[id].?.addon.?.views;