From f2b02c455f2bcdfb905a015eefbb630a28b4b12e Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 12 Nov 2026 10:56:42 -0300 Subject: addons: an addon can hand the frontend a GPU scene (ABI 3.1), and a snake drawn by shaders does; a commit's patch keeps its own +Diff pane; a real ZLS checked through the window build ABI 3.1 appends an optional `gpu` callback and its context to pa_paint: one self-contained sketchbook SGPU v1 scene for the pane, at most 4 MiB, copied during the call, the last successful call winning. The SDL frontend runs it on its own GPU through sketchbook's executor and composites its target texture into the pane; replicas carry the scene beside the authoritative pane frame; cells and rasters stay the fallback for terminals, older hosts and frontends without an executor. addons/snake_shader is such an addon (`zig build snake-shader`, the SnakeShader word: a board that follows its pane, buffered turns, a CRT look), with test/gpu_snake.py, test/gpu_snake_interaction.py and test/gpu_upgrade.py. Commit patches open as `+Diff-` and reuse only their own commit's pane, so another paged patch no longer replaces one already open. The language-server client looks in the standard per-user bin directory, which desktop launchers often leave out of PATH, and takes an empty answer that beats the startup progress notification onto the wire; test/real_zls.py checks imports, hover, references, rename previews, diagnostics and completion against a real ZLS from a private home. The dump's schema reader skips two fields older builds persisted, and a replica's shadow of a kind ticks when the authority's does. The reference, the guide, the building and setup notes and the changelog say so. The working copy as it stood on 2026-11-12; message written by Claude from the diff, at the author's request. --- test/gpu_upgrade.py | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 test/gpu_upgrade.py (limited to 'test/gpu_upgrade.py') diff --git a/test/gpu_upgrade.py b/test/gpu_upgrade.py new file mode 100644 index 00000000..bb07e29b --- /dev/null +++ b/test/gpu_upgrade.py @@ -0,0 +1,109 @@ +#!/usr/bin/env python3 +"""Check upgrade, reload, multiple GPU panes and a remote view in isolation.""" +import os +import time +import subprocess +from pathlib import Path +from ninep import Client +from gpu_snake import wait +from daemon import install, processes +import argparse +parser = argparse.ArgumentParser(description='Upgrade, addon reload and GPU replica checks in an isolated session') +for name in ['old', 'new', 'legacy', 'shader', 'output']: + parser.add_argument(name, type=Path) +args = parser.parse_args() +root = args.output.resolve() +root.mkdir(parents=True, exist_ok=True, mode=0o700) +root.chmod(0o700) +print(root, flush=True) +(root / 'config/pardes').mkdir(parents=True) +(root / 'bin').mkdir() +(root / 'config/pardes/init').write_text('Shell /bin/bash\nMessageLinger 0\n') +binary = root / 'bin/pardes-gui' +install(args.old.resolve(), binary) +env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_')} +env.pop('XDG_DATA_HOME', None) +env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), PARDES_TEST='1', PARDES_TEST_CAPTURE_DIR=str(root), SDL_VIDEO_DRIVER='offscreen', PARDES_DAEMON='on') +log = (root / 'stderr.log').open('w') +p = subprocess.Popen([str(binary), '--9p=upgrade'], env=env, cwd=root, stdin=subprocess.PIPE, stdout=subprocess.DEVNULL, stderr=log, start_new_session=True) +c = None +replica = None +try: + sock = root / '9p/pardes/upgrade' + wait(sock.exists) + c = Client(sock) + print('started', p.pid, flush=True) + initial = c.read('/index').decode() + shell = int(next((l.split()[0] for l in initial.splitlines() if l.split()[1] == 'term'))) + term_before = wait(lambda: [l for l in c.read('/sessions').splitlines() if l.startswith(b'shell ')]) + print('shells', term_before, flush=True) + text = int(c.read('/pane/new')) + c.write(f'/pane/{text}/body', b'unsaved text preserved\n') + c.write(f'/pane/{text}/exec', ('Addon load ' + str(args.legacy.resolve()) + '\n').encode()) + c.write(f'/pane/{text}/exec', b'Snake\n') + c.write('/focus', str(text).encode()) + time.sleep(0.1) + snake = int(next((l.split()[0] for l in c.read('/index').decode().splitlines() if l.split()[1] == 'snake'))) + state = c.read(f'/pane/{snake}/body') + install(args.new.resolve(), binary) + mark = time.time() + c.write(f'/pane/{text}/exec', b'Upgrade\n') + c.socket.close() + c = None + + def connect(): + try: + q = Client(sock) + if q.read(f'/pane/{text}/body') == b'unsaved text preserved\n': + return q + q.socket.close() + except (OSError, EOFError): + return None + wait(lambda: os.stat(f'/proc/{p.pid}/exe').st_ino == binary.stat().st_ino, 30) + c = wait(connect, 30) + wait(lambda: (root / 'latest.ppm').stat().st_mtime > mark, 30) + assert c.read('/status').startswith(f'pid {p.pid}\n'.encode()) + assert [l for l in c.read('/sessions').splitlines() if l.startswith(b'shell ')] == term_before + c.write(f'/pane/{text}/exec', ('Addon load ' + str(args.legacy.resolve()) + '\n').encode()) + assert c.read(f'/pane/{snake}/body') == state + c.write(f'/pane/{text}/exec', ('Addon load ' + str(args.shader.resolve()) + '\n').encode()) + c.write(f'/pane/{text}/exec', b'SnakeShader\n') + c.write('/focus', str(text).encode()) + time.sleep(0.1) + shader = int(next((l.split()[0] for l in c.read('/index').decode().splitlines() if l.split()[1] == 'snake_shader'))) + state = c.read(f'/pane/{shader}/body') + c.write(f'/pane/{text}/exec', b'Addon reload snake_shader\n') + assert c.read(f'/pane/{shader}/body') == state + resized = time.time() + c.write(f'/pane/{text}/exec', b'Newcol\n') + c.write(f'/pane/{text}/exec', b'SnakeShader\n') + c.write('/focus', str(text).encode()) + assert sum(line.split()[1] == b'snake_shader' for line in c.read('/index').splitlines()) == 2 + wait(lambda: (root / 'latest.ppm').stat().st_mtime > resized) + c.remove(f'/pane/{shader}') + caps = root / 'replica' + caps.mkdir() + renv = dict(env, PARDES_TEST_CAPTURE_DIR=str(caps)) + rlog = (root / 'replica.log').open('w') + replica = subprocess.Popen([str(binary), '--attach=upgrade'], env=renv, cwd=root, stdin=subprocess.PIPE, stdout=subprocess.DEVNULL, stderr=rlog, start_new_session=True) + wait(lambda: (caps / 'latest.ppm').exists(), 20) + time.sleep(0.4) + from PIL import Image + im = Image.open(caps / 'latest.ppm').convert('RGB') + green = sum((g > 65 and g > r * 1.7 and (g > b * 1.2) for r, g, b in im.get_flattened_data())) + assert green > 300, green + print('PASS: same pid, shell, unsaved text and snake state; shader reload/resize/close; replica GPU pixels', green, flush=True) + (root / 'result.txt').write_text('PASS: upgrade preserves pid, shell, text and snake; shader reload/resize/close; replica GPU pixels=' + str(green) + '\n') +finally: + if c: + c.socket.close() + for child in [replica, p]: + if child and child.poll() is None: + child.kill() + child.wait(timeout=10) + for pid in processes(root): + try: + os.kill(pid, 9) + except ProcessLookupError: + pass + log.close() -- cgit v1.3