Files
WoW-Hybrid-gateway/tests/native_far_control_opcode_win_test.py
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

35 lines
2.7 KiB
Python

#!/usr/bin/env python3
"""New PE/C admission boundary from captured opcode; no game/client is run."""
import json,os,subprocess,sys
from pathlib import Path
ROOT=Path(__file__).resolve().parents[1];sys.path.insert(0,str(ROOT/'ops'))
from build_wine_wire import FLAGS,LIBS
from wine_console import run_console
telemetry='--log-disconnect' in sys.argv
if telemetry:
oracle=json.loads(Path(sys.argv[1]).read_text());assert oracle['input'].splitlines()[0]=='C 460007' and oracle['output'].splitlines()[0].split()[0]=='440007'
captured=None
else:
captured=int(Path(sys.argv[1]).read_text().strip())
if not 0<=captured<=0xffffffff:raise ValueError('Captured opcode bound')
folder=ROOT/('runtime/vm-build-share/log-disconnect-opcode-fixture'if telemetry else 'runtime/vm-build-share/far-control-opcode-fixture');folder.mkdir(parents=True,exist_ok=True)
obj=folder/'opcode.obj';exe=folder/'opcode.exe'
if '--run-existing' not in sys.argv:
if telemetry:
host=(ROOT/'native/wine_pipe_host.c').read_text();assert host.count(' if(opcode==0x460007){')==1
begin=host.index(' if(opcode==0x460007){');end=host.index(' if(opcode==0x420070){',begin)
(folder/'log_disconnect_production_branch.inc').write_text(host[begin:end])
tail=host[host.index('static void WINAPI pipe_write_current('):];done=tail.index('done:');completion=tail[done:tail.index(' ReleaseSRWLockExclusive(&lock);',done)]
assert 'if(error&&gw_wire_pipe_data.connection)close_pipe(error);' in completion
(folder/'log_disconnect_production_completion.inc').write_text(completion)
defines=['-DGW_LOG_DISCONNECT_FIXTURE=1','-I'+str(folder)]
else:defines=['-DGW_CAPTURED_SUSPEND_OPCODE='+str(captured)+'u']
subprocess.run(['clang',*FLAGS,*defines,'-c',str(ROOT/'tests/native_far_control_opcode_win_fixture.c'),'-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])],check=True)
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)
r=run_console(['wine',str(exe)],env=env,timeout=15)
(folder/'stdout-private.log').write_bytes(r.stdout);(folder/'stderr-private.log').write_bytes(r.stderr)
if r.returncode:raise RuntimeError('Opcode PE fixture exit'+str(r.returncode)+'; see private logs for host/fixture attribution')
print('PASS actual host telemetry branch preserves pipe; malformed framing rejected; no original native client called.'if telemetry else 'PASS captured70334PE control classification; obsolete connection alias refused; no original native client called.')