#!/usr/bin/env python3 """ Generate a >64 KB test file with predictable position-encoded content. Every 256-byte block starts with a 32-character ASCII line "[off=NNNNNNN] block #BBBB filler...\n" where NNNNNNN is the absolute byte offset of the block start (padded to 7 decimal digits) and BBBB is the 4-digit block index. The line is padded to 256 bytes with '.' so that seeking to any 256-aligned offset gives an immediately-readable label. """ import sys import os def main(): path = sys.argv[1] if len(sys.argv) > 1 else "big.txt" target_size = int(sys.argv[2]) if len(sys.argv) > 2 else 100 * 1024 block_size = 256 nblocks = (target_size + block_size - 1) // block_size with open(path, "wb") as f: for b in range(nblocks): offset = b * block_size header = f"[off={offset:07d}] block #{b:04d} " body = header + ("." * (block_size - len(header) - 1)) + "\n" assert len(body) == block_size, len(body) f.write(body.encode("ascii")) actual = os.path.getsize(path) print(f"wrote {path}: {actual} bytes ({nblocks} blocks of {block_size} each)") if __name__ == "__main__": main()