#!/usr/bin/env python3 """Unit tests for firmware image detection. No emulator needed. The distinction matters because getting it wrong is silent: an image loaded at the wrong offset runs 0x2800 bytes off and the first fetch reads whatever data is there. """ import os import struct import tempfile import unittest import uvk5_image as ui def write(tmp, name, data): path = os.path.join(tmp, name) with open(path, "wb") as fh: fh.write(data) return path def image(tmp, name, sp, reset, size=0x4000, extra_at_2800=None): """A file whose first two words are a vector table.""" buf = bytearray(size) struct.pack_into("