upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/scripts/run_wine_tests.py
diff options
context:
space:
mode:
authorVonsek <45567075+Vonsek@users.noreply.github.com>2026-11-22 15:51:40 +0100
committerVonsek <45567075+Vonsek@users.noreply.github.com>2026-11-22 15:51:40 +0100
commitdf91c6624b69ee4e6c6eeca20ed68d331ed0e728 (patch)
tree323c88b9df89bf8abaa2b98d10808474ab675dc2 /scripts/run_wine_tests.py
parentb40d8039a98f57b26bd05860febbabbe59b97873 (diff)
parent6a6704df1592e1dc4a3215ddf1423a78adb52045 (diff)
Merge main into test/valu-int-misc (#1492)
Conflicted files: runtime/test/shaders/check.py, scripts/run_gpu_tests.py AI-assisted.
Diffstat (limited to 'scripts/run_wine_tests.py')
-rw-r--r--scripts/run_wine_tests.py70
1 files changed, 62 insertions, 8 deletions
diff --git a/scripts/run_wine_tests.py b/scripts/run_wine_tests.py
index b2736982f..b55ea9b91 100644
--- a/scripts/run_wine_tests.py
+++ b/scripts/run_wine_tests.py
@@ -8,6 +8,10 @@ Usage:
8made in (forward slashes, as `cygpath -m` prints it). Paths under it are mapped to --root, the Linux checkout (default: 8made in (forward slashes, as `cygpath -m` prints it). Paths under it are mapped to --root, the Linux checkout (default:
9this repository), which must hold the Windows build's runtime/build folder at the same place. 9this repository), which must hold the Windows build's runtime/build folder at the same place.
10 10
11Some tests open files through absolute paths compiled into them (the GLSL test shaders, LEONIDA_TEST_*_SPV under
12runtime/build/generated). For those, the drive of --windows-root is pointed at --root in the Wine prefix for the run
13($WINEPREFIX, else ~/.wine), unless that drive is already in use there.
14
11Every test is run and reported. The exit code is 1 if a test named by --require fails or is missing, else 0: the 15Every test is run and reported. The exit code is 1 if a test named by --require fails or is missing, else 0: the
12others show what does and doesn't work under Wine yet without failing the job. 16others show what does and doesn't work under Wine yet without failing the job.
13""" 17"""
@@ -17,8 +21,10 @@ import math
17import os 21import os
18import re 22import re
19import shlex 23import shlex
24import shutil
20import subprocess 25import subprocess
21import sys 26import sys
27import tempfile
22import time 28import time
23 29
24ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 30ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@@ -46,6 +52,51 @@ def map_path(arg: str, windows_root: str, root: str) -> str | None:
46 return None 52 return None
47 53
48 54
55class DriveMap:
56 """Points the drive of the Windows checkout at the Linux one inside the Wine prefix, for the run.
57
58 A test that opens D:/a/Leonida/Leonida/runtime/build/generated/x.spv (a path compiled into it) then reads
59 <root>/runtime/build/generated/x.spv. The drive is a dosdevices link to a scratch folder holding a/Leonida/Leonida
60 as a link to the root; both are removed afterwards. A drive the prefix already has (c:, z:, or one set up by
61 hand) is left alone, and so is a root without a drive letter.
62 """
63
64 def __init__(self, windows_root: str, root: str, prefix: str):
65 self.windows_root, self.root, self.prefix = norm(windows_root), os.path.abspath(root), prefix
66 self.link = self.scratch = None
67 self.note = ""
68
69 def __enter__(self):
70 m = re.fullmatch(r"([A-Za-z]):/(.+)", self.windows_root)
71 if not m:
72 self.note = f"{self.windows_root} has no drive letter: no drive mapped"
73 return self
74 drive, rest = m.group(1).lower(), [p for p in m.group(2).split("/") if p]
75 dosdevices = os.path.join(self.prefix, "dosdevices")
76 link = os.path.join(dosdevices, drive + ":")
77 if not os.path.isdir(dosdevices):
78 self.note = f"no Wine prefix at {self.prefix}: drive {drive}: not mapped"
79 return self
80 if os.path.lexists(link):
81 self.note = f"drive {drive}: is already set in {dosdevices}: left as it is"
82 return self
83 self.scratch = tempfile.mkdtemp(prefix="wine-drive-")
84 parent = os.path.join(self.scratch, *rest[:-1])
85 os.makedirs(parent, exist_ok=True)
86 os.symlink(self.root, os.path.join(parent, rest[-1]))
87 os.symlink(self.scratch, link)
88 self.link = link
89 self.note = f"drive {drive}: maps {self.windows_root} to {self.root} for this run"
90 return self
91
92 def __exit__(self, *exc):
93 if self.link and os.path.islink(self.link):
94 os.unlink(self.link)
95 if self.scratch:
96 shutil.rmtree(self.scratch, ignore_errors=True) # removes the links, never what they point to
97 return False
98
99
49def wine_path(path: str) -> str: 100def wine_path(path: str) -> str:
50 """Wine's Z: drive is the Unix root, so a Windows program reads /x/y as Z:\\x\\y.""" 101 """Wine's Z: drive is the Unix root, so a Windows program reads /x/y as Z:\\x\\y."""
51 return "Z:" + os.path.abspath(path).replace("/", "\\") 102 return "Z:" + os.path.abspath(path).replace("/", "\\")
@@ -175,14 +226,17 @@ def main() -> int:
175 return 2 226 return 2
176 wine = args.wine 227 wine = args.wine
177 results = {} 228 results = {}
178 for test in tests: 229 prefix = os.environ.get("WINEPREFIX") or os.path.join(os.path.expanduser("~"), ".wine")
179 name = test.get("name", "?") 230 with DriveMap(args.windows_root, args.root, prefix) as drive:
180 status, detail = run_test(test, args, wine) 231 print(drive.note, flush=True)
181 results[name] = status 232 for test in tests:
182 print(f"[{status.upper()}] {name}", flush=True) 233 name = test.get("name", "?")
183 if status != "pass": 234 status, detail = run_test(test, args, wine)
184 for line in detail.rstrip().splitlines()[-40:]: 235 results[name] = status
185 print(f" {line}") 236 print(f"[{status.upper()}] {name}", flush=True)
237 if status != "pass":
238 for line in detail.rstrip().splitlines()[-40:]:
239 print(f" {line}")
186 240
187 missing = [n for n in args.require if n not in results] 241 missing = [n for n in args.require if n not in results]
188 failed_required = [n for n in args.require if results.get(n) != "pass"] 242 failed_required = [n for n in args.require if results.get(n) != "pass"]