"""tex_headers.py report paths: never overwrite a carve manifest or a scanned .bin stream. Run with ``python -I tests/test_tex_headers_report_paths.py``. Set ``LEONIDA_TEX_HEADERS`` to another copy of the tool to use as a negative control (main's version writes the report over the .bin it just scanned). All inputs are hand-built; no game data is used. """ import contextlib import io import json import os import pathlib import struct import subprocess import sys import tempfile import unittest from unittest import mock ROOT = pathlib.Path(__file__).resolve().parent.parent TOOL = pathlib.Path(os.environ.get("LEONIDA_TEX_HEADERS", str(ROOT / "tools" / "tex_headers.py"))) for folder in (str(ROOT), str(ROOT / "tools")): if folder not in sys.path: sys.path.insert(0, folder) import tex_headers def make_carve(folder): """One synthetic BC1 texture: a CPU descriptor blob followed by its GPU data blob.""" carve = pathlib.Path(folder) / "carve" arch = carve / "common" arch.mkdir(parents=True) cpu_off, gpu_off = 0x1000, 0x2000 qwords = [0] * 32 qwords[0] = 0 qwords[1] = 0x123456789ABCDEF0 k = 10 qwords[k - 2] = 0xCAFEBABE00000001 qwords[k - 1] = 0x980 qwords[k] = 0x60000000 + 0x1000 qwords[k + 4] = struct.unpack("