64 lines
2.2 KiB
Markdown
64 lines
2.2 KiB
Markdown
# Test Case: Corrupted Superblock Fields
|
|
|
|
**Test ID**: TC015-superblock-corrupted
|
|
**Category**: Error Handling
|
|
**Priority**: High
|
|
|
|
## Objective
|
|
|
|
Verify ordered rejection of an unsupported block size, an image-bounds-invalid
|
|
48-bit root NID, and an unknown incompat feature. Every variant preserves
|
|
provider length and carries a checksum valid for its encoded fields.
|
|
|
|
## Fixture Qualification
|
|
|
|
```sh
|
|
work=$(mktemp -d /tmp/repo22-tc015.XXXXXX)
|
|
tests/prepare_error_fixtures.sh "$work/fixtures"
|
|
grep -E '^(bad-block-size|bad-root-nid|unsupported-feature) ' \
|
|
"$work/fixtures/fixture-evidence.txt"
|
|
python3 tests/erofs_fixture.py inspect "$work/fixtures/bad-block-size.erofs"
|
|
python3 tests/erofs_fixture.py inspect "$work/fixtures/bad-root-nid.erofs"
|
|
python3 tests/erofs_fixture.py inspect "$work/fixtures/unsupported-feature.erofs"
|
|
(cd "$work/fixtures" && sha256 -c SHA256SUMS)
|
|
```
|
|
|
|
`bad-block-size` changes `blkszbits` at 1036 from 12 to 13 and recomputes the
|
|
checksum over `[1024,8192)`. `bad-root-nid` selects the 48-bit union form and
|
|
sets `rootnid_8b` beyond the declared inode area. `unsupported-feature` sets
|
|
unknown incompat bit `0x80000000`.
|
|
|
|
## FreeBSD Procedure
|
|
|
|
For each image, attach a dynamic vnode md unit, run mount directly and under
|
|
`truss`, assert nonzero status and no mount entry, then detach that exact unit.
|
|
|
|
```sh
|
|
mkdir "$work/mnt"
|
|
for image in bad-block-size.erofs bad-root-nid.erofs unsupported-feature.erofs
|
|
do
|
|
unit=$(mdconfig -a -t vnode -f "$work/fixtures/$image")
|
|
set +e
|
|
mount -t erofs -o ro "/dev/$unit" "$work/mnt" \
|
|
>"$work/$image.out" 2>"$work/$image.err"
|
|
status=$?
|
|
set -e
|
|
printf '%s status=%s\n' "$image" "$status"
|
|
test "$status" -ne 0
|
|
set +e
|
|
truss -o "$work/$image.truss" mount -t erofs -o ro "/dev/$unit" \
|
|
"$work/mnt" >/dev/null 2>&1
|
|
set -e
|
|
grep -E 'nmount.*ERR#' "$work/$image.truss"
|
|
! mount -p | awk -v path="$work/mnt" '$2 == path { found=1 }
|
|
END { exit found ? 0 : 1 }'
|
|
mdconfig -d -u "${unit#md}"
|
|
done
|
|
```
|
|
|
|
## Expected Results
|
|
|
|
Bad block size returns `EINVAL`, bad root NID returns `EINTEGRITY`, and the
|
|
unknown incompat bit returns `EOPNOTSUPP`. Record syscall errno, image hash,
|
|
provider length, new dmesg lines, and cleanup for all three subcases.
|