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

Pino Toscano ptoscano at redhat.com
Wed Nov 14 17:37:33 UTC 2018


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20181114/a8ddfcf2/attachment.sig>


More information about the Libguestfs mailing list