test code v1

This commit is contained in:
2026-08-13 10:44:59 +02:00
commit f3b1165f19
301 changed files with 37885 additions and 0 deletions
+87
View File
@@ -0,0 +1,87 @@
# Test Case: LZ4 Compressed File Read
**Test ID**: TC003-lz4-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**: Critical
**Regression**: None
## Objective
Verify correct decompression and reading of LZ4-compressed files.
## Preconditions
- EROFS image with LZ4-compressed files: `test-lz4.erofs`
- Known reference file: `original.txt` (uncompressed source)
- Compressed file in image: `/compressed/test.txt`
- Mount point: `/mnt/test`
## Test Steps
1. Mount the LZ4 test image:
```
mount -t erofs /dev/md0 /mnt/test
```
2. Verify file exists:
```
ls -lh /mnt/test/compressed/test.txt
```
3. Read the entire file:
```
cat /mnt/test/compressed/test.txt > /tmp/decompressed.txt
```
4. Calculate checksum:
```
sha256 /tmp/decompressed.txt
sha256 original.txt
```
5. Compare byte-for-byte:
```
cmp /tmp/decompressed.txt original.txt
```
6. Test partial read:
```
dd if=/mnt/test/compressed/test.txt of=/tmp/partial.txt bs=1024 count=1
```
7. Verify partial read matches:
```
cmp -n 1024 /tmp/partial.txt original.txt
```
## Expected Results
- Step 1: Mount succeeds
- Step 2: File size matches original uncompressed size
- Step 4: SHA256 checksums are identical
- Step 5: `cmp` returns 0 (files identical)
- Step 7: First 1024 bytes match
## Verification Method
- Exact byte-for-byte match with original file
- No corruption in decompressed data
- File attributes (size, timestamps) preserved correctly
- Check inode compression format:
```
# Using custom debug tool if available
erofs_inspect /dev/md0 /compressed/test.txt
# Should show: z_algorithmformat[0:2] = Z_EROFS_COMPRESSION_LZ4
```
## Cleanup
```
umount /mnt/test
mdconfig -d -u md0
rm /tmp/decompressed.txt /tmp/partial.txt
```
## Notes
- LZ4 is the most common compression algorithm in EROFS
- Test should cover files of various sizes: small (<4KB), medium (4KB-1MB), large (>1MB)
- LZ4 pcluster size is typically 4KB or 64KB
- Related: TC004 (ztailpacking), TC005 (pcluster mapping)