2.6 KiB
Test Case: Mount Error Conditions
Test ID: TC008-mount-errors Category: Mount Operations Priority: High
Objective
Verify graceful rejection of three distinct provider conditions: a checksum-valid bad magic at the correct field, a 1023-byte provider ending before the superblock, and a zero-length provider.
Fixture Qualification
work=$(mktemp -d /tmp/repo22-tc008.XXXXXX)
tests/prepare_error_fixtures.sh "$work/fixtures"
grep -E '^(bad-magic|truncated-before-super|empty-provider) ' \
"$work/fixtures/fixture-evidence.txt"
python3 tests/erofs_fixture.py inspect "$work/fixtures/bad-magic.erofs"
wc -c "$work/fixtures/bad-magic.erofs" \
"$work/fixtures/truncated-before-super.erofs" \
"$work/fixtures/empty-provider.erofs"
(cd "$work/fixtures" && sha256 -c SHA256SUMS)
The bad-magic variant changes only absolute bytes 1024 through 1027 and preserves media size. It intentionally retains the original checksum: the production verifier's fixed-magic suffix calculation remains valid, while the canonical checksum over the now-invalid magic does not. Magic is rejected before checksum verification. The short and empty fixtures are intentional provider-size cases, not same-size corruption variants.
FreeBSD Procedure
Create a fresh mount directory. Execute each case separately and record whether
failure occurs at mdconfig or nmount; never assume a fixed md number.
mkdir "$work/mnt"
for image in bad-magic.erofs truncated-before-super.erofs empty-provider.erofs
do
set +e
unit=$(mdconfig -a -t vnode -f "$work/fixtures/$image" \
2>"$work/$image.md.err")
md_status=$?
set -e
printf '%s md_status=%s unit=%s\n' "$image" "$md_status" "$unit"
if test "$md_status" -eq 0; then
set +e
mount -t erofs -o ro "/dev/$unit" "$work/mnt" \
>"$work/$image.out" 2>"$work/$image.mount.err"
mount_status=$?
set -e
printf '%s mount_status=%s\n' "$image" "$mount_status"
test "$mount_status" -ne 0
set +e
truss -o "$work/$image.mount.truss" mount -t erofs -o ro \
"/dev/$unit" "$work/mnt" >/dev/null 2>&1
set -e
grep -E 'nmount.*ERR#' "$work/$image.mount.truss"
mdconfig -d -u "${unit#md}"
else
cat "$work/$image.md.err"
fi
! mount -p | awk -v path="$work/mnt" '$2 == path { found=1 }
END { exit found ? 0 : 1 }'
done
Expected Results
All three cases fail without panic or hang. Bad magic reaches nmount and
returns EINVAL. A 1023-byte vnode provider reaches nmount and returns
ENXIO; a zero-byte provider is rejected by mdconfig with EINVAL. Record
the observed stage and errno rather than fabricating a mount result. No md unit
or mount may remain after each case.