test code v1
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
# Test Case: Targeted Compressed-Stream Corruption
|
||||
|
||||
**Test ID**: TC116-truncated-compressed
|
||||
**Category**: Error Handling
|
||||
**Priority**: Critical
|
||||
|
||||
## Objective
|
||||
|
||||
Verify targeted damage inside a proven LZ4 physical extent reaches
|
||||
`z_erofs_decompress` and returns `EIO`. Provider length must remain identical;
|
||||
this is not a short-media test.
|
||||
|
||||
## Fixture Qualification
|
||||
|
||||
```sh
|
||||
work=$(mktemp -d /tmp/repo22-tc116.XXXXXX)
|
||||
tests/prepare_error_fixtures.sh "$work/fixtures"
|
||||
cc -O2 -Wall -Wextra -std=c17 tests/read_probe.c -o "$work/read_probe"
|
||||
cat "$work/fixtures/compressed.extents"
|
||||
grep '^compressed-stream-corrupt ' "$work/fixtures/fixture-evidence.txt"
|
||||
wc -c "$work/fixtures/valid-lz4.erofs" \
|
||||
"$work/fixtures/compressed-stream-corrupt.erofs"
|
||||
cat "$work/fixtures/compressed-corrupt-fsck.txt"
|
||||
sha256 -q "$work/fixtures/compressed-stream-corrupt.erofs"
|
||||
```
|
||||
|
||||
The generator parses extent 0 for `/compressed.bin`, proves the 64-byte patch
|
||||
at extent offset +32 lies wholly inside that extent, changes nonzero bytes to
|
||||
zero, remains outside the superblock checksum window, preserves provider
|
||||
length, and requires `fsck.erofs --extract` failure. The superblock checksum
|
||||
remains valid because payload bytes are outside its range.
|
||||
|
||||
## FreeBSD Procedure
|
||||
|
||||
```sh
|
||||
mkdir "$work/mnt"
|
||||
unit=$(mdconfig -a -t vnode \
|
||||
-f "$work/fixtures/compressed-stream-corrupt.erofs")
|
||||
mount -t erofs -o ro "/dev/$unit" "$work/mnt"
|
||||
cmp "$work/fixtures/source/control.txt" "$work/mnt/control.txt"
|
||||
probe_module=$(dtrace -l -f z_erofs_decompress | awk \
|
||||
'$4 == "z_erofs_decompress" && $5 == "entry" { print $3; exit }')
|
||||
test -n "$probe_module"
|
||||
dtrace -l -n "fbt:$probe_module:z_erofs_decompress:entry"
|
||||
set +e
|
||||
dtrace -q -n "fbt:$probe_module:z_erofs_decompress:entry {
|
||||
@calls = count(); } END { printa(\"decompress_calls=%@d\\n\", @calls); }" \
|
||||
-c "$work/read_probe expect-error $work/mnt/compressed.bin 5" \
|
||||
>"$work/dtrace.out" 2>"$work/dtrace.err"
|
||||
dtrace_status=$?
|
||||
set -e
|
||||
cat "$work/dtrace.out"
|
||||
test "$dtrace_status" -eq 0
|
||||
grep -Eq 'decompress_calls=[1-9][0-9]*' "$work/dtrace.out"
|
||||
truss -o "$work/read.truss" "$work/read_probe" expect-error \
|
||||
"$work/mnt/compressed.bin" 5 | tee "$work/error.out"
|
||||
grep -q 'expected_errno=5' "$work/error.out"
|
||||
grep -E 'read.*ERR#5' "$work/read.truss"
|
||||
cmp "$work/fixtures/source/control.txt" "$work/mnt/control.txt"
|
||||
umount "$work/mnt"
|
||||
mdconfig -d -u "${unit#md}"
|
||||
kldunload dtraceall
|
||||
```
|
||||
|
||||
## Expected Results
|
||||
|
||||
Mount succeeds, proving media-size validation passed. FBT records at least one
|
||||
`z_erofs_decompress` entry for the target command, and the target read returns
|
||||
errno 5 (`EIO`). Control data remains readable and cleanup is complete.
|
||||
Reference in New Issue
Block a user