# Test Case: LZ4 ztailpacking Data Path

**Test ID**: TC091-ztailpacking-basic  

**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 operation of ztailpacking (compressed tail packing) for LZ4-compressed files.

## Preconditions
- EROFS image with ztailpacking enabled: `test-ztailpacking.erofs`
- Test file: `/inline.dat` (64KB deterministic compressible data)
- Mount point: `/mnt/test`
- Generate with:
  ```
  mkfs.erofs -zlz4 -C4096 -Eztailpacking test-ztailpacking.erofs source
  ```
- Before mounting, require `dump.erofs -s` to report `ztailpacking` and
  `dump.erofs --path=/inline.dat -e` to show the compressed physical extent
  inside the metadata block. Enabling the mkfs option alone does not prove
  that the target file was tail-packed.

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

2. Read file with packed tail:
   ```
   cat /mnt/test/inline.dat > /tmp/output.dat
   ```

3. Verify file size correct:
   ```
   stat -f %z /mnt/test/inline.dat
   ```

4. Read file tail specifically:
   ```
   tail -c 1024 /mnt/test/inline.dat > /tmp/tail.dat
   ```

5. Verify data integrity:
   ```
   sha256 /tmp/output.dat
   ```

## Expected Results
- Step 2: File read successfully with tail decompressed
- Step 3: Size matches original uncompressed size
- Step 4: Tail data correct
- Step 5: Checksum matches reference

## Verification Method
- Verify tail-packed data decompressed correctly
- Confirm storage efficiency (tail stored inline or in special area)
- Test tail packing transparent to reader
- Verify boundary between main data and packed tail handled correctly

## Cleanup
```
umount /mnt/test
mdconfig -d -u md0
rm /tmp/output.dat /tmp/tail.dat
```

## Notes
- ztailpacking stores compressed file tail inline with inode or in special area
- Reduces fragmentation and improves small file efficiency
- Related tests: TC092 (edge cases), TC033 (uncompressed tailpacking)
