47 lines
3.5 KiB
Python
47 lines
3.5 KiB
Python
#!/usr/bin/env python3
|
|
import argparse, hashlib, json, subprocess, sys
|
|
from pathlib import Path
|
|
ROOT=Path(__file__).resolve().parents[1]
|
|
def run(*args): subprocess.run([str(x) for x in args],check=True,cwd=ROOT)
|
|
def main():
|
|
ap=argparse.ArgumentParser();ap.add_argument('--build',action='store_true');ap.add_argument('--output',type=Path,required=True);ap.add_argument('--content-root',type=Path,action='append',default=[])
|
|
a=ap.parse_args();a.output.mkdir(parents=True,exist_ok=True)
|
|
if a.build:
|
|
run('c++','-std=c++20','-Wall','-Wextra','-Werror','-I',ROOT/'native',ROOT/'tests/source_creation_challenges_test.cpp','-o',a.output/'mask-test')
|
|
run('c++','-std=c++20','-Wall','-Wextra','-Werror','-fsyntax-only','-I',ROOT/'native','-I',ROOT/'include','-isystem','/usr/include/wine/windows',ROOT/'native/wine_wire_registry.cpp')
|
|
sys.path.insert(0,str(ROOT/'ops'))
|
|
from build_wine_wire import FLAGS
|
|
# Host Wine rpcndr defines 'small'; neutralize that legacy macro only in this syntax harness.
|
|
shim=a.output/'wine-header-shim.h';shim.write_text('#include <windows.h>\n#undef small\n')
|
|
for file in ('native/wine_pipe_host.c','native/wine_wire_account.c','native/nohelper/clogin_realm_rows.c'):
|
|
run('clang',*FLAGS,'-DGW_SOURCE_ONLY_PROFILE=5','-DGW_SOURCE_UI_CREATE_EXPERIMENT=1','-DGW_SOURCE_LOCAL_AUTH_IPV4="127.0.0.1"','-DGW_SOURCE_LOCAL_AUTH_PORT=3724','-include',shim,'-fsyntax-only',ROOT/file)
|
|
else:
|
|
run(a.output/'mask-test')
|
|
run('lua',ROOT/'tests/source_creation_challenges_test.lua',ROOT/'compat/glue/challenge_creation.lua')
|
|
sys.path.insert(0,str(ROOT/'ops'));from challenge_creation_ui import patch
|
|
source=' if api(8, 0, 0) ~= 1 then return false, "stage"; end\nlocal ok, reason = GW_SourceDirectCreate(self:GetSelectedName());\nfunction CharacterCreateMixin:OnShow()\nfunction CharacterCreateMixin:OnEvent(event, ...)\n'
|
|
result=patch(source);assert result.index('GW_SourceChallengeStage() then') < result.index('local staged = api(8')
|
|
assert 'GW_SourceChallengeReset();\n if staged' in result
|
|
try:patch(result)
|
|
except ValueError:pass
|
|
else:raise AssertionError('double patch accepted')
|
|
for root in a.content_root:
|
|
from content_candidate_rehearsal import rehearse
|
|
rows=json.loads((root/'candidate-assets.json').read_text())
|
|
assert len(rows)==1 and rows[0]['file_data_id']==8209459
|
|
row=rows[0];before=(root/'native-minimaps'/row['path']).read_bytes();after=Path(row['file']).read_bytes()
|
|
assert hashlib.sha256(before).hexdigest()==row['before_sha256']
|
|
assert hashlib.sha256(after).hexdigest()==row['after_sha256']
|
|
assert after.startswith((ROOT/'compat/glue/challenge_creation.lua').read_bytes()+b'\n')
|
|
run('luac','-p',row['file'])
|
|
parent=Path(json.loads((root/'current-content-parent-path.json').read_text())[0])
|
|
old=(parent/'decoded/root.bin').read_bytes()
|
|
oldkey=hashlib.md5(before).digest();newkey=hashlib.md5(after).digest()
|
|
assert old.count(oldkey)==1
|
|
candidate=(root/'content-step/candidate/decoded/root.bin').read_bytes()
|
|
assert candidate==old.replace(oldkey,newkey), 'only the chooser ROOT resource may change'
|
|
result=rehearse(root)
|
|
print('Content forward/inverse rehearsal', root.name, result)
|
|
print('Source challenge creation contract PASS')
|
|
if __name__=='__main__':main()
|