import json import os import struct import subprocess import sys import tempfile import unittest from unittest import mock ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.insert(0, os.path.join(ROOT, "tools")) TOOL = os.path.join(ROOT, "tools", "rootsig_census.py") import rootsig_census as R def container(chunks): """A minimal DXBC container: magic, 24 zero bytes, chunk count at 28, offsets at 32.""" head = bytearray(b"DXBC" + b"\0" * 24) head += struct.pack("= 2 base = 24 + 12 * len(params) entries, body, tables = bytearray(), bytearray(), [] def push(data): off = base + len(body) body.extend(data) return off for param in params: kind, vis = param[0], param[1] if kind == "table": off = push(struct.pack("<2I", param[2], 0)) tables.append((off - base, param[2])) entries += struct.pack("<3I", 0, vis, off) elif kind == "constants": off = push(struct.pack("<4I", 0, 0, param[2], 0)) entries += struct.pack("<3I", 1, vis, off) else: dtype = {"cbv": 2, "srv": 3, "uav": 4}[kind] off = push(struct.pack("<3I", 0, 0, 0) if v11 else struct.pack("<2I", 0, 0)) entries += struct.pack("<3I", dtype, vis, off) for at, nranges in tables: if not nranges: continue ranges_off = base + len(body) for j in range(nranges): body += struct.pack("<6I", 0, 1, 0, 0, 0, j) if v11 else struct.pack("<5I", 0, 1, 0, 0, j) struct.pack_into("