test code v1
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
# Test Case: LZ4 Deterministic Random-Offset Reads
|
||||
|
||||
**Test ID**: TC087-lz4-random-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**: High
|
||||
|
||||
## Objective
|
||||
|
||||
Verify non-sequential reads from deterministic offsets in an LZ4-compressed
|
||||
file and compare every returned byte with the source. `$RANDOM` and timing-only
|
||||
checks are not evidence of data correctness.
|
||||
|
||||
## Fixture and Helper
|
||||
|
||||
```sh
|
||||
work=$(mktemp -d /tmp/repo22-tc087.XXXXXX)
|
||||
tests/prepare_error_fixtures.sh "$work/fixtures"
|
||||
cc -O2 -Wall -Wextra -std=c17 tests/read_probe.c -o "$work/read_probe"
|
||||
dump.erofs --path=/compressed.bin -e "$work/fixtures/valid-lz4.erofs"
|
||||
```
|
||||
|
||||
## FreeBSD Procedure
|
||||
|
||||
```sh
|
||||
mkdir "$work/mnt"
|
||||
unit=$(mdconfig -a -t vnode -f "$work/fixtures/valid-lz4.erofs")
|
||||
mount -t erofs -o ro "/dev/$unit" "$work/mnt"
|
||||
size=$(stat -f %z "$work/fixtures/source/compressed.bin")
|
||||
test "$size" -gt 1052672
|
||||
|
||||
index=0
|
||||
for offset in 0 4096 65536 1048576 $((size - 4096)); do
|
||||
"$work/read_probe" pread "$work/mnt/compressed.bin" \
|
||||
"$offset" 4096 "$work/guest-$index.bin"
|
||||
"$work/read_probe" pread "$work/fixtures/source/compressed.bin" \
|
||||
"$offset" 4096 "$work/source-$index.bin"
|
||||
cmp "$work/source-$index.bin" "$work/guest-$index.bin"
|
||||
index=$((index + 1))
|
||||
done
|
||||
|
||||
umount "$work/mnt"
|
||||
mdconfig -d -u "${unit#md}"
|
||||
```
|
||||
|
||||
## Expected Results
|
||||
|
||||
All five fixed reads, including the final 4 KiB of the file, return exactly
|
||||
4096 bytes and compare equal to their corresponding source ranges. No
|
||||
performance ordering is asserted.
|
||||
Reference in New Issue
Block a user