btrfs-progs: tests: use force when decompressing images

Some tests report that decompressing the image failed, which did not
fail the test but could lead to wrong errors in case the image is not
overwritten and leaves some old state. Use --force parameter.

    [TEST]   fuzz-tests.sh
    [TEST/fuzz]   001-simple-check-unmounted
xz: btrfs-progs/tests/fuzz-tests/images/bko-97021-invalid-chunk-sectorsize.raw: File exists
failed to decompress image btrfs-progs/tests/fuzz-tests/images/bko-97021-invalid-chunk-sectorsize.raw.xz
    [TEST/fuzz]   002-simple-image
xz: btrfs-progs/tests/fuzz-tests/images/bko-97021-invalid-chunk-sectorsize.raw: File exists
failed to decompress image btrfs-progs/tests/fuzz-tests/images/bko-97021-invalid-chunk-sectorsize.raw.xz

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2021-03-01 13:22:06 +01:00
parent 464e73ff0d
commit 06bf4d0e8b

View File

@ -449,23 +449,23 @@ extract_image()
rm -f "$image.restored"
;;
*.img.xz)
xz --decompress --keep "$image" || \
xz --decompress --keep --force "$image" || \
_fail "failed to decompress image $image" >&2
image=${image%%.xz}
rm -f "$image.restored"
cleanme=$image
;;
*.raw)
cp --sparse=auto "$image" "$image.restored"
cp --sparse=auto --force "$image" "$image.restored"
;;
*.raw.xz)
xz --decompress --keep "$image" || \
xz --decompress --keep --force "$image" || \
_fail "failed to decompress image $image" >&2
image=${image%%.xz}
mv "$image" "$image.restored"
;;
*.stream.xz)
xz --decompress --keep "$image" || \
xz --decompress --keep --force "$image" || \
_fail "failed to decompress file $image" >&2
image=${image%%.xz}
mv "$image" "$image.restored"