[Libguestfs] [PATCH] test-data: Allow tests to be run when Btrfs is not available.

Richard W.M. Jones rjones at redhat.com
Wed Nov 14 16:08:40 UTC 2018


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.
---
 test-data/phony-guests/make-fedora-img.pl | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/test-data/phony-guests/make-fedora-img.pl b/test-data/phony-guests/make-fedora-img.pl
index c665f0d19..739a229da 100755
--- a/test-data/phony-guests/make-fedora-img.pl
+++ b/test-data/phony-guests/make-fedora-img.pl
@@ -39,8 +39,15 @@ my @PARTITIONS = (
     # 32k blank space
 );
 
-my @images;
+# Test features.
 my $g = Sys::Guestfs->new ();
+$g->add_drive ("/dev/null");
+$g->launch ();
+my $btrfs_available = $g->feature_available (["btrfs"]);
+$g->close ();
+
+my @images;
+$g = Sys::Guestfs->new ();
 
 my $bootdev;
 
@@ -122,7 +129,17 @@ EOF
   init_lvm_root ('/dev/md/rootdev');
 }
 
-elsif ($ENV{LAYOUT} eq 'btrfs') {
+elsif ($ENV{LAYOUT} eq 'btrfs' && !$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;
+}
+
+elsif ($ENV{LAYOUT} eq 'btrfs' && $btrfs_available) {
   push (@images, "fedora-btrfs.img-t");
 
   open (my $fstab, '>', "fedora.fstab") or die;
-- 
2.19.0.rc0




More information about the Libguestfs mailing list