# Test Case: LZ4 Compression Large File Handling

**Test ID**: TC085-lz4-large-file  

**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 LZ4 decompression correctness for large files (>100MB).

## Preconditions
- Generated image: `images/lz4-large.erofs`
- Test file: `/large.bin`, exactly 268435456 bytes
- Reference: `sources/large/large.bin` and its generated SHA256
- Mount point: `/mnt/test`

## Test Steps
1. Mount the image:
   ```
   mount -t erofs /dev/md0 /mnt/test
   ```

2. Verify file size reported correctly:
   ```
   stat -f %z /mnt/test/files/large-lz4.bin
   ```

3. Read entire file and compute checksum:
   ```
   sha256 -q /mnt/test/large.bin
   sha256 -q sources/large/large.bin
   cmp sources/large/large.bin /mnt/test/large.bin
   ```

4. Test partial reads at various offsets:
   ```
   read_probe pread /mnt/test/large.bin 52428800 10485760 guest.bin
   read_probe pread sources/large/large.bin 52428800 10485760 source.bin
   cmp source.bin guest.bin
   read_probe pread /mnt/test/large.bin 209715200 10485760 guest.bin
   read_probe pread sources/large/large.bin 209715200 10485760 source.bin
   cmp source.bin guest.bin
   ```

5. Test random access reads:
   ```
   # Compare both guest ranges with the same source offsets.
   read_probe pread /mnt/test/large.bin 4096000 4096 chunk1
   read_probe pread /mnt/test/large.bin 204800000 4096 chunk2
   ```

## Expected Results
- Step 2: Size is 268435456 bytes (256MB)
- Step 3: Checksum matches reference value
- Step 4: Partial reads succeed, no errors
- Step 5: Random access works correctly

## Verification Method
- Verify data integrity via checksum
- Confirm partial/random reads decompress correctly
- Test memory usage during decompression reasonable
- Verify no memory leaks or buffer overflows

## Cleanup
```
umount /mnt/test
mdconfig -d -u "${unit#md}"
rm /tmp/chunk1 /tmp/chunk2
```

## Notes
- Large file decompression tests pcluster handling
- LZ4 decompression should be streaming (low memory)
- Related tests: TC089 (pcluster mapping)
