aorecomp

Anarchy Online classic in the browser

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


tools/client/test_portable_network_startup.py (1312B)


      1 """Compare Winsock initialization, address conversion and socket lifetime with 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-network-startup"
      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/network_startup.c", "-lws2_32", "-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/network_startup.c", "runtime/linux_network.c", "runtime/linux_sync.c", "runtime/guest_memory.c",
     22     "runtime/recomp_state.c", "-pthread", "-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())