[Pkg-libvirt-commits] [libguestfs] 92/266: v2v: Add tests.
Hilko Bengen
bengen at moszumanska.debian.org
Fri Oct 3 14:41:45 UTC 2014
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to annotated tag debian/1%1.27.35-1
in repository libguestfs.
commit ef10da8b3a62e3bf0df649f1e725e5150135b003
Author: Richard W.M. Jones <rjones at redhat.com>
Date: Wed Aug 13 12:17:57 2014 +0100
v2v: Add tests.
The virt-v2v tests here are not meant to be thorough tests of guest
conversion. There is a test suite used to test conversion which is
kept outside libguestfs because it contains lots of proprietary
unredistributable guests like Windows.
The tests here instead are testing:
- virt-v2v command line arguments
- virt-v2v reads and writes files to the correct places
- valgrind & memory leaks
- any conversion properties that can be tested using just the
phony guests (but we don't go out of our way here)
- that up to date guests don't crash virt-v2v
---
.gitignore | 6 +++
v2v/Makefile.am | 53 +++++++++++++++++++++++-
v2v/test-v2v-machine-readable.sh | 34 ++++++++++++++++
v2v/test-v2v-no-copy.sh | 75 ++++++++++++++++++++++++++++++++++
v2v/test-v2v-of-option.sh | 58 +++++++++++++++++++++++++++
v2v/test-v2v-on-option.sh | 56 ++++++++++++++++++++++++++
v2v/test-v2v-real-conversions.sh | 71 +++++++++++++++++++++++++++++++++
v2v/test-v2v-rhev-options.sh | 82 ++++++++++++++++++++++++++++++++++++++
v2v/test-v2v-rhev.sh | 72 +++++++++++++++++++++++++++++++++
v2v/test-v2v-windows-conversion.sh | 79 ++++++++++++++++++++++++++++++++++++
10 files changed, 585 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index a29cf6d..60c4217 100644
--- a/.gitignore
+++ b/.gitignore
@@ -545,7 +545,13 @@ Makefile.in
/test-tool/stamp-libguestfs-test-tool.pod
/tools/virt-*.1
/v2v/.depend
+/v2v/centos-6.img
+/v2v/centos-7.0.img
+/v2v/fedora-20.img
/v2v/link.sh
+/v2v/rhel-5.10.img
+/v2v/rhel-6.5.img
+/v2v/rhel-7.0.img
/v2v/stamp-virt-v2v.pod
/v2v/virt-v2v
/v2v/virt-v2v.1
diff --git a/v2v/Makefile.am b/v2v/Makefile.am
index 97d6d3e..2c1ce77 100644
--- a/v2v/Makefile.am
+++ b/v2v/Makefile.am
@@ -19,6 +19,7 @@ include $(top_srcdir)/subdir-rules.mk
EXTRA_DIST = \
$(SOURCES_MLI) $(SOURCES_ML) $(SOURCES_C) \
+ $(TESTS) $(SLOW_TESTS) \
virt-v2v.pod
CLEANFILES = *~ *.cmi *.cmo *.cmx *.cmxa *.o virt-v2v
@@ -154,15 +155,65 @@ CLEANFILES += stamp-virt-v2v.pod
# Tests.
+# The virt-v2v tests here are not meant to be thorough tests of guest
+# conversion. There is a test suite used to test conversion which is
+# kept outside libguestfs because it contains lots of proprietary
+# unredistributable guests like Windows.
+#
+# The tests here instead are testing:
+#
+# - virt-v2v command line arguments
+# - virt-v2v reads and writes files to the correct places
+# - valgrind & memory leaks
+# - any conversion properties that can be tested using just the
+# phony guests (but we don't go out of our way here)
+# - that up to date guests don't crash virt-v2v
+
TESTS_ENVIRONMENT = $(top_builddir)/run --test
if ENABLE_APPLIANCE
-TESTS =
+TESTS = \
+ test-v2v-machine-readable.sh \
+ test-v2v-no-copy.sh \
+ test-v2v-of-option.sh \
+ test-v2v-on-option.sh \
+ test-v2v-rhev.sh \
+ test-v2v-rhev-options.sh \
+ test-v2v-windows-conversion.sh
endif ENABLE_APPLIANCE
check-valgrind:
$(MAKE) VG="$(top_builddir)/run @VG@" check
+SLOW_TESTS = \
+ test-v2v-real-conversions.sh
+
+check-slow: $(real_guests:%=%.img)
+ $(MAKE) check TESTS="$(SLOW_TESTS)"
+
+# A selection of real guests that test-v2v-real-conversions.sh will
+# try to convert. This is only used by 'make check-slow'.
+
+real_guests = \
+ centos-6 \
+ centos-7.0 \
+ fedora-20 \
+ rhel-5.10 \
+ rhel-6.5 \
+ rhel-7.0
+
+$(real_guests:%=%.img):
+ rm -f $@
+ n=`basename $@ .img`; \
+ vb="$(top_builddir)/run $(top_builddir)/builder/virt-builder"; \
+ if $$vb --help >/dev/null && $$vb --notes $$n >/dev/null; then \
+ $$vb $$n; \
+ else \
+ touch $$n.img; \
+ fi
+
+CLEANFILES += $(real_guests:%=%.img)
+
# Dependencies.
depend: .depend
diff --git a/v2v/test-v2v-machine-readable.sh b/v2v/test-v2v-machine-readable.sh
new file mode 100755
index 0000000..5771d9e
--- /dev/null
+++ b/v2v/test-v2v-machine-readable.sh
@@ -0,0 +1,34 @@
+#!/bin/bash -
+# libguestfs virt-v2v test script
+# Copyright (C) 2014 Red Hat Inc.
+#
+# 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 --machine-readable option.
+
+unset CDPATH
+export LANG=C
+set -e
+
+if [ -n "$SKIP_TEST_V2V_MACHINE_READABLE_SH" ]; then
+ echo "$0: test skipped because environment variable is set"
+ exit 77
+fi
+
+$VG ./virt-v2v --debug-gc --machine-readable > test-v2v-machine-readable.out
+grep virt-v2v test-v2v-machine-readable.out
+grep libguestfs-rewrite test-v2v-machine-readable.out
+
+rm test-v2v-machine-readable.out
diff --git a/v2v/test-v2v-no-copy.sh b/v2v/test-v2v-no-copy.sh
new file mode 100755
index 0000000..ba2dc17
--- /dev/null
+++ b/v2v/test-v2v-no-copy.sh
@@ -0,0 +1,75 @@
+#!/bin/bash -
+# libguestfs virt-v2v test script
+# Copyright (C) 2014 Red Hat Inc.
+#
+# 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 --no-copy option.
+
+unset CDPATH
+export LANG=C
+set -e
+
+if [ -n "$SKIP_TEST_V2V_NO_COPY_SH" ]; then
+ echo "$0: test skipped because environment variable is set"
+ exit 77
+fi
+
+if [ "$(../fish/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-all-good.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
+
+d=test-v2v-no-copy.d
+rm -rf $d
+mkdir $d
+
+# No copy with -o local.
+$VG ./virt-v2v --debug-gc --no-copy \
+ -i libvirt -ic "$libvirt_uri" windows \
+ -o local -os $d
+
+# Test the libvirt XML metadata was created.
+test -f $d/windows.xml
+
+# Test the disk was NOT created.
+! test -f $d/windows-sda
+
+# --no-copy with -o rhev.
+mkdir $d/12345678-1234-1234-1234-123456789abc
+mkdir $d/12345678-1234-1234-1234-123456789abc/images
+mkdir $d/12345678-1234-1234-1234-123456789abc/master
+mkdir $d/12345678-1234-1234-1234-123456789abc/master/vms
+
+$VG ./virt-v2v --debug-gc --no-copy \
+ -i libvirt -ic "$libvirt_uri" windows \
+ -o rhev -os $d
+
+# Test the OVF metadata was created.
+test -f $d/12345678-1234-1234-1234-123456789abc/master/vms/*/*.ovf
+
+# Test the disk was NOT created.
+! test -f $d/12345678-1234-1234-1234-123456789abc/images/*/*.meta
+
+rm -r $d
diff --git a/v2v/test-v2v-of-option.sh b/v2v/test-v2v-of-option.sh
new file mode 100755
index 0000000..0335d52
--- /dev/null
+++ b/v2v/test-v2v-of-option.sh
@@ -0,0 +1,58 @@
+#!/bin/bash -
+# libguestfs virt-v2v test script
+# Copyright (C) 2014 Red Hat Inc.
+#
+# 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 -of (format conversion) option.
+
+unset CDPATH
+export LANG=C
+set -e
+
+if [ -n "$SKIP_TEST_V2V_OF_OPTION_SH" ]; then
+ echo "$0: test skipped because environment variable is set"
+ exit 77
+fi
+
+if [ "$(../fish/guestfish get-backend)" = "uml" ]; then
+ echo "$0: test skipped because UML backend does not support network or qcow2"
+ exit 77
+fi
+
+abs_top_builddir="$(cd ..; pwd)"
+libvirt_uri="test://$abs_top_builddir/tests/guests/guests-all-good.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
+
+d=test-v2v-windows-conversion.d
+rm -rf $d
+mkdir $d
+
+$VG ./virt-v2v --debug-gc \
+ -i libvirt -ic "$libvirt_uri" windows \
+ -o local -os $d -of qcow2
+
+# Test the disk is qcow2 format.
+if [ "$(../fish/guestfish disk-format $d/windows-sda)" != qcow2 ]; then
+ echo "$0: test failed: output is not qcow2"
+ exit 1
+fi
+
+rm -r $d
diff --git a/v2v/test-v2v-on-option.sh b/v2v/test-v2v-on-option.sh
new file mode 100755
index 0000000..0d3011e
--- /dev/null
+++ b/v2v/test-v2v-on-option.sh
@@ -0,0 +1,56 @@
+#!/bin/bash -
+# libguestfs virt-v2v test script
+# Copyright (C) 2014 Red Hat Inc.
+#
+# 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 -on (change name) option.
+
+unset CDPATH
+export LANG=C
+set -e
+
+if [ -n "$SKIP_TEST_V2V_ON_OPTION_SH" ]; then
+ echo "$0: test skipped because environment variable is set"
+ exit 77
+fi
+
+if [ "$(../fish/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-all-good.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
+
+d=test-v2v-windows-conversion.d
+rm -rf $d
+mkdir $d
+
+$VG ./virt-v2v --debug-gc \
+ -i libvirt -ic "$libvirt_uri" windows \
+ -o local -os $d -on this-is-not-windows
+
+# Test the libvirt XML metadata and a disk was created.
+test -f $d/this-is-not-windows.xml
+test -f $d/this-is-not-windows-sda
+
+rm -r $d
diff --git a/v2v/test-v2v-real-conversions.sh b/v2v/test-v2v-real-conversions.sh
new file mode 100755
index 0000000..26ac22b
--- /dev/null
+++ b/v2v/test-v2v-real-conversions.sh
@@ -0,0 +1,71 @@
+#!/bin/bash -
+# libguestfs virt-v2v test script
+# Copyright (C) 2014 Red Hat Inc.
+#
+# 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 on some real guests.
+#
+# The phony Fedora guest isn't sufficient for testing. The
+# Makefile.am builds some real guests using virt-builder and we just
+# run virt-v2v on those (to make sure it doesn't crash / assert).
+
+unset CDPATH
+export LANG=C
+set -e
+
+if [ -n "$SKIP_TEST_V2V_REAL_CONVERSIONS_SH" ]; then
+ echo "$0: test skipped because environment variable is set"
+ exit 77
+fi
+
+d=test-v2v-real-conversions.d
+rm -rf $d
+mkdir $d
+
+for file in *.img; do
+ if test -f $file && test -s $file ; then
+ n=`basename $file .img`
+
+ # Create some minimal test metadata.
+ cat > $d/$n-input.xml <<EOF
+<domain type='test'>
+ <name>$n</name>
+ <memory>1048576</memory>
+ <os>
+ <type>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <devices>
+ <disk type='file' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source file='$(pwd)/$file'/>
+ <target dev='vda' bus='virtio'/>
+ </disk>
+ </devices>
+</domain>
+EOF
+
+ ./virt-v2v --debug-gc \
+ -i libvirtxml $d/$n-input.xml \
+ -o local -os $d
+
+ # Test the libvirt XML metadata and a disk was created.
+ test -f $d/$n.xml
+ test -f $d/$n-sda
+ fi
+done
+
+rm -r $d
diff --git a/v2v/test-v2v-rhev-options.sh b/v2v/test-v2v-rhev-options.sh
new file mode 100755
index 0000000..ec760a4
--- /dev/null
+++ b/v2v/test-v2v-rhev-options.sh
@@ -0,0 +1,82 @@
+#!/bin/bash -
+# libguestfs virt-v2v test script
+# Copyright (C) 2014 Red Hat Inc.
+#
+# 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 -o rhev options: --vmtype and --rhev-*-uuid
+
+unset CDPATH
+export LANG=C
+set -e
+
+if [ -n "$SKIP_TEST_V2V_RHEV_OPTIONS_SH" ]; then
+ echo "$0: test skipped because environment variable is set"
+ exit 77
+fi
+
+if [ "$(../fish/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-all-good.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
+
+d=test-v2v-rhev-options.d
+rm -rf $d
+mkdir $d
+
+# Create a dummy Export Storage Domain.
+mkdir $d/12345678-1234-1234-1234-123456789abc
+mkdir $d/12345678-1234-1234-1234-123456789abc/images
+mkdir $d/12345678-1234-1234-1234-123456789abc/master
+mkdir $d/12345678-1234-1234-1234-123456789abc/master/vms
+
+# The --rhev-*-uuid options don't actually check that the
+# parameter is a UUID, which is useful here.
+
+$VG ./virt-v2v --debug-gc \
+ -i libvirt -ic "$libvirt_uri" windows \
+ -o rhev -os $d \
+ --vmtype desktop \
+ --rhev-image-uuid IMAGE \
+ --rhev-vol-uuid VOL \
+ --rhev-vm-uuid VM \
+
+# Test the OVF metadata was created.
+test -f $d/12345678-1234-1234-1234-123456789abc/master/vms/VM/VM.ovf
+
+# Test the OVF metadata contains <VmType>DESKTOP</VmType>.
+grep '<VmType>DESKTOP</VmType>' \
+ $d/12345678-1234-1234-1234-123456789abc/master/vms/VM/VM.ovf
+
+pushd $d/12345678-1234-1234-1234-123456789abc/images/IMAGE
+
+# Test the disk .meta was created.
+test -f VOL.meta
+
+# Test the disk file was created.
+test -f VOL
+
+popd
+
+rm -r $d
diff --git a/v2v/test-v2v-rhev.sh b/v2v/test-v2v-rhev.sh
new file mode 100755
index 0000000..56d2e9a
--- /dev/null
+++ b/v2v/test-v2v-rhev.sh
@@ -0,0 +1,72 @@
+#!/bin/bash -
+# libguestfs virt-v2v test script
+# Copyright (C) 2014 Red Hat Inc.
+#
+# 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 -o rhev.
+
+unset CDPATH
+export LANG=C
+set -e
+
+if [ -n "$SKIP_TEST_V2V_RHEV_SH" ]; then
+ echo "$0: test skipped because environment variable is set"
+ exit 77
+fi
+
+if [ "$(../fish/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-all-good.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
+
+d=test-v2v-rhev.d
+rm -rf $d
+mkdir $d
+
+# Create a dummy Export Storage Domain.
+mkdir $d/12345678-1234-1234-1234-123456789abc
+mkdir $d/12345678-1234-1234-1234-123456789abc/images
+mkdir $d/12345678-1234-1234-1234-123456789abc/master
+mkdir $d/12345678-1234-1234-1234-123456789abc/master/vms
+
+$VG ./virt-v2v --debug-gc \
+ -i libvirt -ic "$libvirt_uri" windows \
+ -o rhev -os $d
+
+# Test the OVF metadata was created.
+test -f $d/12345678-1234-1234-1234-123456789abc/master/vms/*/*.ovf
+
+pushd $d/12345678-1234-1234-1234-123456789abc/images/*
+
+# Test the disk .meta was created.
+test -f *.meta
+
+# Test the disk file was created.
+vol=`basename *.meta .meta`
+test -f $vol
+
+popd
+
+rm -r $d
diff --git a/v2v/test-v2v-windows-conversion.sh b/v2v/test-v2v-windows-conversion.sh
new file mode 100755
index 0000000..c437c38
--- /dev/null
+++ b/v2v/test-v2v-windows-conversion.sh
@@ -0,0 +1,79 @@
+#!/bin/bash -
+# libguestfs virt-v2v test script
+# Copyright (C) 2014 Red Hat Inc.
+#
+# 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 (Phony) Windows conversion.
+
+unset CDPATH
+export LANG=C
+set -e
+
+if [ -n "$SKIP_TEST_V2V_WINDOWS_CONVERSION_SH" ]; then
+ echo "$0: test skipped because environment variable is set"
+ exit 77
+fi
+
+if [ "$(../fish/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-all-good.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
+
+# 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-windows-conversion.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 some aspects of the target disk image.
+../fish/guestfish --ro -a $d/windows-sda -i <<EOF
+ is-dir "/Program Files/Red Hat/Firstboot"
+ is-file "/Program Files/Red Hat/Firstboot/firstboot.bat"
+ is-dir "/Program Files/Red Hat/Firstboot/scripts"
+ is-dir "/Windows/Drivers/VirtIO"
+EOF
+
+# We also update the Registry several times, for firstboot, and (ONLY
+# if the virtio-win drivers are installed locally) the critical device
+# database.
+
+rm -r $d
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git
More information about the Pkg-libvirt-commits
mailing list