Richard W.M. Jones
2018-Nov-14 16:08 UTC
[Libguestfs] [PATCH] 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. --- 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
Pino Toscano
2018-Nov-14 17:37 UTC
Re: [Libguestfs] [PATCH] test-data: Allow tests to be run when Btrfs is not available.
On Wednesday, 14 November 2018 17:08:40 CET Richard W.M. Jones wrote:> 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 ();I'd delay this ...> + > +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) {... here: all the other layouts do not need to know whether btrfs is available, and doing all the checks in a single place means not duplicate the check of the layout name.> + # 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; >-- Pino Toscano
Seemingly Similar Threads
- [PATCH v2] test-data: Allow tests to be run when Btrfs is not available.
- [PATCH v2] test-data: Allow tests to be run when Btrfs is not available.
- [PATCH v2 0/4] New API: lvm_scan, deprecate vgscan (RHBZ#1602353).
- [PATCH 0/3] New API: lvm_scan, deprecate vgscan (RHBZ#1602353).
- [PATCH 0/2] Support for expanding f2fs partitions