tools/client/test_portable_new_handler.py (1257B)
1 """Compare guest allocation-failure callbacks with Windows x86 MSVCRT.""" 2 import pathlib 3 import subprocess 4 5 6 root = pathlib.Path(__file__).resolve().parents[2] 7 decompiled = root / "client" 8 work = root / "local/client/portable-new-handler" 9 work.mkdir(parents=True, exist_ok=True) 10 reference = work / "reference.exe" 11 subprocess.run([ 12 str(root / "toolchains/llvm-mingw-20261006-ucrt-x86_64/bin/i686-w64-mingw32-clang.exe"), 13 "-O2", "tests/new_handler.c", "-o", str(reference), 14 ], cwd=decompiled, check=True) 15 expected = subprocess.check_output([str(reference)], text=True, timeout=30) 16 linux_path = "/mnt/" + decompiled.drive[0].lower() + decompiled.as_posix()[2:] 17 linux_output = "/mnt/" + work.drive[0].lower() + work.as_posix()[2:] + "/translated" 18 wsl = ["wsl", "-d", "Ubuntu-26.04", "--cd", linux_path, "--exec"] 19 subprocess.run(wsl + [ 20 "gcc", "-O2", "-DRECOMP_PORTABLE", "-Iruntime", "-fno-strict-aliasing", 21 "tests/new_handler.c", "runtime/guest_crt.c", "runtime/guest_heap.c", 22 "runtime/guest_memory.c", "runtime/recomp_state.c", "-lm", "-o", linux_output, 23 ], check=True) 24 actual = subprocess.check_output(wsl + [linux_output], text=True, timeout=30) 25 assert actual == expected, (expected, actual) 26 print("Windows == Linux: " + actual.strip())