"""FAT32/MBR layout: field-level checks against the FAT spec on an in-memory disk, plus an independent FAT implementation (pyfatfs) mounting the result.""" import struct import pytest from kota_tech.sd import fat32 MiB, GiB = 1024**2, 1024**3 def make_disk(size: int, label="KOTA") -> tuple[bytearray, fat32.Fat32Layout]: lay = fat32.plan(size) disk = bytearray(b"\xAA" * size) # old garbage everywhere zeros, writes = fat32.build(lay, label, 0x12345678, 0xCAFEBABE, size) for off, n in zeros: disk[off:off + n] = bytes(n) for off, data in writes: disk[off:off + len(data)] = data return disk, lay @pytest.fixture(scope="module") def small(): return make_disk(96 * MiB) def test_mbr_has_one_fat32_lba_partition(small): disk, lay = small assert disk[510:512] == b"\x55\xAA" status, ptype, lba, count = struct.unpack_from("