Blame SOURCES/0020-tests-Add-a-simple-test-of-o-local-of-qcow2-oo-compr.patch

c1a9fa
From 672b9795e85b48f337b3da2d6fa393e7788d79a1 Mon Sep 17 00:00:00 2001
c1a9fa
From: "Richard W.M. Jones" <rjones@redhat.com>
c1a9fa
Date: Fri, 1 Jul 2022 11:18:53 +0100
c1a9fa
Subject: [PATCH] tests: Add a simple test of -o local -of qcow2 -oo compressed
c1a9fa
c1a9fa
This only tests that it doesn't completely fail, which it did before
c1a9fa
we fixed nbdcopy.  I checked the file sizes manually and with
c1a9fa
compression the resulting file is about half the size.
c1a9fa
c1a9fa
This test is a clone of tests/test-v2v-of-option.sh.  In order to
c1a9fa
compare the sizes across the two tests, and to keep the tests fairly
c1a9fa
similar I added an ls -l command to the original test.
c1a9fa
c1a9fa
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
c1a9fa
(cherry picked from commit 7505750972b49e1a448c519a27998bd5f20be60a)
c1a9fa
---
c1a9fa
 tests/Makefile.am                          |  2 +
c1a9fa
 tests/test-v2v-o-local-qcow2-compressed.sh | 53 ++++++++++++++++++++++
c1a9fa
 tests/test-v2v-of-option.sh                |  2 +
c1a9fa
 3 files changed, 57 insertions(+)
c1a9fa
 create mode 100755 tests/test-v2v-o-local-qcow2-compressed.sh
c1a9fa
c1a9fa
diff --git a/tests/Makefile.am b/tests/Makefile.am
c1a9fa
index e787a86c..a26ecf7a 100644
c1a9fa
--- a/tests/Makefile.am
c1a9fa
+++ b/tests/Makefile.am
c1a9fa
@@ -82,6 +82,7 @@ TESTS = \
c1a9fa
 	test-v2v-networks-and-bridges.sh \
c1a9fa
 	test-v2v-o-glance.sh \
c1a9fa
 	test-v2v-o-libvirt.sh \
c1a9fa
+	test-v2v-o-local-qcow2-compressed.sh \
c1a9fa
 	test-v2v-o-null.sh \
c1a9fa
 	test-v2v-o-openstack.sh \
c1a9fa
 	test-v2v-o-qemu.sh \
c1a9fa
@@ -241,6 +242,7 @@ EXTRA_DIST += \
c1a9fa
 	test-v2v-networks-and-bridges-expected.xml \
c1a9fa
 	test-v2v-o-glance.sh \
c1a9fa
 	test-v2v-o-libvirt.sh \
c1a9fa
+	test-v2v-o-local-qcow2-compressed.sh \
c1a9fa
 	test-v2v-o-null.sh \
c1a9fa
 	test-v2v-o-openstack.sh \
c1a9fa
 	test-v2v-o-qemu.sh \
c1a9fa
diff --git a/tests/test-v2v-o-local-qcow2-compressed.sh b/tests/test-v2v-o-local-qcow2-compressed.sh
c1a9fa
new file mode 100755
c1a9fa
index 00000000..32c9ebbe
c1a9fa
--- /dev/null
c1a9fa
+++ b/tests/test-v2v-o-local-qcow2-compressed.sh
c1a9fa
@@ -0,0 +1,53 @@
c1a9fa
+#!/bin/bash -
c1a9fa
+# libguestfs virt-v2v test script
c1a9fa
+# Copyright (C) 2014-2022 Red Hat Inc.
c1a9fa
+#
c1a9fa
+# This program is free software; you can redistribute it and/or modify
c1a9fa
+# it under the terms of the GNU General Public License as published by
c1a9fa
+# the Free Software Foundation; either version 2 of the License, or
c1a9fa
+# (at your option) any later version.
c1a9fa
+#
c1a9fa
+# This program is distributed in the hope that it will be useful,
c1a9fa
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
c1a9fa
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c1a9fa
+# GNU General Public License for more details.
c1a9fa
+#
c1a9fa
+# You should have received a copy of the GNU General Public License
c1a9fa
+# along with this program; if not, write to the Free Software
c1a9fa
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
c1a9fa
+
c1a9fa
+# Test -o local -of qcow2 -oo compressed.
c1a9fa
+
c1a9fa
+set -e
c1a9fa
+
c1a9fa
+source ./functions.sh
c1a9fa
+set -e
c1a9fa
+set -x
c1a9fa
+
c1a9fa
+skip_if_skipped
c1a9fa
+requires test -f ../test-data/phony-guests/windows.img
c1a9fa
+
c1a9fa
+# This requires fixed nbdcopy >= 1.13.5.
c1a9fa
+requires nbdcopy --version
c1a9fa
+nbdcopy --version | {
c1a9fa
+    IFS=' .' read name major minor release
c1a9fa
+    requires test \( "$major" -gt 1 \) -o \
c1a9fa
+                  \( "$major" -eq 1 -a "$minor" -gt 13 \) -o \
c1a9fa
+                  \( "$major" -eq 1 -a "$minor" -eq 13 -a "$release" -ge 5 \)
c1a9fa
+}
c1a9fa
+
c1a9fa
+export VIRT_TOOLS_DATA_DIR="$srcdir/../test-data/fake-virt-tools"
c1a9fa
+
c1a9fa
+d=test-v2v-o-local-qcow2-compressed.d
c1a9fa
+rm -rf $d
c1a9fa
+cleanup_fn rm -rf $d
c1a9fa
+mkdir $d
c1a9fa
+
c1a9fa
+$VG virt-v2v --debug-gc \
c1a9fa
+    -i disk ../test-data/phony-guests/windows.img \
c1a9fa
+    -o local -of qcow2 -oo compressed -os $d
c1a9fa
+
c1a9fa
+# Test the libvirt XML metadata and a disk was created.
c1a9fa
+ls -l $d
c1a9fa
+test -f $d/windows.xml
c1a9fa
+test -f $d/windows-sda
c1a9fa
diff --git a/tests/test-v2v-of-option.sh b/tests/test-v2v-of-option.sh
c1a9fa
index bdfd3418..6c5f5938 100755
c1a9fa
--- a/tests/test-v2v-of-option.sh
c1a9fa
+++ b/tests/test-v2v-of-option.sh
c1a9fa
@@ -42,6 +42,8 @@ $VG virt-v2v --debug-gc \
c1a9fa
     -i libvirt -ic "$libvirt_uri" windows \
c1a9fa
     -o local -os $d -of qcow2
c1a9fa
 
c1a9fa
+ls -l $d
c1a9fa
+
c1a9fa
 # Test the disk is qcow2 format.
c1a9fa
 if [ "$(guestfish disk-format $d/windows-sda)" != qcow2 ]; then
c1a9fa
     echo "$0: test failed: output is not qcow2"