[Libguestfs] [PATCH v2] sparsify: Fix test-virt-sparsify-in-place-fstrim-unsupported.sh

Richard W.M. Jones rjones at redhat.com
Fri Sep 21 12:34:44 UTC 2018


Since Linux commit f663b5b38fff trimming vfat is now supported by
Linux.  This broke the test which assumed it was not supported.  Use
another filesystem (minix) which does not support trimming instead.

Thanks: Daniel P. Berrangé and Pino Toscano.
---
 ...est-virt-sparsify-in-place-fstrim-unsupported.sh | 13 ++++++-------
 tests/test-functions.sh                             | 10 ++++++++++
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/sparsify/test-virt-sparsify-in-place-fstrim-unsupported.sh b/sparsify/test-virt-sparsify-in-place-fstrim-unsupported.sh
index ff7dab3fa..e5afab682 100755
--- a/sparsify/test-virt-sparsify-in-place-fstrim-unsupported.sh
+++ b/sparsify/test-virt-sparsify-in-place-fstrim-unsupported.sh
@@ -21,13 +21,11 @@
 #
 # https://bugzilla.redhat.com/show_bug.cgi?id=1364347
 #
-# This test assumes that the kernel vfat driver does not support
+# This test assumes that the kernel minix driver does not support
 # fstrim.  It might become supported in a future kernel version in
 # which case we could use a different filesystem for this test, or
 # delete the test if we are confident that all common filesystems are
 # supported.
-#
-# The reason why vfat is significant is because UEFI guests use it.
 
 set -e
 set -x
@@ -36,13 +34,14 @@ $TEST_FUNCTIONS
 skip_if_skipped
 # UML does not support discard.
 skip_if_backend uml
+skip_unless_filesystem_available minix
 
 img=test-virt-sparsify-in-place-fstrim-unsupported.img
 log=test-virt-sparsify-in-place-fstrim-unsupported.log
 rm -f $img $log
 
-# Create a test filesystem with a single vfat filesystem.
-guestfish -N $img=fs:vfat exit
+# Create a test filesystem with a single minix filesystem.
+guestfish -N $img=fs:minix exit
 
 # This should warn.
 virt-sparsify --in-place $img |& tee $log
@@ -58,8 +57,8 @@ if grep "warning:.*fstrim.*not supported" $log; then
     exit 1
 fi
 
-# Create a test filesystem with vfat and ext4 filesystems.
-guestfish -N $img=bootroot:vfat:ext4 exit
+# Create a test filesystem with minix and ext4 filesystems.
+guestfish -N $img=bootroot:minix:ext4 exit
 
 # This should warn.
 virt-sparsify --in-place $img |& tee $log
diff --git a/tests/test-functions.sh b/tests/test-functions.sh
index 22beaf99c..a0bad16fa 100755
--- a/tests/test-functions.sh
+++ b/tests/test-functions.sh
@@ -198,6 +198,16 @@ skip_unless_feature_available ()
     fi
 }
 
+# Skip if a filesystem is unavailable in the daemon.
+skip_unless_filesystem_available ()
+{
+    r="$(guestfish -a /dev/null run : filesystem_available "$1")"
+    if [ "$r" != "true" ] ; then
+        echo "$(basename $0): test skipped because $1 filesystem is not available"
+        exit 77
+    fi
+}
+
 # Skip unless the libvirt minimum version is met.
 skip_unless_libvirt_minimum_version ()
 {
-- 
2.18.0




More information about the Libguestfs mailing list