test-data: Allow tests to be run when Btrfs is not available.

Create the fedora-btrfs.img as an empty file.

The only place this is used explicitly is tests/mountable/
test-mountable-inspect.sh, but that test already skips if !btrfs.

Also this is used via guests-all-good.xml, but the script that creates
this XML skips the file if it has zero size.
This commit is contained in:
Richard W.M. Jones
2018-11-14 15:47:24 +00:00
parent fe9988eff8
commit ed3ff51df9

View File

@@ -123,6 +123,23 @@ EOF
}
elsif ($ENV{LAYOUT} eq 'btrfs') {
# Test if btrfs is available.
my $g2 = Sys::Guestfs->new ();
$g2->add_drive ("/dev/null");
$g2->launch ();
my $btrfs_available = $g2->feature_available (["btrfs"]);
$g2->close ();
if (!$btrfs_available) {
# Btrfs not available, create an empty image.
push (@images, "fedora-btrfs.img");
unlink ("fedora-btrfs.img");
open (my $img, '>', "fedora-btrfs.img");
close ($img) or die;
exit 0;
}
else {
push (@images, "fedora-btrfs.img-t");
open (my $fstab, '>', "fedora.fstab") or die;
@@ -151,6 +168,7 @@ EOF
$g->umount ('/');
$g->mount ('btrfsvol:/dev/sda2/root', '/');
}
}
elsif ($ENV{LAYOUT} eq 'lvm-luks') {