aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


tools/client/test_msvcp_strings.py (1674B)


      1 """Compare the portable VC6 string ABI with the retained 32-bit vendor DLL."""
      2 import hashlib
      3 import pathlib
      4 import subprocess
      5 
      6 
      7 root = pathlib.Path(__file__).resolve().parents[2]
      8 decompiled = root / "client"
      9 vendor = root / "anarchy-runtime-14.9.1/MSVCP60.DLL"
     10 assert hashlib.sha256(vendor.read_bytes()).hexdigest() == (
     11     "2b6b93c2d66969eb00258e2b5ad6172decebada096e3b1b077a3380c80e4a072"
     12 )
     13 
     14 # Compile and execute the real x86 reference without loading any game binaries.
     15 reference = decompiled / "build/msvcp-strings-reference.exe"
     16 reference.parent.mkdir(parents=True, exist_ok=True)
     17 subprocess.run([
     18     str(root / "toolchains/llvm-mingw-20261006-ucrt-x86_64/bin/i686-w64-mingw32-clang.exe"),
     19     "-O2", "-Iruntime", "tests/msvcp_strings.c", "tests/reference_memory.c",
     20     "runtime/recomp_state.c", "-o", str(reference),
     21 ], cwd=decompiled, check=True)
     22 expected = subprocess.check_output([str(reference), str(vendor)], text=True)
     23 
     24 # Compile the same observations against translated guest memory on native Linux.
     25 linux_path = "/mnt/" + decompiled.drive[0].lower() + decompiled.as_posix()[2:]
     26 wsl = ["wsl", "-d", "Ubuntu-26.04", "--cd", linux_path, "--exec"]
     27 subprocess.run(wsl + ["mkdir", "-p", "build/linux"], check=True)
     28 subprocess.run(wsl + [
     29     "gcc", "-O2", "-DRECOMP_PORTABLE", "-Iruntime", "tests/msvcp_strings.c",
     30     "runtime/guest_msvcp.c", "runtime/guest_heap.c", "runtime/guest_memory.c",
     31     "runtime/recomp_state.c", "-o", "build/linux/msvcp-strings",
     32 ], check=True)
     33 actual = subprocess.check_output(wsl + ["build/linux/msvcp-strings"], text=True)
     34 assert actual == expected, (expected, actual)
     35 print("Windows MSVCP60 == Linux x86-64: " + actual.strip())