From 9e6d248fbea88d87cb5f1db9f06a7bbff02daaad Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Thu, 15 Oct 2026 01:03:40 +0200 Subject: [PATCH] test_friends: --xvfb and --offscreen for headless Linux machines Co-Authored-By: Claude Opus 5.5 --- tools/test_friends.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/test_friends.py b/tools/test_friends.py index 086516a72..04399fe0f 100644 --- a/tools/test_friends.py +++ b/tools/test_friends.py @@ -78,15 +78,19 @@ def health(relay_url): class Game: """A Horizon client with a control socket in its own home.""" + # Extra words before and after the client (`--xvfb`, `--offscreen`). + prefix = [] + extra = [] + def __init__(self, client, resources, work, name, env): self.home = work / name self.home.mkdir() self.endpoint = self.home / 'c.sock' self.log = (self.home / 'client.log').open('w+') - self.process = subprocess.Popen([ + self.process = subprocess.Popen(Game.prefix + [ str(client), '--resources', str(resources), '--render-distance', '2', '--test-terrain', '--control-socket', str(self.endpoint), '--timeout-seconds', '600', - ], cwd=self.home, env=dict(os.environ, HORIZON_HOME=str(self.home), HORIZON_NO_AUDIO='1', **env), + ] + Game.extra, cwd=self.home, env=dict(os.environ, HORIZON_HOME=str(self.home), HORIZON_NO_AUDIO='1', **env), stdout=self.log, stderr=subprocess.STDOUT) wait_for(self.endpoint, 'screen', lambda v: v['screen'] == 'title', 120, f'{name} title') @@ -333,7 +337,11 @@ def main(): parser.add_argument('--wait', type=float, default=600) parser.add_argument('--hold', type=float, default=0, help='guest: stay this many seconds before leaving') parser.add_argument('--baseline', action='store_true', help='first run the same checks over plain LAN') + parser.add_argument('--offscreen', action='store_true', help='run the games without a window') + parser.add_argument('--xvfb', action='store_true', help='run the games under xvfb-run (headless Linux)') args = parser.parse_args() + Game.prefix = ['xvfb-run', '-a'] if args.xvfb else [] + Game.extra = ['--offscreen'] if args.offscreen else [] args.client, args.resources = args.client.resolve(), args.resources.resolve() # Short: Unix socket paths are limited to about 100 bytes. with tempfile.TemporaryDirectory(prefix='hzf-', dir='/tmp') as directory: