Files
WoW-Hybrid-gateway/tests/loading_screens_source_component_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

105 lines
5.1 KiB
Python

"""Validate only the new real-resource-binding→private legacy definition batch.
Original table encoding, image decoding and resource allocation receipts remain
owning evidence. This checks their new association in the actual C++ header.
"""
import argparse
import json
import os
from pathlib import Path
import struct
import subprocess
def run(component_directory, binding_path):
component = json.loads((component_directory / 'component.json').read_text())
binding_handoff = json.loads(binding_path.read_text())
expected = {}
members = {}
for binding in binding_handoff['bindings']:
for ident in binding['loading_ids']:
assert ident not in expected
expected[ident] = binding['file_data_id']
members[ident] = binding
assert len(expected) == 21
assert len(component['rows']) == len(component['source_bindings']) == 21
assert component['source_schema_has_flags'] is False
assert component['source_fields'] == ['ID32', 'Name_string_offset32', 'FileName_string_offset32']
assert component['native_original_row_application'] is False
assert component['active_package_or_client_changed'] is False
assert component['input_receipts']['candidate_manifest_sha256'] == binding_handoff['candidate_manifest_sha256']
for source in component['source_bindings']:
ident = source['source_loading_id']
binding = members[ident]
assert source['source_fields']['ID'] == ident
assert set(source['source_fields']) == {'ID', 'Name', 'FileName'}
assert source['source_fields']['FileName'] == binding['member']
assert source['native_file_data_id'] == binding['file_data_id']
assert source['content_key'] == binding['content_key']
assert source['source_body_sha256'] == binding['source_sha256']
# Actual generated profile lookup is the boundary under test. Interpret its
# bytes with the independent six-int/four-float original layout contract.
work = component_directory / 'focused-compiled-lookup'
work.mkdir()
source = work / 'lookup.cpp'
source.write_text('''#include <cstdio>
#include "../item_sparse_compat.hpp"
int main() {
using namespace gateway::item_sparse_compat;
for (const auto& row : Records) {
const auto value = find(row.table, row.id);
const uint32_t prefix[] = {row.table, row.id, static_cast<uint32_t>(value.size())};
if (std::fwrite(prefix, sizeof(prefix), 1, stdout) != 1 ||
std::fwrite(value.data(), 1, value.size(), stdout) != value.size()) return 2;
}
if (!find(0x7253EB43, Records[0].id).empty() || !find(0xEF9DC6FF, 0).empty()) return 3;
return 0;
}
''')
executable = work / 'lookup'
command = ['clang++', '-std=c++20', '-O0', '-Wall', '-Wextra', '-Werror', str(source), '-o', str(executable)]
(work / 'compile-command.json').write_text(json.dumps(command, indent=2) + '\n')
with (work / 'compile.log').open('w') as log:
subprocess.run(command, stdout=log, stderr=subprocess.STDOUT, check=True)
raw = subprocess.run([str(executable)], check=True, capture_output=True).stdout
offset, observed = 0, {}
while offset < len(raw):
table, ident, size = struct.unpack_from('<III', raw, offset)
offset += 12
assert table == 0xEF9DC6FF and size == 40 and ident not in observed
values = struct.unpack_from('<6i4f', raw, offset)
offset += size
assert values[0] == expected[ident]
assert values[1:] == (0, 0, 0, 0, 0, 0.0, 0.0, 0.0, 0.0)
observed[ident] = values[0]
assert offset == len(raw) and observed == expected
pages = json.loads((component_directory / 'pages.json').read_text())['pages']
assert sum(p['count'] for p in pages) == 21
assert sum(p['wire_bytes'] - 8 for p in pages) == 21 * 61
return dict(status='PASS_PRIVATE21_REAL_BINDING_CPP_LOOKUP',
Source_definition_IDs=21, actual_asset_bindings=21,
original_legacy_fields_preserved=9, body_bytes=40,
source_Name_and_FileName_retained=True, source_flag_column_absent=True,
wrong_table_and_zero_lookup_refused=True,
source_image_decode_or_asset_allocation_repeated=False,
CASC_readback=binding_handoff['native_CASC_readback'],
native_application_or_runtime_rendering=False,
current_package_or_client_mutation=False)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--component-directory', type=Path, required=True)
parser.add_argument('--bindings', type=Path, required=True)
parser.add_argument('--result', type=Path, required=True)
args = parser.parse_args()
try:
result = run(args.component_directory, args.bindings)
except Exception as error:
args.result.write_text(json.dumps(dict(status='FAIL_PRIVATE21_NEW_BINDING_BOUNDARY',
error_type=type(error).__name__, error=str(error)), indent=2) + '\n')
raise
args.result.write_text(json.dumps(result, indent=2) + '\n')
os.chmod(args.result, 0o600)
print(result['status'])