# Test Case: LZ4 Compressed Physical Cluster Mapping (64KB)

**Test ID**: TC090-lz4-pcluster-64k  

**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 physical cluster mapping for LZ4 compression with 64KB pcluster size.

## Preconditions
- EROFS image with LZ4, 64KB pcluster: `test-lz4-pcluster-64k.erofs`
- Test file: `/files/test-64k.dat` (1MB, highly compressible)
- Mount point: `/mnt/test`
- Generate with `mkfs.erofs -zlz4 -C65536 test-lz4-pcluster-64k.erofs source`
  and confirm `compr_cfgs big_pcluster` with `dump.erofs -s`.

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

2. Read first pcluster (64KB):
   ```
   dd if=/mnt/test/files/test-64k.dat of=/tmp/out1 bs=64K count=1
   ```

3. Read small portion requiring full pcluster decompression:
   ```
   dd if=/mnt/test/files/test-64k.dat of=/tmp/out2 bs=4K count=1 skip=1
   ```

4. Read crossing pcluster boundary:
   ```
   dd if=/mnt/test/files/test-64k.dat of=/tmp/cross bs=1 skip=65504 count=64
   dd if=/root/reference/test-64k.dat of=/tmp/cross.expected bs=1 skip=65504 count=64
   cmp /tmp/cross /tmp/cross.expected
   ```

5. Record the physical extent layout:
   ```
   dump.erofs --path=/files/test-64k.dat -e test-lz4-pcluster-64k.erofs
   ```

## Expected Results
- Step 2: Full 64KB pcluster decompressed correctly
- Step 3: Reading 4KB requires decompressing entire 64KB pcluster
- Step 4: Boundary crossing handled correctly
- Step 5: The fixture contains a real compressed big-pcluster extent

## Verification Method
- Verify large pcluster decompression works
- Confirm small reads still trigger full pcluster decompression
- Test memory usage reasonable for 64KB decompression
- Do not require a better compression ratio than 4KB for every corpus

## Cleanup
```
umount /mnt/test
mdconfig -d -u md0
rm /tmp/out* /tmp/cross /tmp/cross.expected
```

## Notes
- 64KB pcluster provides better compression at cost of random access
- Common pcluster size for read-heavy workloads
- Related tests: TC089 (4KB pcluster), TC088 (config handling)
