tools/client/test_portable_module_snapshot.py (1039B)
1 """Check the module snapshot contract on Windows and native Linux.""" 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-module-snapshot" 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/module_snapshot.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 wsl = ["wsl", "-d", "Ubuntu-26.04", "--cd", linux_path, "--exec"] 18 subprocess.run(wsl + ["make", "-s", "-f", "Makefile.linux", "build/linux/module-snapshot"], check=True) 19 actual = subprocess.check_output(wsl + ["./build/linux/module-snapshot"], text=True, timeout=30) 20 assert actual == expected, (expected, actual) 21 print("Windows == Linux contract: " + actual.strip()) 22 23