For that, add autofoo machinery to generate the iso out of the fake
virtio-win drivers introduced in the previous patches, and pass the
resulting image in $VIRTIO_WIN to v2v in a new test otherwise similar to
test-v2v-windows-conversion.sh.
Signed-off-by: Roman Kagan <rkagan(a)virtuozzo.com>
---
Makefile.am | 1 +
configure.ac | 1 +
tests/fake-virtio-win/.gitignore | 1 +
tests/fake-virtio-win/Makefile.am | 34 ++++++++++++++
v2v/Makefile.am | 1 +
v2v/test-v2v-virtio-win-iso.sh | 96 +++++++++++++++++++++++++++++++++++++++
6 files changed, 134 insertions(+)
create mode 100644 tests/fake-virtio-win/.gitignore
create mode 100644 tests/fake-virtio-win/Makefile.am
create mode 100755 v2v/test-v2v-virtio-win-iso.sh
diff --git a/Makefile.am b/Makefile.am
index dae7f7b..21acba7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -40,6 +40,7 @@ endif
if ENABLE_APPLIANCE
SUBDIRS += tests/qemu
SUBDIRS += tests/guests
+SUBDIRS += tests/fake-virtio-win
SUBDIRS += tests/c-api
SUBDIRS += tests/tmpdirs
SUBDIRS += tests/protocol
diff --git a/configure.ac b/configure.ac
index 2e8d868..294805e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1798,6 +1798,7 @@ AC_CONFIG_FILES([Makefile
tests/disks/test-qemu-drive-libvirt.xml
tests/disk-labels/Makefile
tests/events/Makefile
+ tests/fake-virtio-win/Makefile
tests/fuzz/Makefile
tests/guests/Makefile
tests/guests/guests.xml
diff --git a/tests/fake-virtio-win/.gitignore b/tests/fake-virtio-win/.gitignore
new file mode 100644
index 0000000..11011ce
--- /dev/null
+++ b/tests/fake-virtio-win/.gitignore
@@ -0,0 +1 @@
+/fake-virtio-win.iso
diff --git a/tests/fake-virtio-win/Makefile.am b/tests/fake-virtio-win/Makefile.am
new file mode 100644
index 0000000..c6fa67d
--- /dev/null
+++ b/tests/fake-virtio-win/Makefile.am
@@ -0,0 +1,34 @@
+# fake virtio-win drivers to test copying on v2v
+# Copyright (C) 2009-2015 Red Hat Inc.
+# Copyright (C) 2015 Parallels IP Holdings GmbH.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+include $(top_srcdir)/subdir-rules.mk
+
+drv_files = \
+ $(wildcard */*/*/*.cat) \
+ $(wildcard */*/*/*.inf) \
+ $(wildcard */*/*/*.sys)
+
+fake_virtio_win_iso = fake-virtio-win.iso
+
+check_DATA = $(fake_virtio_win_iso)
+
+CLEANFILES = $(fake_virtio_win_iso)
+
+$(fake_virtio_win_iso): $(drv_files)
+ $(GENISOIMAGE) -J -r -o $@ -graft-points \
+ $$(for f in $^; do echo $$f=$$f; done)
diff --git a/v2v/Makefile.am b/v2v/Makefile.am
index 5f2a0ee..7811e2a 100644
--- a/v2v/Makefile.am
+++ b/v2v/Makefile.am
@@ -249,6 +249,7 @@ TESTS += \
test-v2v-on-option.sh \
test-v2v-print-source.sh \
test-v2v-sound.sh \
+ test-v2v-virtio-win-iso.sh \
test-v2v-windows-conversion.sh
endif ENABLE_APPLIANCE
diff --git a/v2v/test-v2v-virtio-win-iso.sh b/v2v/test-v2v-virtio-win-iso.sh
new file mode 100755
index 0000000..7394a9a
--- /dev/null
+++ b/v2v/test-v2v-virtio-win-iso.sh
@@ -0,0 +1,96 @@
+#!/bin/bash -
+# libguestfs virt-v2v test script
+# Copyright (C) 2014 Red Hat Inc.
+# Copyright (C) 2015 Parallels IP Holdings GmbH.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+# Test virt-v2v Windows conversion with VirtIO drivers on an ISO image.
+
+unset CDPATH
+export LANG=C
+set -e
+
+if [ -n "$SKIP_TEST_V2V_VIRTIO_WIN_ISO_SH" ]; then
+ echo "$0: test skipped because environment variable is set"
+ exit 77
+fi
+
+if [ "$(guestfish get-backend)" = "uml" ]; then
+ echo "$0: test skipped because UML backend does not support network"
+ exit 77
+fi
+
+abs_top_builddir="$(cd ..; pwd)"
+libvirt_uri="test://$abs_top_builddir/tests/guests/guests.xml"
+
+f=../tests/guests/windows.img
+if ! test -f $f || ! test -s $f; then
+ echo "$0: test skipped because phony Windows image was not created"
+ exit 77
+fi
+
+export VIRT_TOOLS_DATA_DIR="$abs_top_builddir/tests/fake-virt-tools"
+export
VIRTIO_WIN="$abs_top_builddir/tests/fake-virtio-win/fake-virtio-win.iso"
+
+if ! test -f "$VIRTIO_WIN"; then
+ echo "$0: test skipped because fake virtio-win iso image was not created"
+ exit 77
+fi
+
+# Return a random element from the array 'choices'.
+function random_choice
+{
+ echo "${choices[$((RANDOM % ${#choices[*]}))]}"
+}
+
+# Test the --root option stochastically.
+choices=("/dev/sda2" "single" "first")
+root=`random_choice`
+
+d=test-v2v-virtio-win-iso.d
+rm -rf $d
+mkdir $d
+
+$VG virt-v2v --debug-gc \
+ -i libvirt -ic "$libvirt_uri" windows \
+ -o local -os $d \
+ --root $root
+
+# Test the libvirt XML metadata and a disk was created.
+test -f $d/windows.xml
+test -f $d/windows-sda
+
+# Test that the drivers have been copied over into the guest
+virtio_dir="/Windows/Drivers/VirtIO"
+{
+ echo "trace 1"
+ echo "is-dir \"$virtio_dir\""
+ for drv in netkvm qxl vioscsi viostor; do
+ for sfx in cat inf sys; do
+ echo "is-file \"$virtio_dir/$drv.$sfx\""
+ done
+ done
+ echo "trace 0"
+} | guestfish --ro -a $d/windows-sda -i | {
+ ret=0
+ while read r; do
+ [ "$r" = "true" ] || ret=1
+ done
+ exit $ret
+}
+(( PIPESTATUS[1] == 0 ))
+
+rm -r $d
--
2.4.3