upleb.uk

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

summaryrefslogtreecommitdiff
path: root/scripts/run_gpu_tests.py
diff options
context:
space:
mode:
authorShrey Ratna <shreyratna4445@hotmail.com>2026-11-23 01:57:30 +0530
committerShrey Ratna <shreyratna4445@hotmail.com>2026-11-23 01:57:30 +0530
commit6e083c17d92bb9912e3b79c74b920bc9dc071581 (patch)
tree626085077c3215d8ddd721ed81d56831872408f1 /scripts/run_gpu_tests.py
parentf847748cc76bd3777f9c070c4034eb2fc1c04e64 (diff)
rdna2spirv, run_gpu_tests: folders outside the ANSI code page reach the native tools
On Windows, spirv-as, spirv-val and the GPU test programs read their command line in the ANSI code page, so a folder name with a character outside it (a Cyrillic or CJK user name, as under %TEMP%) reached them as '?' and every shader failed with "file does not exist": run_gpu_tests.py's default work folder broke for such users, and so did make_game.py's shaders stage under such a work folder. - assemble_spirv pipes the .spvasm into `spirv-as -` and runs both tools in the output folder with the staging file's bare name, so no path reaches them. - run_gpu_tests.py runs the suite in the work folder's 8.3 short name when its path doesn't fit the code page, and stops with one error line when the volume keeps no short names. - tests/test_native_tool_paths.py: 8 tests with a private-use character in the folder name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'scripts/run_gpu_tests.py')
-rw-r--r--scripts/run_gpu_tests.py34
1 files changed, 33 insertions, 1 deletions
diff --git a/scripts/run_gpu_tests.py b/scripts/run_gpu_tests.py
index 7cd0e9dbf..cb7a9e545 100644
--- a/scripts/run_gpu_tests.py
+++ b/scripts/run_gpu_tests.py
@@ -614,6 +614,31 @@ def find_test_programs(build: str, ext: str) -> str | None:
614 return None 614 return None
615 615
616 616
617def native_folder(path: str, ansi: str = "mbcs") -> str | None:
618 """`path` spelled so that the native programs this runner starts can open files under it, or None.
619
620 On Windows the test programs and the Vulkan SDK tools (spirv-val, spirv-as) read their command line in the ANSI
621 code page, so a character outside it, as in a Cyrillic or CJK user name under %TEMP%, reaches them as '?'. Such a
622 folder is replaced by its 8.3 short name, which is plain ASCII, when the volume keeps one. Elsewhere, and for a
623 path the code page holds, `path` comes back as it is. `ansi` is the codec of that code page (a parameter so a
624 test can pick a narrow one).
625 """
626 def fits(p: str) -> bool:
627 try:
628 p.encode(ansi)
629 return True
630 except UnicodeEncodeError:
631 return False
632
633 if os.name != "nt" or fits(path):
634 return path
635 import ctypes
636 buf = ctypes.create_unicode_buffer(32768)
637 n = ctypes.windll.kernel32.GetShortPathNameW(path, buf, len(buf))
638 short = buf.value if 0 < n < len(buf) else ""
639 return short if short and fits(short) else None
640
641
617def main() -> int: 642def main() -> int:
618 ap = argparse.ArgumentParser() 643 ap = argparse.ArgumentParser()
619 ap.add_argument("--llvm-mc", default=os.environ.get("LLVM_MC", "llvm-mc"), 644 ap.add_argument("--llvm-mc", default=os.environ.get("LLVM_MC", "llvm-mc"),
@@ -657,7 +682,14 @@ def main() -> int:
657 682
658 work = a.work or tempfile.mkdtemp(prefix="leonida_gpu_tests_") 683 work = a.work or tempfile.mkdtemp(prefix="leonida_gpu_tests_")
659 try: 684 try:
660 return run_suite(a, work) 685 os.makedirs(work, exist_ok=True)
686 native = native_folder(work)
687 if native is None:
688 print(f"error: the work folder {ascii(work)} has characters outside this PC's ANSI code page and no 8.3 "
689 "short name, so the test programs and the Vulkan SDK tools can't open files in it. Pass --work "
690 "with a folder whose path they can, such as C:\\leonida_gpu_work.", file=sys.stderr)
691 return 2
692 return run_suite(a, native)
661 finally: 693 finally:
662 if a.work is None: 694 if a.work is None:
663 shutil.rmtree(work, ignore_errors=True) 695 shutil.rmtree(work, ignore_errors=True)