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

**Test ID**: TC089-lz4-pcluster-4k  

**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 (pcluster) mapping for LZ4 compression with 4KB pcluster size.

## Preconditions
- EROFS image with LZ4, 4KB pcluster: `test-lz4-pcluster-4k.erofs`
- Test file: `/files/test-4k.dat` (aligned to 4KB boundaries)
- Mount point: `/mnt/test`

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

2. Read aligned to pcluster boundary (offset 0):
   ```
   dd if=/mnt/test/files/test-4k.dat of=/tmp/out1 bs=4K count=1 skip=0
   ```

3. Read aligned to pcluster boundary (offset 4K):
   ```
   dd if=/mnt/test/files/test-4k.dat of=/tmp/out2 bs=4K count=1 skip=1
   ```

4. Read unaligned (crosses pcluster boundary):
   ```
   dd if=/mnt/test/files/test-4k.dat of=/tmp/out3 bs=2K count=2 skip=1
   ```

5. Read spanning multiple pclusters:
   ```
   dd if=/mnt/test/files/test-4k.dat of=/tmp/out4 bs=16K count=1
   ```

## Expected Results
- Step 2: Single pcluster decompressed, correct data
- Step 3: Adjacent pcluster decompressed, correct data
- Step 4: Two pclusters decompressed for unaligned read
- Step 5: Four pclusters decompressed (16K / 4K = 4)

## Verification Method
- Verify pcluster boundaries handled correctly
- Confirm unaligned reads work (may decompress extra pclusters)
- Test each pcluster independently decompressible
- Verify correct data returned for all read patterns

## Cleanup
```
umount /mnt/test
mdconfig -d -u md0
rm /tmp/out1 /tmp/out2 /tmp/out3 /tmp/out4
```

## Notes
- 4KB pcluster provides good random access performance
- Each 4KB logical region compressed independently
- Small pcluster = less compression, better random access
- Related tests: TC090 (64KB pcluster)
