"""Tests for tools/ptr_constants.py. The VT1200 firmware stores TMS34010 *bit* addresses: a 32-bit value P refers to physical byte P >> 3. ptr_constants.scan() finds those constants in an address-ordered image and resolves where they point. """ import os import struct import sys import unittest HERE = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, os.path.join(HERE, "tools")) import ptr_constants ROM_BASE = 0x07E40000 class ScanSyntheticTest(unittest.TestCase): def test_finds_string_pointer(self): img = bytearray(0x1000) img[0x100:0x100 + 11] = b"HELLO WORLD" ptr = (ROM_BASE + 0x100) << 3 # bit address of the string struct.pack_into("