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

55 lines
3.0 KiB
Python

import hashlib
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'ops'))
from engine_race_validator_observation import ENTRY, PAGE, inspect
from engine_race_vector_copy_observation import (ENTRY as COPY_ENTRY, PAGE as COPY_PAGE, PREFIX,
capture as capture_copy, parse_source_header,
parse_race_class_pairs)
code = bytes((i * 31 + 7) & 0xff for i in range(4096))
reads = []
def read(address, size):
reads.append((address, size))
assert address == PAGE and size == 4096
return code
missing = inspect(read, lambda address, size: False)
assert missing == {'available': False, 'reason': 'fixed-validator-page-not-executable',
'engine_calls_made': False, 'arguments_read': False,
'memory_protection_changed': False}
assert reads == []
# Execute permission is sufficient for the bounded code-only probe. The
# runtime's /proc/pid/mem read may succeed for execute-only mappings.
captured = inspect(read, lambda address, size: address == PAGE and size == 4096)
assert captured['available'] and captured['page'] == hex(PAGE)
assert captured['sha256'] == hashlib.sha256(code).hexdigest()
assert captured['code'] == code and not captured['engine_calls_made']
assert not captured['arguments_read'] and not captured['memory_protection_changed']
assert reads == [(PAGE, 4096)]
assert ENTRY == 0x140208810
assert COPY_ENTRY == 0x142415208 and COPY_PAGE == (COPY_ENTRY & ~4095)
assert PREFIX == bytes.fromhex('48 8b 15 04 1f 85 05')
copy_reads = []
copy_page = inspect(lambda address, size: (copy_reads.append((address, size)) or code),
lambda address, size: address == COPY_PAGE and size == 4096,
COPY_PAGE)
assert copy_page['available'] and copy_page['page'] == hex(COPY_PAGE)
assert copy_page['code'] == code and copy_reads == [(COPY_PAGE, 4096)]
import struct
assert parse_source_header(struct.pack('<QQ', 0, 0))['source_row_count'] == 0
populated = parse_source_header(struct.pack('<QQ', 0x12340000, 4))
assert populated['source_row_count'] == 4 and populated['source_pointer_count_consistent']
assert parse_source_header(struct.pack('<QQ', 0x12340000, 33))['source_header_reason'] == 'source-count-out-of-bound'
assert parse_source_header(b'') ['source_header_reason'] == 'fixed-source-header-short-read'
assert parse_race_class_pairs(struct.pack('<QQ', 0, 0))['race_class_pair_count'] == 0
assert parse_race_class_pairs(struct.pack('<QQ', 0x12340000, 4))['race_class_pairs_pointer_count_consistent']
assert parse_race_class_pairs(struct.pack('<QQ', 0x12340000, 257))['race_class_pairs_reason'] == 'race-class-count-out-of-bound'
different = capture_copy(1, type('Registers', (), {'rip': COPY_ENTRY + 1})())
assert different['reason'] == 'different-entry' and not different['arguments_read']
print('Race/class observers are pinned to natural validator and vector-copy entries; NX pages and packet arguments remain untouched.')