Files
WoW-Hybrid-gateway/tests/native_gameobject_query_boundary_test.py

29 lines
1.8 KiB
Python

"""Actual host admission source expression plus linked world dispatch fixture.
The host token check is static admission evidence, not PE execution or native
client acceptance. The compiled fixture exercises the current world/helper
request/reply path and verifies it produces no invented native template.
"""
import os,re,subprocess,sys,tempfile
from pathlib import Path
host=(Path(__file__).resolve().parents[1]/'native/wine_pipe_host.c').read_text()
expressions=re.findall(r'if\(([^{}]+)\)\{\s*init\(&c,GW_WIRE_GAMEPLAY\)',host)
query=[x for x in expressions if re.search(r'\bopcode\s*==\s*0x3e0144\b',x)]
assert len(query)==1,'Exact QueryGameObject opcode must have one host admission branch'
assert all(not re.search(r'\bopcode\s*==\s*0x3d0142\b',x) for x in expressions),'Reference normalization candidate must not be admitted as native alias'
with tempfile.TemporaryDirectory() as directory:
log=Path(directory)/'gw.log'
result=subprocess.run([sys.argv[1]],capture_output=True,text=True,
env={**os.environ,'GW_NATIVE_STARTUP_LOG':str(log)})
if result.returncode==0:
lines=[line for line in log.read_text().splitlines() if line.startswith('GW_GO template-reply ')]
assert lines and all(re.fullmatch(r'GW_GO template-reply entry=\d+ type=\d+ result=(answered|held) reason=[A-Za-z]+',line) for line in lines)
assert any('result=held reason=Unsolicited' in line for line in lines)
assert any('result=answered reason=NotFound' in line for line in lines)
# The first world receives the same reply twice; the next world starts
# from a fresh session and must log that entry again.
assert lines[0]==lines[1] and 'result=held' in lines[0]
sys.stdout.write(result.stdout);sys.stderr.write(result.stderr)
raise SystemExit(result.returncode)