Blame SOURCES/0169-sparsify-Add-a-regression-test-for-RHBZ-1364347.patch

e76f14
From 0772a6866796bced2d4694e40ad87b8b8f6be902 Mon Sep 17 00:00:00 2001
e76f14
From: "Richard W.M. Jones" <rjones@redhat.com>
e76f14
Date: Fri, 5 Aug 2016 12:20:49 +0100
e76f14
Subject: [PATCH] sparsify: Add a regression test for RHBZ#1364347.
e76f14
e76f14
Add a regression test for the previous commit.
e76f14
e76f14
(cherry picked from commit 71de3d49a395b4b91d282ad01bb2d382060c8392)
e76f14
e76f14
Conflicts:
e76f14
	sparsify/Makefile.am
e76f14
---
e76f14
 sparsify/Makefile.am                               |  7 +-
e76f14
 ...st-virt-sparsify-in-place-fstrim-unsupported.sh | 84 ++++++++++++++++++++++
e76f14
 2 files changed, 89 insertions(+), 2 deletions(-)
e76f14
 create mode 100755 sparsify/test-virt-sparsify-in-place-fstrim-unsupported.sh
e76f14
e76f14
diff --git a/sparsify/Makefile.am b/sparsify/Makefile.am
e76f14
index 22a684b..61f28bc 100644
e76f14
--- a/sparsify/Makefile.am
e76f14
+++ b/sparsify/Makefile.am
e76f14
@@ -21,7 +21,9 @@ EXTRA_DIST = \
e76f14
 	$(SOURCES_MLI) $(SOURCES_ML) $(SOURCES_C) \
e76f14
 	virt-sparsify.pod \
e76f14
 	test-virt-sparsify.sh \
e76f14
-	test-virt-sparsify-in-place.sh
e76f14
+	test-virt-sparsify-in-place.sh \
e76f14
+	test-virt-sparsify-in-place-fstrim-unsupported.sh \
e76f14
+	virt-sparsify.pod
e76f14
 
e76f14
 CLEANFILES = *~ *.annot *.cmi *.cmo *.cmx *.cmxa *.o virt-sparsify
e76f14
 
e76f14
@@ -128,7 +130,8 @@ TESTS_ENVIRONMENT = $(top_builddir)/run --test
e76f14
 if ENABLE_APPLIANCE
e76f14
 TESTS = \
e76f14
 	test-virt-sparsify.sh \
e76f14
-	test-virt-sparsify-in-place.sh
e76f14
+	test-virt-sparsify-in-place.sh \
e76f14
+	test-virt-sparsify-in-place-fstrim-unsupported.sh
e76f14
 endif ENABLE_APPLIANCE
e76f14
 
e76f14
 check-valgrind:
e76f14
diff --git a/sparsify/test-virt-sparsify-in-place-fstrim-unsupported.sh b/sparsify/test-virt-sparsify-in-place-fstrim-unsupported.sh
e76f14
new file mode 100755
e76f14
index 0000000..d6a300d
e76f14
--- /dev/null
e76f14
+++ b/sparsify/test-virt-sparsify-in-place-fstrim-unsupported.sh
e76f14
@@ -0,0 +1,84 @@
e76f14
+#!/bin/bash -
e76f14
+# libguestfs virt-sparsify --in-place test script
e76f14
+# Copyright (C) 2011-2016 Red Hat Inc.
e76f14
+#
e76f14
+# This program is free software; you can redistribute it and/or modify
e76f14
+# it under the terms of the GNU General Public License as published by
e76f14
+# the Free Software Foundation; either version 2 of the License, or
e76f14
+# (at your option) any later version.
e76f14
+#
e76f14
+# This program is distributed in the hope that it will be useful,
e76f14
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
e76f14
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
e76f14
+# GNU General Public License for more details.
e76f14
+#
e76f14
+# You should have received a copy of the GNU General Public License
e76f14
+# along with this program; if not, write to the Free Software
e76f14
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
e76f14
+
e76f14
+# Test that we do the right thing for filesystems where the fstrim
e76f14
+# operation is not supported.
e76f14
+#
e76f14
+# https://bugzilla.redhat.com/show_bug.cgi?id=1364347
e76f14
+#
e76f14
+# This test assumes that the kernel vfat driver does not support
e76f14
+# fstrim.  It might become supported in a future kernel version in
e76f14
+# which case we could use a different filesystem for this test, or
e76f14
+# delete the test if we are confident that all common filesystems are
e76f14
+# supported.
e76f14
+#
e76f14
+# The reason why vfat is significant is because UEFI guests use it.
e76f14
+
e76f14
+export LANG=C
e76f14
+set -e
e76f14
+set -x
e76f14
+
e76f14
+if [ -n "$SKIP_TEST_VIRT_SPARSIFY_IN_PLACE_FSTRIM_UNSUPPORTED_SH" ]; then
e76f14
+    echo "$0: skipping test (environment variable set)"
e76f14
+    exit 77
e76f14
+fi
e76f14
+
e76f14
+if [ "$(guestfish get-backend)" = "uml" ]; then
e76f14
+    echo "$0: skipping test because uml backend does not support discard"
e76f14
+    exit 77
e76f14
+fi
e76f14
+
e76f14
+img=test-virt-sparsify-in-place-fstrim-unsupported.img
e76f14
+log=test-virt-sparsify-in-place-fstrim-unsupported.log
e76f14
+rm -f $img $log
e76f14
+
e76f14
+# Create a test filesystem with a single vfat filesystem.
e76f14
+guestfish -N $img=fs:vfat exit
e76f14
+
e76f14
+# This should warn.
e76f14
+virt-sparsify --in-place $img |& tee $log
e76f14
+
e76f14
+# Check the warning was emitted.
e76f14
+grep "warning:.*fstrim" $log
e76f14
+
e76f14
+# This should ignore the filesystem and not warn.
e76f14
+virt-sparsify --in-place --ignore /dev/sda1 $img |& tee $log
e76f14
+
e76f14
+if grep "warning:.*fstrim.*not supported" $log; then
e76f14
+    echo "$0: filesystem /dev/sda1 was not ignored"
e76f14
+    exit 1
e76f14
+fi
e76f14
+
e76f14
+# Create a test filesystem with vfat and ext4 filesystems.
e76f14
+guestfish -N $img=bootroot:vfat:ext4 exit
e76f14
+
e76f14
+# This should warn.
e76f14
+virt-sparsify --in-place $img |& tee $log
e76f14
+
e76f14
+# Check the warning was emitted.
e76f14
+grep "warning:.*fstrim" $log
e76f14
+
e76f14
+# This should ignore the filesystem and not warn.
e76f14
+virt-sparsify --in-place --ignore /dev/sda1 $img |& tee $log
e76f14
+
e76f14
+if grep "warning:.*fstrim.*not supported" $log; then
e76f14
+    echo "$0: filesystem /dev/sda1 was not ignored"
e76f14
+    exit 1
e76f14
+fi
e76f14
+
e76f14
+rm $img $log
e76f14
-- 
e76f14
1.8.3.1
e76f14