# Test Case: MicroLZMA Consumption and Corruption **Test ID**: TC144-microlzma-consumption-and-corruption **G5 fixture contract**: Use [G5-MANUAL-SETUP.md](G5-MANUAL-SETUP.md). Its generated paths, source comparisons, structured corruption offsets, and cleanup rules supersede placeholder examples in this file. **Category**: Compression **Priority**: Critical **Regression**: MicroLZMA full/partial completion semantics ## Objective Verify MicroLZMA input-consumption rules for complete streams, early-success rules for partial references, and deterministic rejection of damaged streams. ## Preconditions - FreeBSD 15 guest and repo22 module. - A full-index LZMA image with: - `/a.dat`: 1048576-byte complete MicroLZMA stream; - `/b.dat`: 700000-byte partial reference to `/a.dat`'s pcluster; - the `/b.dat` HEAD record marked `Z_EROFS_LI_PARTIAL_REF`. - the reused pblk and `D0_CBLKCNT` both equal `/a.dat`'s values. - A corrupted copy with a byte changed inside the proven compressed byte range. - Source files and their SHA256 values available on the guest. ## Test Steps 1. Prove the pcluster and partial-reference record with `dump.erofs` and a byte-level parser. 2. Mount the valid image and hash `/a.dat` completely. 3. Hash `/b.dat` completely; this requests only a prefix of the reused stream. 4. Compare reads at offsets 65500 and 524287 against source bytes. 5. Mount the corrupted image and read `/a.dat` with an errno-reporting helper. 6. Confirm the implementation's complete-stream condition includes both `XZ_STREAM_END` and `buffer.in_pos == srclen`. 7. Compare `vmstat -m` active EROFS allocations and pre/post `dmesg`. ## Expected Results - `/a.dat` succeeds only after exact output, `XZ_STREAM_END`, and complete compressed-input consumption. - `/b.dat` accepts `XZ_OK` after the requested partial output is filled. - Both complete SHA256 values and random ranges match. - The corrupted full stream returns errno 5 (`EIO`). - `control.bin` in the same corrupted image still matches its source. - Decoder state is freed on success and error; active EROFS allocations return to zero after unmount/unload. ## Cleanup ```sh umount /mnt/repo22 2>/dev/null || true mdconfig -d -u "${unit#md}" 2>/dev/null || true kldunload -i "${module_id}" ```