# Test Case: LZMA Compressed File Read **Test ID**: TC004-lzma-compressed-read **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**: High **Regression**: None ## Objective Verify correct decompression and reading of LZMA/MicroLZMA-compressed files (newly implemented in repo18 iteration 1). ## Preconditions - EROFS image with LZMA-compressed files: `test-lzma.erofs` - Known reference file: `original-large.txt` (uncompressed source) - Compressed file in image: `/compressed/large.txt` - Mount point: `/mnt/test` ## Test Steps 1. Mount the LZMA test image: ```sh unit=$(mdconfig -a -t vnode -f test-lzma.erofs) mount -t erofs -o ro /dev/${unit} /mnt/test ``` 2. Verify file exists and check size: ``` ls -lh /mnt/test/compressed/large.txt stat -f "Size: %z bytes" /mnt/test/compressed/large.txt ``` 3. Read entire compressed file: ``` cat /mnt/test/compressed/large.txt > /tmp/lzma-decompressed.txt ``` 4. Verify decompression correctness: ``` sha256 /tmp/lzma-decompressed.txt sha256 original-large.txt ``` 5. Compare byte-for-byte: ``` cmp /tmp/lzma-decompressed.txt original-large.txt echo $? ``` 6. Test random access read: ``` dd if=/mnt/test/compressed/large.txt of=/tmp/lzma-middle.txt bs=1k skip=100 count=10 dd if=original-large.txt of=/tmp/orig-middle.txt bs=1k skip=100 count=10 cmp /tmp/lzma-middle.txt /tmp/orig-middle.txt ``` 7. Test end-of-file read: ``` tail -c 1000 /mnt/test/compressed/large.txt > /tmp/lzma-tail.txt tail -c 1000 original-large.txt > /tmp/orig-tail.txt cmp /tmp/lzma-tail.txt /tmp/orig-tail.txt ``` ## Expected Results - Step 1: Mount succeeds - Step 2: File size matches original uncompressed size exactly - Step 4: SHA256 checksums are identical - Step 5: Exit code 0 (files identical) - Step 6: Middle section matches (random access works) - Step 7: Tail matches (EOF handling correct) ## Verification Method - Complete data integrity check via SHA256 - Partial read correctness (random access) - No memory corruption or crashes during decompression - Verify LZMA decoder internal state: - 1846 probability models initialized - Range decoder normalization correct - Dictionary buffer within bounds ## Cleanup ``` umount /mnt/test mdconfig -d -u "${unit}" rm /tmp/lzma-*.txt /tmp/orig-*.txt ``` ## Notes - **NEW in repo18**: This is the first iteration with LZMA support - LZMA provides maximum compression ratio (~30-50% smaller than LZ4) - MicroLZMA is a variant without header, commonly used in EROFS - Self-contained implementation in `src/decompressor_lzma.c` - Reference implementation: XZ Embedded minimal decoder - Critical test for repo18 iteration 1 validation - Regression marker: First LZMA implementation, high priority for validation