"""Check a real installed release RPM and exercise the GUI control channel.""" import json import os from pathlib import Path import secrets import socket import subprocess import time import tempfile def run_smoke(results): requirements = (results / "rpm-requires.txt").read_text() for capability in ( "libc.so.6()(64bit)", "libm.so.6(GLIBC_2.35)(64bit)", "libgcc_s.so.1()(64bit)", "libxkbcommon.so.0()(64bit)", "(libvulkan.so.1()(64bit) or libEGL.so.1()(64bit))", ): if capability not in requirements.splitlines(): raise RuntimeError(f"Missing RPM requirement: {capability}") version = subprocess.check_output(["vectorcraft-cli", "--version"], text=True) (results / "cli-version.txt").write_text(version) # Original fixture authored for this package smoke test; no external artwork. fixture = results / "original-smoke.svg" fixture.write_text('' '' '') token = secrets.token_hex(32) with tempfile.TemporaryDirectory(prefix="vectorcraft-runtime-") as runtime, (results / "gui.log").open("w") as log: env = dict(os.environ, VECTORCRAFT_NO_PREFS="1", XDG_RUNTIME_DIR=runtime, VECTORCRAFT_CONTROL_TOKEN=token) app = subprocess.Popen([ "vectorcraft", "--control", "32180", "--automation-read-root", str(results), "--automation-write-root", str(results), str(fixture), ], stdout=log, stderr=subprocess.STDOUT, env=env) try: deadline = time.monotonic() + 90 while True: if app.poll() is not None: raise RuntimeError(f"GUI exited during startup: {app.returncode}") try: channel = socket.create_connection(("127.0.0.1", 32180), timeout=5) break except OSError: if time.monotonic() >= deadline: raise RuntimeError("GUI control channel did not become ready") from None time.sleep(1) channel.settimeout(30) with channel, channel.makefile("rwb") as stream: for request_id, method, params in ( (0, "auth", {"token": token}), (1, "ui.inspect", {}), ): stream.write((json.dumps(dict(id=request_id, method=method, params=params)) + "\n").encode()) stream.flush() response = json.loads(stream.readline()) (results / f"{method}.json").write_text(json.dumps(response, indent=2)) if response.get("id") != request_id or response.get("ok") is not True: raise RuntimeError(f"GUI request failed: {method}") finally: app.terminate() try: app.wait(timeout=10) except subprocess.TimeoutExpired: app.kill() app.wait() if __name__ == "__main__": run_smoke(Path("/results"))