Files
praxisandClaude Fable 5.2 7f2139d8d0 Offline test fixtures
883 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

38 lines
2.9 KiB
Python

#!/usr/bin/env python3
"""Owned PE->Wine Unix-call fixture; no game compatibility claim.
Uses the normal development bridge pair. Core ASan/UBSan tests remain separate;
the optional Windows ABI fixture is not claimed to be sanitizer-instrumented.
"""
import json,os,shutil,subprocess,sys,tempfile
from pathlib import Path
ROOT=Path(__file__).resolve().parents[1]
sys.path.insert(0,str(ROOT/'ops'))
if not all(shutil.which(t) for t in ('wine','clang','lld-link')) or not Path('/usr/include/wine/unixlib.h').exists() or not (ROOT/'runtime/native-wine-prefix/gateway-private-prefix.json').exists():
print('SKIP: requires installed Wine ABI headers/toolchain');sys.exit(77)
from build_wine_wire import build,FLAGS,LIBS
from wine_console import run_console
pe,unix=build()
def compile_fixture(source,obj,exe,extra=(),defines=()):
slash=chr(92)
dos='Z:'+str(pe).replace('/',slash)
nt=slash+'??'+slash+'Z:'+str(unix).replace('/',slash)
subprocess.run(['clang',*FLAGS,*defines,'-DGW_WIRE_DLL='+json.dumps(dos),'-DGW_WIRE_UNIX=L'+json.dumps(nt),'-c',str(source),'-o',str(obj)],check=True)
subprocess.run(['lld-link','/entry:fixture_start','/subsystem:console','/nodefaultlib','/timestamp:0','/out:'+str(exe),str(obj),str(LIBS[2]),str(LIBS[3]),*map(str,extra)],check=True)
if len(sys.argv)>1 and sys.argv[1] in ('--network','--auth-host'):
account=sys.argv[1]=='--auth-host'
folder=ROOT/'build/wine-wire'
compile_fixture(ROOT/'tests/wine_wire_network.c',folder/'network.obj',folder/'network.exe',[
Path('/usr/lib/wine/x86_64-windows/libws2_32.a'),Path('/usr/lib/wine/x86_64-windows/libshell32.a')],['-DGW_TEST_AUTH_HOST=1'] if account else [])
subprocess.run([sys.executable,str(ROOT/'tests/loopback_fixture.py'),str(ROOT/'ops/run_wine_wire_fixture.py'),'--auth-host' if account else '--discover'],check=True,env=dict(os.environ,GW_FIXTURE_TIMINGS='1'))
print('Independent SRP server verified the Windows-owned account worker, invalid proofs and bounded cleanup; no world socket or Forever adoption.' if account else 'Independent SRP/world server verified genuine proofs and roster over a Windows-owned WinSock connection through the owned PE/Wine ABI; no Forever engine claim.')
sys.exit(0)
with tempfile.TemporaryDirectory(prefix='gateway-wine-wire-') as temp:
folder=Path(temp);obj=folder/'control.obj';exe=folder/'control.exe'
compile_fixture(ROOT/'tests/wine_wire_control.c',obj,exe)
env=dict(os.environ,WINEPREFIX=str(ROOT/'runtime/native-wine-prefix'),WINEDEBUG='-all')
for key in ('LD_PRELOAD','GW_NATIVE_BOOTSTRAP','GW_NATIVE_EXPECTED_EXE','GW_NATIVE_REGISTER'):env.pop(key,None)
result=run_console(['wine',str(exe)],env=env,timeout=15)
if result.returncode:raise RuntimeError('Owned Wine wire ABI fixture failed with status '+str(result.returncode))
print('Real PE DLL -> installed Wine Unix-call ABI: layout, initialization, scalar roundtrip, invalid typed tokens and idle cleanup verified; no game/network access.')