"""Run Linux players briefly under WSL; this checks startup, not policy quality.""" import argparse import json import subprocess from pathlib import Path parser = argparse.ArgumentParser() parser.add_argument("--root", required=True, type=Path) parser.add_argument("--environments", default="Match3VectorObs,Basic,3DBall,PushBlockWithInput") parser.add_argument("--report-name", default="linux-startup.json") args = parser.parse_args() reports = args.root / "reports" reports.mkdir(exist_ok=True) results = {} for name in args.environments.split(","): if name not in ("Match3VectorObs", "Basic", "3DBall", "PushBlockWithInput"): raise ValueError(f"Unknown environment {name}") player = args.root / "builds" / "linux" / name / f"{name}.x86_64" player.chmod(player.stat().st_mode | 0o111) log = reports / f"{name}-linux-startup.log" process = subprocess.Popen([str(player), "-batchmode", "-nographics", "-logFile", str(log)], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) alive = False try: code = process.wait(timeout=10) raise RuntimeError(f"{name} exited unexpectedly with {code}") except subprocess.TimeoutExpired: alive = True finally: if process.poll() is None: process.terminate() try: process.wait(timeout=5) except subprocess.TimeoutExpired: process.kill() process.wait() text = log.read_text(errors="replace") initialized = "Initialize engine version: 6000.0.40f1" in text results[name] = {"alive_after_seconds": 10 if alive else 0, "engine_initialized": initialized, "passed": alive and initialized, "validation": "startup only; no policy connected"} print(json.dumps({name: results[name]}), flush=True) if not results[name]["passed"]: raise RuntimeError(f"{name} failed Linux startup; inspect {log}") (reports / args.report_name).write_text(json.dumps(results, indent=2) + "\n")