Richard W.M. Jones
2018-Nov-14 18:29 UTC
[Libguestfs] [PATCH v2] test-data: Allow tests to be run when Btrfs is not available.
v2: - Moved the btrfs available test into the subclause where it is used. Note I got tired of fighting emacs indentation mode and I pushed a whitespace only patch which fixes the indentation to be 4 spaces instead of 2 spaces: https://github.com/libguestfs/libguestfs/commit/df54c75d4c53ed580e5269306e11e0758d169452 This v2 patch requires that one. Rich.
Richard W.M. Jones
2018-Nov-14 18:29 UTC
[Libguestfs] [PATCH v2] 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 | 52 +++++++++++++++-------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/test-data/phony-guests/make-fedora-img.pl b/test-data/phony-guests/make-fedora-img.pl index 9eb0dc2ad..4ba49b0ca 100755 --- a/test-data/phony-guests/make-fedora-img.pl +++ b/test-data/phony-guests/make-fedora-img.pl @@ -123,34 +123,52 @@ EOF } elsif ($ENV{LAYOUT} eq 'btrfs') { - push (@images, "fedora-btrfs.img-t"); + # 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 (); - open (my $fstab, '>', "fedora.fstab") or die; - print $fstab <<EOF; + 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; + print $fstab <<EOF; LABEL=BOOT /boot ext2 default 0 0 LABEL=ROOT / btrfs subvol=root 0 0 LABEL=ROOT /home btrfs subvol=home 0 0 EOF - close ($fstab) or die; + close ($fstab) or die; - $bootdev = '/dev/sda1'; + $bootdev = '/dev/sda1'; - $g->disk_create ("fedora-btrfs.img-t", "raw", $IMAGE_SIZE); + $g->disk_create ("fedora-btrfs.img-t", "raw", $IMAGE_SIZE); - $g->add_drive ("fedora-btrfs.img-t", format => "raw"); - $g->launch (); + $g->add_drive ("fedora-btrfs.img-t", format => "raw"); + $g->launch (); - $g->part_init ('/dev/sda', 'mbr'); - $g->part_add ('/dev/sda', 'p', 64, 524287); - $g->part_add ('/dev/sda', 'p', 524288, -64); + $g->part_init ('/dev/sda', 'mbr'); + $g->part_add ('/dev/sda', 'p', 64, 524287); + $g->part_add ('/dev/sda', 'p', 524288, -64); - $g->mkfs_btrfs (['/dev/sda2'], label => 'ROOT'); - $g->mount ('/dev/sda2', '/'); - $g->btrfs_subvolume_create ('/root'); - $g->btrfs_subvolume_create ('/home'); - $g->umount ('/'); + $g->mkfs_btrfs (['/dev/sda2'], label => 'ROOT'); + $g->mount ('/dev/sda2', '/'); + $g->btrfs_subvolume_create ('/root'); + $g->btrfs_subvolume_create ('/home'); + $g->umount ('/'); - $g->mount ('btrfsvol:/dev/sda2/root', '/'); + $g->mount ('btrfsvol:/dev/sda2/root', '/'); + } } elsif ($ENV{LAYOUT} eq 'lvm-luks') { -- 2.19.0.rc0
Pino Toscano
2018-Nov-20 15:37 UTC
Re: [Libguestfs] [PATCH v2] test-data: Allow tests to be run when Btrfs is not available.
On Wednesday, 14 November 2018 19:29:14 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. > ---LGTM. Thanks, -- Pino Toscano
Apparently Analagous Threads
- [PATCH] Fix make-fedora-img for btrfs minimum size
- [PATCH v2] test-data: Allow tests to be run when Btrfs is not available.
- Remaining btrfs patches
- [PATCH 0/8] Add MD inspection support to libguestfs
- [PATCH] test-data: Allow tests to be run when Btrfs is not available.