Roman Kagan
2015-Oct-05 12:40 UTC
[Libguestfs] [PATCH 0/6] v2v: assorted improvements to tests for windows
This series makes several enhancements to tests for v2v conversion of Windows guests. Specifically, it - adds a number of files which imitate the stuff that is supposed to be present on the host when the actual conversion is performed, but may not be there when the tests are run. This includes certain tools and virtio drivers - fixes the test for windows conversion to actually check that the guest filesystem contains the expected files and directories upon conversion - adds a test for the case when virtio windows drivers are provied on an iso image - fixes a bogus failure case in a utility function which triggered on the newly added fake virio windows driver directory. Roman Kagan (6): tests: use fake rhsrvany.exe tests: add fake rhev-apt.exe v2v:test:win: actually check the eventual layout tests: use fake virtio-win drivers v2v:utils: ignore files w/o extension add test for v2v with virtio-win drivers on iso Makefile.am | 1 + configure.ac | 1 + p2v/test-virt-p2v-pxe.sh | 10 ++--- p2v/test-virt-p2v.sh | 9 ++--- tests/fake-virt-tools/rhev-apt.exe | 1 + tests/fake-virt-tools/rhsrvany.exe | 1 + tests/fake-virtio-win/.gitignore | 1 + tests/fake-virtio-win/Makefile.am | 34 ++++++++++++++++ tests/fake-virtio-win/drivers/i386/Win7/netkvm.cat | 1 + tests/fake-virtio-win/drivers/i386/Win7/netkvm.inf | 1 + tests/fake-virtio-win/drivers/i386/Win7/netkvm.sys | 1 + tests/fake-virtio-win/drivers/i386/Win7/qxl.cat | 1 + tests/fake-virtio-win/drivers/i386/Win7/qxl.inf | 1 + tests/fake-virtio-win/drivers/i386/Win7/qxl.sys | 1 + .../fake-virtio-win/drivers/i386/Win7/vioscsi.cat | 1 + .../fake-virtio-win/drivers/i386/Win7/vioscsi.inf | 1 + .../fake-virtio-win/drivers/i386/Win7/vioscsi.sys | 1 + .../fake-virtio-win/drivers/i386/Win7/viostor.cat | 1 + .../fake-virtio-win/drivers/i386/Win7/viostor.inf | 1 + .../fake-virtio-win/drivers/i386/Win7/viostor.sys | 1 + tests/regressions/rhbz1232192.sh | 7 +--- v2v/Makefile.am | 1 + v2v/test-v2v-cdrom.sh | 7 +--- v2v/test-v2v-i-disk.sh | 7 +--- v2v/test-v2v-i-ova-formats.sh | 7 +--- v2v/test-v2v-i-ova-gz.sh | 7 +--- v2v/test-v2v-i-ova-two-disks.sh | 8 ++-- v2v/test-v2v-i-ova.sh | 8 ++-- v2v/test-v2v-networks-and-bridges.sh | 6 +-- v2v/test-v2v-no-copy.sh | 6 +-- v2v/test-v2v-o-glance.sh | 6 +-- v2v/test-v2v-o-libvirt.sh | 6 +-- v2v/test-v2v-o-null.sh | 6 +-- v2v/test-v2v-o-qemu.sh | 6 +-- v2v/test-v2v-o-rhev.sh | 6 +-- v2v/test-v2v-o-vdsm-options.sh | 6 +-- v2v/test-v2v-oa-option.sh | 6 +-- v2v/test-v2v-of-option.sh | 6 +-- v2v/test-v2v-on-option.sh | 6 +-- v2v/test-v2v-sound.sh | 6 +-- ...ws-conversion.sh => test-v2v-virtio-win-iso.sh} | 45 ++++++++++++++-------- v2v/test-v2v-windows-conversion.sh | 35 +++++++++++------ v2v/utils.ml | 5 +-- 43 files changed, 140 insertions(+), 139 deletions(-) create mode 100644 tests/fake-virt-tools/rhev-apt.exe create mode 100644 tests/fake-virt-tools/rhsrvany.exe create mode 100644 tests/fake-virtio-win/.gitignore create mode 100644 tests/fake-virtio-win/Makefile.am create mode 100644 tests/fake-virtio-win/drivers/i386/Win7/netkvm.cat create mode 100644 tests/fake-virtio-win/drivers/i386/Win7/netkvm.inf create mode 100644 tests/fake-virtio-win/drivers/i386/Win7/netkvm.sys create mode 100644 tests/fake-virtio-win/drivers/i386/Win7/qxl.cat create mode 100644 tests/fake-virtio-win/drivers/i386/Win7/qxl.inf create mode 100644 tests/fake-virtio-win/drivers/i386/Win7/qxl.sys create mode 100644 tests/fake-virtio-win/drivers/i386/Win7/vioscsi.cat create mode 100644 tests/fake-virtio-win/drivers/i386/Win7/vioscsi.inf create mode 100644 tests/fake-virtio-win/drivers/i386/Win7/vioscsi.sys create mode 100644 tests/fake-virtio-win/drivers/i386/Win7/viostor.cat create mode 100644 tests/fake-virtio-win/drivers/i386/Win7/viostor.inf create mode 100644 tests/fake-virtio-win/drivers/i386/Win7/viostor.sys copy v2v/{test-v2v-windows-conversion.sh => test-v2v-virtio-win-iso.sh} (65%) -- 2.4.3
The tests that depend on rhsrvany.exe being available, actually don't need it to be the real one: all they want is the file being present. So, instead of skipping the tests if the real rhsrvany.exe is not found, store a fake one in the repository, and point $VIRT_TOOLS_DATA_DIR at its location. Signed-off-by: Roman Kagan <rkagan@virtuozzo.com> --- p2v/test-virt-p2v-pxe.sh | 10 +++------- p2v/test-virt-p2v.sh | 9 +++------ tests/fake-virt-tools/rhsrvany.exe | 1 + tests/regressions/rhbz1232192.sh | 7 ++----- v2v/test-v2v-cdrom.sh | 6 +----- v2v/test-v2v-i-disk.sh | 7 ++----- v2v/test-v2v-i-ova-formats.sh | 7 ++----- v2v/test-v2v-i-ova-gz.sh | 7 ++----- v2v/test-v2v-i-ova-two-disks.sh | 7 ++----- v2v/test-v2v-i-ova.sh | 7 ++----- v2v/test-v2v-networks-and-bridges.sh | 6 +----- v2v/test-v2v-no-copy.sh | 6 +----- v2v/test-v2v-o-glance.sh | 6 +----- v2v/test-v2v-o-libvirt.sh | 6 +----- v2v/test-v2v-o-null.sh | 6 +----- v2v/test-v2v-o-qemu.sh | 6 +----- v2v/test-v2v-o-rhev.sh | 6 +----- v2v/test-v2v-o-vdsm-options.sh | 6 +----- v2v/test-v2v-oa-option.sh | 6 +----- v2v/test-v2v-of-option.sh | 6 +----- v2v/test-v2v-on-option.sh | 6 +----- v2v/test-v2v-sound.sh | 6 +----- v2v/test-v2v-windows-conversion.sh | 6 +----- 23 files changed, 33 insertions(+), 113 deletions(-) create mode 100644 tests/fake-virt-tools/rhsrvany.exe diff --git a/p2v/test-virt-p2v-pxe.sh b/p2v/test-virt-p2v-pxe.sh index f05cb96..4a42d10 100755 --- a/p2v/test-virt-p2v-pxe.sh +++ b/p2v/test-virt-p2v-pxe.sh @@ -55,18 +55,14 @@ if ! test -f $img; then exit 77 fi -guestsdir="$(cd ../tests/guests && pwd)" -f="$guestsdir/windows.img" +abs_top_builddir="$(cd ..; pwd)" +f="$abs_top_builddir/tests/guests/windows.img" if ! test -f $f; then echo "$0: test skipped because phony Windows image was not created" exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$abs_top_builddir/tests/fake-virt-tools" d=test-virt-p2v-pxe.d rm -rf $d diff --git a/p2v/test-virt-p2v.sh b/p2v/test-virt-p2v.sh index 8c3731c..af03ba8 100755 --- a/p2v/test-virt-p2v.sh +++ b/p2v/test-virt-p2v.sh @@ -32,7 +32,8 @@ if [ "$(guestfish get-backend)" = "uml" ]; then exit 77 fi -guestsdir="$(cd ../tests/guests && pwd)" +abs_top_builddir="$(cd ..; pwd)" +guestsdir="$abs_top_builddir/tests/guests" f1="$guestsdir/windows.img" if ! test -f $f1 || ! test -s $f1; then echo "$0: test skipped because phony Windows image was not created" @@ -44,11 +45,7 @@ if ! test -f $f2 || ! test -s $f2; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$abs_top_builddir/tests/fake-virt-tools" d=test-virt-p2v.d rm -rf $d diff --git a/tests/fake-virt-tools/rhsrvany.exe b/tests/fake-virt-tools/rhsrvany.exe new file mode 100644 index 0000000..b474349 --- /dev/null +++ b/tests/fake-virt-tools/rhsrvany.exe @@ -0,0 +1 @@ +This is a fake rhsrvany.exe, used for testing only diff --git a/tests/regressions/rhbz1232192.sh b/tests/regressions/rhbz1232192.sh index 5b4b31e..c0e4519 100755 --- a/tests/regressions/rhbz1232192.sh +++ b/tests/regressions/rhbz1232192.sh @@ -47,10 +47,7 @@ if [ ! -f ../guests/blank-disk.img ]; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +abs_top_builddir="$(cd ../..; pwd)" +export VIRT_TOOLS_DATA_DIR="$abs_top_builddir/tests/fake-virt-tools" ../../v2v/virt-v2v -i libvirtxml rhbz1232192.xml -o null --no-copy diff --git a/v2v/test-v2v-cdrom.sh b/v2v/test-v2v-cdrom.sh index 93975c2..25bf275 100755 --- a/v2v/test-v2v-cdrom.sh +++ b/v2v/test-v2v-cdrom.sh @@ -48,11 +48,7 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$abs_builddir/../tests/fake-virt-tools" d=test-v2v-cdrom.d rm -rf $d diff --git a/v2v/test-v2v-i-disk.sh b/v2v/test-v2v-i-disk.sh index b15e0d0..112f841 100755 --- a/v2v/test-v2v-i-disk.sh +++ b/v2v/test-v2v-i-disk.sh @@ -38,11 +38,8 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +abs_top_builddir="$(cd ..; pwd)" +export VIRT_TOOLS_DATA_DIR="$abs_top_builddir/tests/fake-virt-tools" d=test-v2v-i-disk.d rm -rf $d diff --git a/v2v/test-v2v-i-ova-formats.sh b/v2v/test-v2v-i-ova-formats.sh index bd3e048..c1f60a7 100755 --- a/v2v/test-v2v-i-ova-formats.sh +++ b/v2v/test-v2v-i-ova-formats.sh @@ -44,11 +44,8 @@ if [ "$(guestfish get-backend)" = "uml" ]; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +abs_top_builddir="$(cd ..; pwd)" +export VIRT_TOOLS_DATA_DIR="$abs_top_builddir/tests/fake-virt-tools" d=test-v2v-i-ova-formats.d rm -rf $d diff --git a/v2v/test-v2v-i-ova-gz.sh b/v2v/test-v2v-i-ova-gz.sh index 6c630fb..f8624af 100755 --- a/v2v/test-v2v-i-ova-gz.sh +++ b/v2v/test-v2v-i-ova-gz.sh @@ -32,11 +32,8 @@ if [ "$(guestfish get-backend)" = "uml" ]; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +abs_top_builddir="$(cd ..; pwd)" +export VIRT_TOOLS_DATA_DIR="$abs_top_builddir/tests/fake-virt-tools" d=test-v2v-i-ova-gz.d rm -rf $d diff --git a/v2v/test-v2v-i-ova-two-disks.sh b/v2v/test-v2v-i-ova-two-disks.sh index dfda956..ede6766 100755 --- a/v2v/test-v2v-i-ova-two-disks.sh +++ b/v2v/test-v2v-i-ova-two-disks.sh @@ -32,11 +32,8 @@ if [ "$(guestfish get-backend)" = "uml" ]; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +abs_top_builddir="$(cd ..; pwd)" +export VIRT_TOOLS_DATA_DIR="$abs_top_builddir/tests/fake-virt-tools" d=test-v2v-i-ova-two-disks.d rm -rf $d diff --git a/v2v/test-v2v-i-ova.sh b/v2v/test-v2v-i-ova.sh index 5047eca..37fc89e 100755 --- a/v2v/test-v2v-i-ova.sh +++ b/v2v/test-v2v-i-ova.sh @@ -38,11 +38,8 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +abs_top_builddir="$(cd ..; pwd)" +export VIRT_TOOLS_DATA_DIR="$abs_top_builddir/tests/fake-virt-tools" d=test-v2v-i-ova.d rm -rf $d diff --git a/v2v/test-v2v-networks-and-bridges.sh b/v2v/test-v2v-networks-and-bridges.sh index 68743d6..3654458 100755 --- a/v2v/test-v2v-networks-and-bridges.sh +++ b/v2v/test-v2v-networks-and-bridges.sh @@ -41,11 +41,7 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$abs_builddir/../tests/fake-virt-tools" d=test-v2v-networks-and-bridges.d rm -rf $d diff --git a/v2v/test-v2v-no-copy.sh b/v2v/test-v2v-no-copy.sh index f0408dc..4eb9eb6 100755 --- a/v2v/test-v2v-no-copy.sh +++ b/v2v/test-v2v-no-copy.sh @@ -41,11 +41,7 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$abs_top_builddir/tests/fake-virt-tools" d=test-v2v-no-copy.d rm -rf $d diff --git a/v2v/test-v2v-o-glance.sh b/v2v/test-v2v-o-glance.sh index 121177f..cc888d4 100755 --- a/v2v/test-v2v-o-glance.sh +++ b/v2v/test-v2v-o-glance.sh @@ -41,11 +41,7 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$abs_top_builddir/tests/fake-virt-tools" # We don't want to upload to the real glance, so introduce a fake # glance binary. diff --git a/v2v/test-v2v-o-libvirt.sh b/v2v/test-v2v-o-libvirt.sh index 77b38e0..0cf59b2 100755 --- a/v2v/test-v2v-o-libvirt.sh +++ b/v2v/test-v2v-o-libvirt.sh @@ -49,11 +49,7 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$abs_top_builddir/tests/fake-virt-tools" # Generate a random guest name. guestname=tmp-$(tr -cd 'a-f0-9' < /dev/urandom | head -c 8) diff --git a/v2v/test-v2v-o-null.sh b/v2v/test-v2v-o-null.sh index 9ed581b..cc32edb 100755 --- a/v2v/test-v2v-o-null.sh +++ b/v2v/test-v2v-o-null.sh @@ -41,11 +41,7 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$abs_top_builddir/tests/fake-virt-tools" $VG virt-v2v --debug-gc \ -i libvirt -ic "$libvirt_uri" windows \ diff --git a/v2v/test-v2v-o-qemu.sh b/v2v/test-v2v-o-qemu.sh index 9de2b56..926b9b8 100755 --- a/v2v/test-v2v-o-qemu.sh +++ b/v2v/test-v2v-o-qemu.sh @@ -41,11 +41,7 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$abs_top_builddir/tests/fake-virt-tools" d=test-v2v-o-qemu.d rm -rf $d diff --git a/v2v/test-v2v-o-rhev.sh b/v2v/test-v2v-o-rhev.sh index 1162e31..8d5789c 100755 --- a/v2v/test-v2v-o-rhev.sh +++ b/v2v/test-v2v-o-rhev.sh @@ -41,11 +41,7 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$abs_top_builddir/tests/fake-virt-tools" d=test-v2v-o-rhev.d rm -rf $d diff --git a/v2v/test-v2v-o-vdsm-options.sh b/v2v/test-v2v-o-vdsm-options.sh index c170467..1540bd8 100755 --- a/v2v/test-v2v-o-vdsm-options.sh +++ b/v2v/test-v2v-o-vdsm-options.sh @@ -41,11 +41,7 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$abs_top_builddir/tests/fake-virt-tools" d=test-v2v-o-vdsm-options.d rm -rf $d diff --git a/v2v/test-v2v-oa-option.sh b/v2v/test-v2v-oa-option.sh index c1a555a..bafdb61 100755 --- a/v2v/test-v2v-oa-option.sh +++ b/v2v/test-v2v-oa-option.sh @@ -41,11 +41,7 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$abs_top_builddir/tests/fake-virt-tools" d=test-v2v-windows-conversion.d rm -rf $d diff --git a/v2v/test-v2v-of-option.sh b/v2v/test-v2v-of-option.sh index 27441cf..e118b04 100755 --- a/v2v/test-v2v-of-option.sh +++ b/v2v/test-v2v-of-option.sh @@ -41,11 +41,7 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$abs_top_builddir/tests/fake-virt-tools" d=test-v2v-windows-conversion.d rm -rf $d diff --git a/v2v/test-v2v-on-option.sh b/v2v/test-v2v-on-option.sh index e3edb67..1b38ec7 100755 --- a/v2v/test-v2v-on-option.sh +++ b/v2v/test-v2v-on-option.sh @@ -41,11 +41,7 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$abs_top_builddir/tests/fake-virt-tools" d=test-v2v-windows-conversion.d rm -rf $d diff --git a/v2v/test-v2v-sound.sh b/v2v/test-v2v-sound.sh index 7cb6f24..b4c13e0 100755 --- a/v2v/test-v2v-sound.sh +++ b/v2v/test-v2v-sound.sh @@ -41,11 +41,7 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$abs_builddir/../tests/fake-virt-tools" d=test-v2v-sound.d rm -rf $d diff --git a/v2v/test-v2v-windows-conversion.sh b/v2v/test-v2v-windows-conversion.sh index 7e8e628..eef6f57 100755 --- a/v2v/test-v2v-windows-conversion.sh +++ b/v2v/test-v2v-windows-conversion.sh @@ -41,11 +41,7 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$abs_top_builddir/tests/fake-virt-tools" # Return a random element from the array 'choices'. function random_choice -- 2.4.3
Without rhev-apt.exe the code path where firstboot scripts are created isn't taken, so it isn't tested and v2v/test-v2v-windows-conversion.sh is supposed to fail (it actually doesn't but for another reason, addressed in a followup patch). Signed-off-by: Roman Kagan <rkagan@virtuozzo.com> --- tests/fake-virt-tools/rhev-apt.exe | 1 + 1 file changed, 1 insertion(+) create mode 100644 tests/fake-virt-tools/rhev-apt.exe diff --git a/tests/fake-virt-tools/rhev-apt.exe b/tests/fake-virt-tools/rhev-apt.exe new file mode 100644 index 0000000..2f472e5 --- /dev/null +++ b/tests/fake-virt-tools/rhev-apt.exe @@ -0,0 +1 @@ +This is a fake rhev-apt.exe, used for testing only -- 2.4.3
Roman Kagan
2015-Oct-05 12:40 UTC
[Libguestfs] [PATCH 3/6] v2v:test:win: actually check the eventual layout
v2v/test-v2v-windows-conversion.sh used to query if the expected directories and filed were present in the VM upon conversion; however it would ignore the results of that query. That lead to the test passing even though the checks failed. To fix it, parse the output of guestfish and verify that all is-file and is-dir commands return the expected "true". While doing so, keep in mind that the exit status of a pipeline is that of the last command, so make sure to check the exit status of guestfish too via $PIPESTATUS (yes it's bash-specific but the scripts are run with bash only anyway). Signed-off-by: Roman Kagan <rkagan@virtuozzo.com> --- v2v/test-v2v-windows-conversion.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/v2v/test-v2v-windows-conversion.sh b/v2v/test-v2v-windows-conversion.sh index eef6f57..916699d 100755 --- a/v2v/test-v2v-windows-conversion.sh +++ b/v2v/test-v2v-windows-conversion.sh @@ -67,12 +67,23 @@ test -f $d/windows.xml test -f $d/windows-sda # Test some aspects of the target disk image. +{ guestfish --ro -a $d/windows-sda -i <<EOF + trace 1 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" + trace 0 EOF +} | { + ret=0 + while read r; do + [ "$r" = "true" ] || ret=1 + done + exit $ret +} +(( PIPESTATUS[0] == 0 )) # We also update the Registry several times, for firstboot, and (ONLY # if the virtio-win drivers are installed locally) the critical device -- 2.4.3
Roman Kagan
2015-Oct-05 12:40 UTC
[Libguestfs] [PATCH 4/6] tests: use fake virtio-win drivers
In order to test the copying of virtio-win drivers into the guest during v2v, create a set of fake virtio-win drivers and make use of them in the corresponding v2v tests. Signed-off-by: Roman Kagan <rkagan@virtuozzo.com> --- tests/fake-virtio-win/drivers/i386/Win7/netkvm.cat | 1 + tests/fake-virtio-win/drivers/i386/Win7/netkvm.inf | 1 + tests/fake-virtio-win/drivers/i386/Win7/netkvm.sys | 1 + tests/fake-virtio-win/drivers/i386/Win7/qxl.cat | 1 + tests/fake-virtio-win/drivers/i386/Win7/qxl.inf | 1 + tests/fake-virtio-win/drivers/i386/Win7/qxl.sys | 1 + .../fake-virtio-win/drivers/i386/Win7/vioscsi.cat | 1 + .../fake-virtio-win/drivers/i386/Win7/vioscsi.inf | 1 + .../fake-virtio-win/drivers/i386/Win7/vioscsi.sys | 1 + .../fake-virtio-win/drivers/i386/Win7/viostor.cat | 1 + .../fake-virtio-win/drivers/i386/Win7/viostor.inf | 1 + .../fake-virtio-win/drivers/i386/Win7/viostor.sys | 1 + v2v/test-v2v-cdrom.sh | 1 + v2v/test-v2v-i-ova-two-disks.sh | 1 + v2v/test-v2v-i-ova.sh | 1 + v2v/test-v2v-windows-conversion.sh | 26 +++++++++++++--------- 16 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 tests/fake-virtio-win/drivers/i386/Win7/netkvm.cat create mode 100644 tests/fake-virtio-win/drivers/i386/Win7/netkvm.inf create mode 100644 tests/fake-virtio-win/drivers/i386/Win7/netkvm.sys create mode 100644 tests/fake-virtio-win/drivers/i386/Win7/qxl.cat create mode 100644 tests/fake-virtio-win/drivers/i386/Win7/qxl.inf create mode 100644 tests/fake-virtio-win/drivers/i386/Win7/qxl.sys create mode 100644 tests/fake-virtio-win/drivers/i386/Win7/vioscsi.cat create mode 100644 tests/fake-virtio-win/drivers/i386/Win7/vioscsi.inf create mode 100644 tests/fake-virtio-win/drivers/i386/Win7/vioscsi.sys create mode 100644 tests/fake-virtio-win/drivers/i386/Win7/viostor.cat create mode 100644 tests/fake-virtio-win/drivers/i386/Win7/viostor.inf create mode 100644 tests/fake-virtio-win/drivers/i386/Win7/viostor.sys diff --git a/tests/fake-virtio-win/drivers/i386/Win7/netkvm.cat b/tests/fake-virtio-win/drivers/i386/Win7/netkvm.cat new file mode 100644 index 0000000..be81e94 --- /dev/null +++ b/tests/fake-virtio-win/drivers/i386/Win7/netkvm.cat @@ -0,0 +1 @@ +This is a fake netkvm.cat, used for testing only diff --git a/tests/fake-virtio-win/drivers/i386/Win7/netkvm.inf b/tests/fake-virtio-win/drivers/i386/Win7/netkvm.inf new file mode 100644 index 0000000..ab4a68f --- /dev/null +++ b/tests/fake-virtio-win/drivers/i386/Win7/netkvm.inf @@ -0,0 +1 @@ +This is a fake netkvm.inf, used for testing only diff --git a/tests/fake-virtio-win/drivers/i386/Win7/netkvm.sys b/tests/fake-virtio-win/drivers/i386/Win7/netkvm.sys new file mode 100644 index 0000000..3a2afae --- /dev/null +++ b/tests/fake-virtio-win/drivers/i386/Win7/netkvm.sys @@ -0,0 +1 @@ +This is a fake netkvm.sys, used for testing only diff --git a/tests/fake-virtio-win/drivers/i386/Win7/qxl.cat b/tests/fake-virtio-win/drivers/i386/Win7/qxl.cat new file mode 100644 index 0000000..0af6a9a --- /dev/null +++ b/tests/fake-virtio-win/drivers/i386/Win7/qxl.cat @@ -0,0 +1 @@ +This is a fake qxl.cat, used for testing only diff --git a/tests/fake-virtio-win/drivers/i386/Win7/qxl.inf b/tests/fake-virtio-win/drivers/i386/Win7/qxl.inf new file mode 100644 index 0000000..3fb759d --- /dev/null +++ b/tests/fake-virtio-win/drivers/i386/Win7/qxl.inf @@ -0,0 +1 @@ +This is a fake qxl.inf, used for testing only diff --git a/tests/fake-virtio-win/drivers/i386/Win7/qxl.sys b/tests/fake-virtio-win/drivers/i386/Win7/qxl.sys new file mode 100644 index 0000000..118ede0 --- /dev/null +++ b/tests/fake-virtio-win/drivers/i386/Win7/qxl.sys @@ -0,0 +1 @@ +This is a fake qxl.sys, used for testing only diff --git a/tests/fake-virtio-win/drivers/i386/Win7/vioscsi.cat b/tests/fake-virtio-win/drivers/i386/Win7/vioscsi.cat new file mode 100644 index 0000000..056535f --- /dev/null +++ b/tests/fake-virtio-win/drivers/i386/Win7/vioscsi.cat @@ -0,0 +1 @@ +This is a fake vioscsi.cat, used for testing only diff --git a/tests/fake-virtio-win/drivers/i386/Win7/vioscsi.inf b/tests/fake-virtio-win/drivers/i386/Win7/vioscsi.inf new file mode 100644 index 0000000..97b3884 --- /dev/null +++ b/tests/fake-virtio-win/drivers/i386/Win7/vioscsi.inf @@ -0,0 +1 @@ +This is a fake vioscsi.inf, used for testing only diff --git a/tests/fake-virtio-win/drivers/i386/Win7/vioscsi.sys b/tests/fake-virtio-win/drivers/i386/Win7/vioscsi.sys new file mode 100644 index 0000000..102a797 --- /dev/null +++ b/tests/fake-virtio-win/drivers/i386/Win7/vioscsi.sys @@ -0,0 +1 @@ +This is a fake vioscsi.sys, used for testing only diff --git a/tests/fake-virtio-win/drivers/i386/Win7/viostor.cat b/tests/fake-virtio-win/drivers/i386/Win7/viostor.cat new file mode 100644 index 0000000..6c32f85 --- /dev/null +++ b/tests/fake-virtio-win/drivers/i386/Win7/viostor.cat @@ -0,0 +1 @@ +This is a fake viostor.cat, used for testing only diff --git a/tests/fake-virtio-win/drivers/i386/Win7/viostor.inf b/tests/fake-virtio-win/drivers/i386/Win7/viostor.inf new file mode 100644 index 0000000..18f416d --- /dev/null +++ b/tests/fake-virtio-win/drivers/i386/Win7/viostor.inf @@ -0,0 +1 @@ +This is a fake viostor.inf, used for testing only diff --git a/tests/fake-virtio-win/drivers/i386/Win7/viostor.sys b/tests/fake-virtio-win/drivers/i386/Win7/viostor.sys new file mode 100644 index 0000000..3f9c147 --- /dev/null +++ b/tests/fake-virtio-win/drivers/i386/Win7/viostor.sys @@ -0,0 +1 @@ +This is a fake viostor.sys, used for testing only diff --git a/v2v/test-v2v-cdrom.sh b/v2v/test-v2v-cdrom.sh index 25bf275..a963c73 100755 --- a/v2v/test-v2v-cdrom.sh +++ b/v2v/test-v2v-cdrom.sh @@ -49,6 +49,7 @@ if ! test -f $f || ! test -s $f; then fi export VIRT_TOOLS_DATA_DIR="$abs_builddir/../tests/fake-virt-tools" +export VIRTIO_WIN="$abs_builddir/../tests/fake-virtio-win" d=test-v2v-cdrom.d rm -rf $d diff --git a/v2v/test-v2v-i-ova-two-disks.sh b/v2v/test-v2v-i-ova-two-disks.sh index ede6766..e7b4137 100755 --- a/v2v/test-v2v-i-ova-two-disks.sh +++ b/v2v/test-v2v-i-ova-two-disks.sh @@ -34,6 +34,7 @@ fi abs_top_builddir="$(cd ..; pwd)" export VIRT_TOOLS_DATA_DIR="$abs_top_builddir/tests/fake-virt-tools" +export VIRTIO_WIN="$abs_top_builddir/tests/fake-virtio-win" d=test-v2v-i-ova-two-disks.d rm -rf $d diff --git a/v2v/test-v2v-i-ova.sh b/v2v/test-v2v-i-ova.sh index 37fc89e..aaf5031 100755 --- a/v2v/test-v2v-i-ova.sh +++ b/v2v/test-v2v-i-ova.sh @@ -40,6 +40,7 @@ fi abs_top_builddir="$(cd ..; pwd)" export VIRT_TOOLS_DATA_DIR="$abs_top_builddir/tests/fake-virt-tools" +export VIRTIO_WIN="$abs_top_builddir/tests/fake-virtio-win" d=test-v2v-i-ova.d rm -rf $d diff --git a/v2v/test-v2v-windows-conversion.sh b/v2v/test-v2v-windows-conversion.sh index 916699d..3f4ae39 100755 --- a/v2v/test-v2v-windows-conversion.sh +++ b/v2v/test-v2v-windows-conversion.sh @@ -42,6 +42,7 @@ if ! test -f $f || ! test -s $f; then fi export VIRT_TOOLS_DATA_DIR="$abs_top_builddir/tests/fake-virt-tools" +export VIRTIO_WIN="$abs_top_builddir/tests/fake-virtio-win" # Return a random element from the array 'choices'. function random_choice @@ -67,23 +68,28 @@ test -f $d/windows.xml test -f $d/windows-sda # Test some aspects of the target disk image. +firstboot_dir="/Program Files/Red Hat/Firstboot" +virtio_dir="/Windows/Drivers/VirtIO" { -guestfish --ro -a $d/windows-sda -i <<EOF - trace 1 - 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" - trace 0 -EOF -} | { + echo "trace 1" + echo "is-dir \"$firstboot_dir\"" + echo "is-file \"$firstboot_dir/firstboot.bat\"" + echo "is-dir \"$firstboot_dir/scripts\"" + 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[0] == 0 )) +(( PIPESTATUS[1] == 0 )) # We also update the Registry several times, for firstboot, and (ONLY # if the virtio-win drivers are installed locally) the critical device -- 2.4.3
Roman Kagan
2015-Oct-05 12:40 UTC
[Libguestfs] [PATCH 5/6] v2v:utils: ignore files w/o extension
When searching for virtio drivers, it makes no sense to fail if we encounter a file without extension. Ignore such files instead, just like we do for the files whose extension doesn't match that of a driver-related file. Signed-off-by: Roman Kagan <rkagan@virtuozzo.com> --- v2v/utils.ml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/v2v/utils.ml b/v2v/utils.ml index e07f7a9..23d9e51 100644 --- a/v2v/utils.ml +++ b/v2v/utils.ml @@ -238,9 +238,8 @@ let find_virtio_win_drivers virtio_win let extension match last_part_of lc_basename '.' with | Some x -> x - | None -> - error "v2v/find_virtio_win_drivers: missing '.' in %s" - lc_basename in + | None -> raise Not_found + in (* Skip files without specific extensions. *) if extension <> "cat" && extension <> "inf" && -- 2.4.3
Roman Kagan
2015-Oct-05 12:40 UTC
[Libguestfs] [PATCH 6/6] add test for v2v with virtio-win drivers on iso
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@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
Pino Toscano
2015-Oct-05 12:50 UTC
Re: [Libguestfs] [PATCH 3/6] v2v:test:win: actually check the eventual layout
On Monday 05 October 2015 15:40:03 Roman Kagan wrote:> v2v/test-v2v-windows-conversion.sh used to query if the expected > directories and filed were present in the VM upon conversion; however it > would ignore the results of that query. > > That lead to the test passing even though the checks failed. > > To fix it, parse the output of guestfish and verify that all is-file and > is-dir commands return the expected "true". > > While doing so, keep in mind that the exit status of a pipeline is that > of the last command, so make sure to check the exit status of guestfish > too via $PIPESTATUS (yes it's bash-specific but the scripts are run with > bash only anyway). > > Signed-off-by: Roman Kagan <rkagan@virtuozzo.com> > --- > v2v/test-v2v-windows-conversion.sh | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/v2v/test-v2v-windows-conversion.sh b/v2v/test-v2v-windows-conversion.sh > index eef6f57..916699d 100755 > --- a/v2v/test-v2v-windows-conversion.sh > +++ b/v2v/test-v2v-windows-conversion.sh > @@ -67,12 +67,23 @@ test -f $d/windows.xml > test -f $d/windows-sda > > # Test some aspects of the target disk image. > +{ > guestfish --ro -a $d/windows-sda -i <<EOF > + trace 1 > 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" > + trace 0 > EOF > +} | { > + ret=0 > + while read r; do > + [ "$r" = "true" ] || ret=1 > + done > + exit $ret > +}Note we have tests that check the output of guestfish -- for example, fish/test-edit.sh (it is not the only one). I guess you could turn this test to do the same, which could be also easier to expand if there will be added more commands that output things different than "true".> +(( PIPESTATUS[0] == 0 ))set -o pipefail (which is bash-specific) -- Pino Toscano
Richard W.M. Jones
2015-Oct-05 13:17 UTC
Re: [Libguestfs] [PATCH 1/6] tests: use fake rhsrvany.exe
On Mon, Oct 05, 2015 at 03:40:01PM +0300, Roman Kagan wrote:> -guestsdir="$(cd ../tests/guests && pwd)" > -f="$guestsdir/windows.img" > +abs_top_builddir="$(cd ..; pwd)"You don't need to define abs_top_builddir, as it should already be defined. However it won't be exported to the test scripts unless you change v2v/Makefile.am: TESTS_ENVIRONMENT to include it, something like this: -TESTS_ENVIRONMENT = $(top_builddir)/run --test +TESTS_ENVIRONMENT = abs_top_builddir="$(abs_top_builddir)" $(top_builddir)/run --test> diff --git a/tests/fake-virt-tools/rhsrvany.exe b/tests/fake-virt-tools/rhsrvany.exe > new file mode 100644 > index 0000000..b474349 > --- /dev/null > +++ b/tests/fake-virt-tools/rhsrvany.exe > @@ -0,0 +1 @@ > +This is a fake rhsrvany.exe, used for testing only > diff --git a/tests/regressions/rhbz1232192.sh b/tests/regressions/rhbz1232192.shThis doesn't appear in EXTRA_DIST, so it won't be copied to the tarball. TBH I'd prefer if the fake-virt-tools directory was a subdir of v2v/ so you can just add fake-virt-tools/rhsrvany.exe to EXTRA_DIST that is already defined in v2v/Makefile.am. ACK the patch with these changes. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
Richard W.M. Jones
2015-Oct-05 13:18 UTC
Re: [Libguestfs] [PATCH 2/6] tests: add fake rhev-apt.exe
On Mon, Oct 05, 2015 at 03:40:02PM +0300, Roman Kagan wrote:> Without rhev-apt.exe the code path where firstboot scripts are created > isn't taken, so it isn't tested and v2v/test-v2v-windows-conversion.sh > is supposed to fail (it actually doesn't but for another reason, > addressed in a followup patch). > > Signed-off-by: Roman Kagan <rkagan@virtuozzo.com> > --- > tests/fake-virt-tools/rhev-apt.exe | 1 + > 1 file changed, 1 insertion(+) > create mode 100644 tests/fake-virt-tools/rhev-apt.exe > > diff --git a/tests/fake-virt-tools/rhev-apt.exe b/tests/fake-virt-tools/rhev-apt.exe > new file mode 100644 > index 0000000..2f472e5 > --- /dev/null > +++ b/tests/fake-virt-tools/rhev-apt.exe > @@ -0,0 +1 @@ > +This is a fake rhev-apt.exe, used for testing only > -- > 2.4.3As with my comment on patch 1, I think it's better to put this under the v2v/ subdirectory, and you'll need to add the file to EXTRA_DIST too. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW
Richard W.M. Jones
2015-Oct-05 13:24 UTC
Re: [Libguestfs] [PATCH 3/6] v2v:test:win: actually check the eventual layout
On Mon, Oct 05, 2015 at 03:40:03PM +0300, Roman Kagan wrote:> v2v/test-v2v-windows-conversion.sh used to query if the expected > directories and filed were present in the VM upon conversion; however it > would ignore the results of that query. > > That lead to the test passing even though the checks failed.Good point. Fix is kinda ugly though. How about: output=$( guestfish --ro -a $d/windows-sda -i <<EOF is-dir "/Program Files/Red Hat/Firstboot" ... ) if [ "$output" != "true true true true" ]; then echo "$0: firstboot files were not copied into the guest" echo "$0: test output was:" echo "$output" exit 1 fi Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
Richard W.M. Jones
2015-Oct-05 13:25 UTC
Re: [Libguestfs] [PATCH 4/6] tests: use fake virtio-win drivers
On Mon, Oct 05, 2015 at 03:40:04PM +0300, Roman Kagan wrote:> In order to test the copying of virtio-win drivers into the guest during > v2v, create a set of fake virtio-win drivers and make use of them in the > corresponding v2v tests.Similar comments to before, re: location of the directory, EXTRA_DIST, and the manner in which the guestfish test output is checked. Looks good though. With those changes, it's an ACK. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
Richard W.M. Jones
2015-Oct-05 13:26 UTC
Re: [Libguestfs] [PATCH 5/6] v2v:utils: ignore files w/o extension
On Mon, Oct 05, 2015 at 03:40:05PM +0300, Roman Kagan wrote:> When searching for virtio drivers, it makes no sense to fail if we > encounter a file without extension. > > Ignore such files instead, just like we do for the files whose extension > doesn't match that of a driver-related file. > > Signed-off-by: Roman Kagan <rkagan@virtuozzo.com> > --- > v2v/utils.ml | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/v2v/utils.ml b/v2v/utils.ml > index e07f7a9..23d9e51 100644 > --- a/v2v/utils.ml > +++ b/v2v/utils.ml > @@ -238,9 +238,8 @@ let find_virtio_win_drivers virtio_win > let extension > match last_part_of lc_basename '.' with > | Some x -> x > - | None -> > - error "v2v/find_virtio_win_drivers: missing '.' in %s" > - lc_basename in > + | None -> raise Not_found > + in > > (* Skip files without specific extensions. *) > if extension <> "cat" && extension <> "inf" &&ACK. I'll push this one soon. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
Roman Kagan
2015-Oct-08 13:50 UTC
[Libguestfs] [PATCH v2 0/5] v2v: assorted improvements to tests for windows
This series makes several enhancements to tests for v2v conversion of Windows guests. Specifically, it - adds a number of files which imitate the stuff that is supposed to be present on the host when the actual conversion is performed, but may not be there when the tests are run. This includes certain tools and virtio drivers - fixes the test for windows conversion to actually check that the guest filesystem contains the expected files and directories upon conversion - adds a test for the case when virtio windows drivers are provied on an iso image Roman Kagan (5): v2v:tests: use fake rhsrvany.exe v2v: add fake rhev-apt.exe v2v:test:win: actually check the eventual layout v2v:tests: use fake virtio-win drivers v2v: add test for v2v with virtio-win drivers on iso --- changes since v1: - dropped patch merged earlier - moved the fake-* under v2v, and avoid touching the rest - referred to fake-* stuff via $PWD in test scripts - updated Makefile to package the newly added files (unreliable since make dist is still broken) - changed the way the presence of files in the guest is checked to address the comments to v1 .gitignore | 1 + v2v/Makefile.am | 18 +++++++ v2v/fake-virt-tools/rhev-apt.exe | 1 + v2v/fake-virt-tools/rhsrvany.exe | 1 + v2v/fake-virtio-win/drivers/i386/Win7/netkvm.cat | 1 + v2v/fake-virtio-win/drivers/i386/Win7/netkvm.inf | 1 + v2v/fake-virtio-win/drivers/i386/Win7/netkvm.sys | 1 + v2v/fake-virtio-win/drivers/i386/Win7/qxl.cat | 1 + v2v/fake-virtio-win/drivers/i386/Win7/qxl.inf | 1 + v2v/fake-virtio-win/drivers/i386/Win7/qxl.sys | 1 + v2v/fake-virtio-win/drivers/i386/Win7/vioscsi.cat | 1 + v2v/fake-virtio-win/drivers/i386/Win7/vioscsi.inf | 1 + v2v/fake-virtio-win/drivers/i386/Win7/vioscsi.sys | 1 + v2v/fake-virtio-win/drivers/i386/Win7/viostor.cat | 1 + v2v/fake-virtio-win/drivers/i386/Win7/viostor.inf | 1 + v2v/fake-virtio-win/drivers/i386/Win7/viostor.sys | 1 + v2v/test-v2v-cdrom.sh | 7 +-- v2v/test-v2v-i-disk.sh | 6 +-- v2v/test-v2v-i-ova-formats.sh | 6 +-- v2v/test-v2v-i-ova-gz.sh | 6 +-- v2v/test-v2v-i-ova-two-disks.sh | 7 +-- v2v/test-v2v-i-ova.sh | 7 +-- v2v/test-v2v-networks-and-bridges.sh | 6 +-- v2v/test-v2v-no-copy.sh | 6 +-- v2v/test-v2v-o-glance.sh | 6 +-- v2v/test-v2v-o-libvirt.sh | 6 +-- v2v/test-v2v-o-null.sh | 6 +-- v2v/test-v2v-o-qemu.sh | 6 +-- v2v/test-v2v-o-rhev.sh | 6 +-- v2v/test-v2v-o-vdsm-options.sh | 6 +-- v2v/test-v2v-oa-option.sh | 6 +-- v2v/test-v2v-of-option.sh | 6 +-- v2v/test-v2v-on-option.sh | 6 +-- v2v/test-v2v-sound.sh | 6 +-- ...ws-conversion.sh => test-v2v-virtio-win-iso.sh} | 59 +++++++++++++++------- v2v/test-v2v-windows-conversion.sh | 45 +++++++++++++---- 36 files changed, 130 insertions(+), 118 deletions(-) create mode 100644 v2v/fake-virt-tools/rhev-apt.exe create mode 100644 v2v/fake-virt-tools/rhsrvany.exe create mode 100644 v2v/fake-virtio-win/drivers/i386/Win7/netkvm.cat create mode 100644 v2v/fake-virtio-win/drivers/i386/Win7/netkvm.inf create mode 100644 v2v/fake-virtio-win/drivers/i386/Win7/netkvm.sys create mode 100644 v2v/fake-virtio-win/drivers/i386/Win7/qxl.cat create mode 100644 v2v/fake-virtio-win/drivers/i386/Win7/qxl.inf create mode 100644 v2v/fake-virtio-win/drivers/i386/Win7/qxl.sys create mode 100644 v2v/fake-virtio-win/drivers/i386/Win7/vioscsi.cat create mode 100644 v2v/fake-virtio-win/drivers/i386/Win7/vioscsi.inf create mode 100644 v2v/fake-virtio-win/drivers/i386/Win7/vioscsi.sys create mode 100644 v2v/fake-virtio-win/drivers/i386/Win7/viostor.cat create mode 100644 v2v/fake-virtio-win/drivers/i386/Win7/viostor.inf create mode 100644 v2v/fake-virtio-win/drivers/i386/Win7/viostor.sys copy v2v/{test-v2v-windows-conversion.sh => test-v2v-virtio-win-iso.sh} (59%) -- 2.4.3
Roman Kagan
2015-Oct-08 13:50 UTC
[Libguestfs] [PATCH v2 1/5] v2v:tests: use fake rhsrvany.exe
The tests that depend on rhsrvany.exe being available, actually don't need it to be the real one: all they want is the file being present. So, instead of skipping the tests if the real rhsrvany.exe is not found, store a fake one in the repository, and point $VIRT_TOOLS_DATA_DIR at its location. Signed-off-by: Roman Kagan <rkagan@virtuozzo.com> --- changes since v1: - relocated fake-virt-tools under v2v - referred to fake-virt-tools via $PWD in test scripts - packaged fake-virt-tools v2v/Makefile.am | 5 +++++ v2v/fake-virt-tools/rhsrvany.exe | 1 + v2v/test-v2v-cdrom.sh | 6 +----- v2v/test-v2v-i-disk.sh | 6 +----- v2v/test-v2v-i-ova-formats.sh | 6 +----- v2v/test-v2v-i-ova-gz.sh | 6 +----- v2v/test-v2v-i-ova-two-disks.sh | 6 +----- v2v/test-v2v-i-ova.sh | 6 +----- v2v/test-v2v-networks-and-bridges.sh | 6 +----- v2v/test-v2v-no-copy.sh | 6 +----- v2v/test-v2v-o-glance.sh | 6 +----- v2v/test-v2v-o-libvirt.sh | 6 +----- v2v/test-v2v-o-null.sh | 6 +----- v2v/test-v2v-o-qemu.sh | 6 +----- v2v/test-v2v-o-rhev.sh | 6 +----- v2v/test-v2v-o-vdsm-options.sh | 6 +----- v2v/test-v2v-oa-option.sh | 6 +----- v2v/test-v2v-of-option.sh | 6 +----- v2v/test-v2v-on-option.sh | 6 +----- v2v/test-v2v-sound.sh | 6 +----- v2v/test-v2v-windows-conversion.sh | 6 +----- 21 files changed, 25 insertions(+), 95 deletions(-) create mode 100644 v2v/fake-virt-tools/rhsrvany.exe diff --git a/v2v/Makefile.am b/v2v/Makefile.am index 5f2a0ee..e3fa1b5 100644 --- a/v2v/Makefile.am +++ b/v2v/Makefile.am @@ -21,6 +21,7 @@ EXTRA_DIST = \ $(SOURCES_MLI) $(SOURCES_ML) $(SOURCES_C) \ v2v_unit_tests.ml \ $(TESTS) $(SLOW_TESTS) \ + $(FAKE_VIRT_TOOLS) \ HACKING \ test-v2v-cdrom.expected \ test-v2v-cdrom.xml \ @@ -106,6 +107,10 @@ SOURCES_C = \ utils-c.c \ xml-c.c +fake_virt_tools_dir = fake-virt-tools +FAKE_VIRT_TOOLS = \ + $(fake_virt_tools_dir)/rhsrvany.exe + if HAVE_OCAML bin_PROGRAMS = virt-v2v diff --git a/v2v/fake-virt-tools/rhsrvany.exe b/v2v/fake-virt-tools/rhsrvany.exe new file mode 100644 index 0000000..b474349 --- /dev/null +++ b/v2v/fake-virt-tools/rhsrvany.exe @@ -0,0 +1 @@ +This is a fake rhsrvany.exe, used for testing only diff --git a/v2v/test-v2v-cdrom.sh b/v2v/test-v2v-cdrom.sh index 93975c2..1b03b13 100755 --- a/v2v/test-v2v-cdrom.sh +++ b/v2v/test-v2v-cdrom.sh @@ -48,11 +48,7 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$PWD/fake-virt-tools" d=test-v2v-cdrom.d rm -rf $d diff --git a/v2v/test-v2v-i-disk.sh b/v2v/test-v2v-i-disk.sh index b15e0d0..17f904c 100755 --- a/v2v/test-v2v-i-disk.sh +++ b/v2v/test-v2v-i-disk.sh @@ -38,11 +38,7 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$PWD/fake-virt-tools" d=test-v2v-i-disk.d rm -rf $d diff --git a/v2v/test-v2v-i-ova-formats.sh b/v2v/test-v2v-i-ova-formats.sh index bd3e048..86ae5e0 100755 --- a/v2v/test-v2v-i-ova-formats.sh +++ b/v2v/test-v2v-i-ova-formats.sh @@ -44,11 +44,7 @@ if [ "$(guestfish get-backend)" = "uml" ]; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$PWD/fake-virt-tools" d=test-v2v-i-ova-formats.d rm -rf $d diff --git a/v2v/test-v2v-i-ova-gz.sh b/v2v/test-v2v-i-ova-gz.sh index 6c630fb..57c2942 100755 --- a/v2v/test-v2v-i-ova-gz.sh +++ b/v2v/test-v2v-i-ova-gz.sh @@ -32,11 +32,7 @@ if [ "$(guestfish get-backend)" = "uml" ]; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$PWD/fake-virt-tools" d=test-v2v-i-ova-gz.d rm -rf $d diff --git a/v2v/test-v2v-i-ova-two-disks.sh b/v2v/test-v2v-i-ova-two-disks.sh index dfda956..ea50f16 100755 --- a/v2v/test-v2v-i-ova-two-disks.sh +++ b/v2v/test-v2v-i-ova-two-disks.sh @@ -32,11 +32,7 @@ if [ "$(guestfish get-backend)" = "uml" ]; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$PWD/fake-virt-tools" d=test-v2v-i-ova-two-disks.d rm -rf $d diff --git a/v2v/test-v2v-i-ova.sh b/v2v/test-v2v-i-ova.sh index 5047eca..1ec6cce 100755 --- a/v2v/test-v2v-i-ova.sh +++ b/v2v/test-v2v-i-ova.sh @@ -38,11 +38,7 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$PWD/fake-virt-tools" d=test-v2v-i-ova.d rm -rf $d diff --git a/v2v/test-v2v-networks-and-bridges.sh b/v2v/test-v2v-networks-and-bridges.sh index 68743d6..1c16640 100755 --- a/v2v/test-v2v-networks-and-bridges.sh +++ b/v2v/test-v2v-networks-and-bridges.sh @@ -41,11 +41,7 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$PWD/fake-virt-tools" d=test-v2v-networks-and-bridges.d rm -rf $d diff --git a/v2v/test-v2v-no-copy.sh b/v2v/test-v2v-no-copy.sh index f0408dc..647c668 100755 --- a/v2v/test-v2v-no-copy.sh +++ b/v2v/test-v2v-no-copy.sh @@ -41,11 +41,7 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$PWD/fake-virt-tools" d=test-v2v-no-copy.d rm -rf $d diff --git a/v2v/test-v2v-o-glance.sh b/v2v/test-v2v-o-glance.sh index 121177f..a08364b 100755 --- a/v2v/test-v2v-o-glance.sh +++ b/v2v/test-v2v-o-glance.sh @@ -41,11 +41,7 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$PWD/fake-virt-tools" # We don't want to upload to the real glance, so introduce a fake # glance binary. diff --git a/v2v/test-v2v-o-libvirt.sh b/v2v/test-v2v-o-libvirt.sh index a21f816..ac2862a 100755 --- a/v2v/test-v2v-o-libvirt.sh +++ b/v2v/test-v2v-o-libvirt.sh @@ -58,11 +58,7 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$PWD/fake-virt-tools" # Generate a random guest name. guestname=tmp-$(tr -cd 'a-f0-9' < /dev/urandom | head -c 8) diff --git a/v2v/test-v2v-o-null.sh b/v2v/test-v2v-o-null.sh index 9ed581b..4a95740 100755 --- a/v2v/test-v2v-o-null.sh +++ b/v2v/test-v2v-o-null.sh @@ -41,11 +41,7 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$PWD/fake-virt-tools" $VG virt-v2v --debug-gc \ -i libvirt -ic "$libvirt_uri" windows \ diff --git a/v2v/test-v2v-o-qemu.sh b/v2v/test-v2v-o-qemu.sh index 9de2b56..d6fb69f 100755 --- a/v2v/test-v2v-o-qemu.sh +++ b/v2v/test-v2v-o-qemu.sh @@ -41,11 +41,7 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$PWD/fake-virt-tools" d=test-v2v-o-qemu.d rm -rf $d diff --git a/v2v/test-v2v-o-rhev.sh b/v2v/test-v2v-o-rhev.sh index 1162e31..897a82d 100755 --- a/v2v/test-v2v-o-rhev.sh +++ b/v2v/test-v2v-o-rhev.sh @@ -41,11 +41,7 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$PWD/fake-virt-tools" d=test-v2v-o-rhev.d rm -rf $d diff --git a/v2v/test-v2v-o-vdsm-options.sh b/v2v/test-v2v-o-vdsm-options.sh index c170467..914c70a 100755 --- a/v2v/test-v2v-o-vdsm-options.sh +++ b/v2v/test-v2v-o-vdsm-options.sh @@ -41,11 +41,7 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$PWD/fake-virt-tools" d=test-v2v-o-vdsm-options.d rm -rf $d diff --git a/v2v/test-v2v-oa-option.sh b/v2v/test-v2v-oa-option.sh index c1a555a..4de80c0 100755 --- a/v2v/test-v2v-oa-option.sh +++ b/v2v/test-v2v-oa-option.sh @@ -41,11 +41,7 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$PWD/fake-virt-tools" d=test-v2v-windows-conversion.d rm -rf $d diff --git a/v2v/test-v2v-of-option.sh b/v2v/test-v2v-of-option.sh index 27441cf..dea3d40 100755 --- a/v2v/test-v2v-of-option.sh +++ b/v2v/test-v2v-of-option.sh @@ -41,11 +41,7 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$PWD/fake-virt-tools" d=test-v2v-windows-conversion.d rm -rf $d diff --git a/v2v/test-v2v-on-option.sh b/v2v/test-v2v-on-option.sh index e3edb67..3cca6c2 100755 --- a/v2v/test-v2v-on-option.sh +++ b/v2v/test-v2v-on-option.sh @@ -41,11 +41,7 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$PWD/fake-virt-tools" d=test-v2v-windows-conversion.d rm -rf $d diff --git a/v2v/test-v2v-sound.sh b/v2v/test-v2v-sound.sh index 7cb6f24..661a898 100755 --- a/v2v/test-v2v-sound.sh +++ b/v2v/test-v2v-sound.sh @@ -41,11 +41,7 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$PWD/fake-virt-tools" d=test-v2v-sound.d rm -rf $d diff --git a/v2v/test-v2v-windows-conversion.sh b/v2v/test-v2v-windows-conversion.sh index 7e8e628..1688d11 100755 --- a/v2v/test-v2v-windows-conversion.sh +++ b/v2v/test-v2v-windows-conversion.sh @@ -41,11 +41,7 @@ if ! test -f $f || ! test -s $f; then exit 77 fi -virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} -if ! test -r $virt_tools_data_dir/rhsrvany.exe; then - echo "$0: test skipped because rhsrvany.exe is not installed" - exit 77 -fi +export VIRT_TOOLS_DATA_DIR="$PWD/fake-virt-tools" # Return a random element from the array 'choices'. function random_choice -- 2.4.3
Without rhev-apt.exe the code path where firstboot scripts are created isn't taken, so it isn't tested and v2v/test-v2v-windows-conversion.sh is supposed to fail (it actually doesn't but for another reason, addressed in a followup patch). Signed-off-by: Roman Kagan <rkagan@virtuozzo.com> --- changes since v1: - relocated fake-virt-tools under v2v - packaged fake-virt-tools v2v/Makefile.am | 3 ++- v2v/fake-virt-tools/rhev-apt.exe | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 v2v/fake-virt-tools/rhev-apt.exe diff --git a/v2v/Makefile.am b/v2v/Makefile.am index e3fa1b5..9af5d2c 100644 --- a/v2v/Makefile.am +++ b/v2v/Makefile.am @@ -109,7 +109,8 @@ SOURCES_C = \ fake_virt_tools_dir = fake-virt-tools FAKE_VIRT_TOOLS = \ - $(fake_virt_tools_dir)/rhsrvany.exe + $(fake_virt_tools_dir)/rhsrvany.exe \ + $(fake_virt_tools_dir)/rhev-apt.exe if HAVE_OCAML diff --git a/v2v/fake-virt-tools/rhev-apt.exe b/v2v/fake-virt-tools/rhev-apt.exe new file mode 100644 index 0000000..2f472e5 --- /dev/null +++ b/v2v/fake-virt-tools/rhev-apt.exe @@ -0,0 +1 @@ +This is a fake rhev-apt.exe, used for testing only -- 2.4.3
Roman Kagan
2015-Oct-08 13:50 UTC
[Libguestfs] [PATCH v2 3/5] v2v:test:win: actually check the eventual layout
v2v/test-v2v-windows-conversion.sh used to query if the expected directories and files were present in the VM upon conversion; however it would ignore the results of that query. That lead to the test passing even though the checks failed. To fix it, parse the output of guestfish and verify that all is-file and is-dir commands report the expected "true". The approach taken is slightly more elaborate than what is being used in other components, but it allows to generate comprehensible reports in case of test failure, and facilitates future expansion of the set of checks including negative ones. Signed-off-by: Roman Kagan <rkagan@virtuozzo.com> --- changes since v1: - changed the way the presence of files in the guest is checked to address the comments to v1 v2v/test-v2v-windows-conversion.sh | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/v2v/test-v2v-windows-conversion.sh b/v2v/test-v2v-windows-conversion.sh index 1688d11..3e3d645 100755 --- a/v2v/test-v2v-windows-conversion.sh +++ b/v2v/test-v2v-windows-conversion.sh @@ -67,12 +67,31 @@ test -f $d/windows.xml test -f $d/windows-sda # Test some aspects of the target disk image. -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 +script="$d/test.fish" +expected="$d/expected" +response="$d/response" + +mktest () +{ + local cmd="$1" exp="$2" + + echo "echo '$cmd'" >> "$script" + echo "$cmd" >> "$expected" + + echo "$cmd" >> "$script" + echo "$exp" >> "$expected" +} + +:> "$script" +:> "$expected" + +mktest "is-dir \"/Program Files/Red Hat/Firstboot\"" true +mktest "is-file \"/Program Files/Red Hat/Firstboot/firstboot.bat\"" true +mktest "is-dir \"/Program Files/Red Hat/Firstboot/scripts\"" true +mktest "is-dir \"/Windows/Drivers/VirtIO\"" true + +guestfish --ro -a "$d/windows-sda" -i < "$script" > "$response" +diff -u "$expected" "$response" # We also update the Registry several times, for firstboot, and (ONLY # if the virtio-win drivers are installed locally) the critical device -- 2.4.3
Roman Kagan
2015-Oct-08 13:50 UTC
[Libguestfs] [PATCH v2 4/5] v2v:tests: use fake virtio-win drivers
In order to test the copying of virtio-win drivers into the guest during v2v, create a set of fake virtio-win drivers and make use of them in the corresponding v2v tests. Signed-off-by: Roman Kagan <rkagan@virtuozzo.com> --- changes since v1: - moved fake-virtio-win under v2v - referred to fake-virtio-win stuff via $PWD in test scripts - updated Makefile to package the newly added files (unreliable since make dist is still broken) v2v/Makefile.am | 4 ++++ v2v/fake-virtio-win/drivers/i386/Win7/netkvm.cat | 1 + v2v/fake-virtio-win/drivers/i386/Win7/netkvm.inf | 1 + v2v/fake-virtio-win/drivers/i386/Win7/netkvm.sys | 1 + v2v/fake-virtio-win/drivers/i386/Win7/qxl.cat | 1 + v2v/fake-virtio-win/drivers/i386/Win7/qxl.inf | 1 + v2v/fake-virtio-win/drivers/i386/Win7/qxl.sys | 1 + v2v/fake-virtio-win/drivers/i386/Win7/vioscsi.cat | 1 + v2v/fake-virtio-win/drivers/i386/Win7/vioscsi.inf | 1 + v2v/fake-virtio-win/drivers/i386/Win7/vioscsi.sys | 1 + v2v/fake-virtio-win/drivers/i386/Win7/viostor.cat | 1 + v2v/fake-virtio-win/drivers/i386/Win7/viostor.inf | 1 + v2v/fake-virtio-win/drivers/i386/Win7/viostor.sys | 1 + v2v/test-v2v-cdrom.sh | 1 + v2v/test-v2v-i-ova-two-disks.sh | 1 + v2v/test-v2v-i-ova.sh | 1 + v2v/test-v2v-windows-conversion.sh | 16 ++++++++++++---- 17 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 v2v/fake-virtio-win/drivers/i386/Win7/netkvm.cat create mode 100644 v2v/fake-virtio-win/drivers/i386/Win7/netkvm.inf create mode 100644 v2v/fake-virtio-win/drivers/i386/Win7/netkvm.sys create mode 100644 v2v/fake-virtio-win/drivers/i386/Win7/qxl.cat create mode 100644 v2v/fake-virtio-win/drivers/i386/Win7/qxl.inf create mode 100644 v2v/fake-virtio-win/drivers/i386/Win7/qxl.sys create mode 100644 v2v/fake-virtio-win/drivers/i386/Win7/vioscsi.cat create mode 100644 v2v/fake-virtio-win/drivers/i386/Win7/vioscsi.inf create mode 100644 v2v/fake-virtio-win/drivers/i386/Win7/vioscsi.sys create mode 100644 v2v/fake-virtio-win/drivers/i386/Win7/viostor.cat create mode 100644 v2v/fake-virtio-win/drivers/i386/Win7/viostor.inf create mode 100644 v2v/fake-virtio-win/drivers/i386/Win7/viostor.sys diff --git a/v2v/Makefile.am b/v2v/Makefile.am index 9af5d2c..159141f 100644 --- a/v2v/Makefile.am +++ b/v2v/Makefile.am @@ -22,6 +22,7 @@ EXTRA_DIST = \ v2v_unit_tests.ml \ $(TESTS) $(SLOW_TESTS) \ $(FAKE_VIRT_TOOLS) \ + $(FAKE_VIRTIO_WIN) \ HACKING \ test-v2v-cdrom.expected \ test-v2v-cdrom.xml \ @@ -112,6 +113,9 @@ FAKE_VIRT_TOOLS = \ $(fake_virt_tools_dir)/rhsrvany.exe \ $(fake_virt_tools_dir)/rhev-apt.exe +fake_virtio_win_dir = fake-virtio-win +FAKE_VIRTIO_WIN = $(wildcard $(fake_virtio_win_dir)/*/*/*/*) + if HAVE_OCAML bin_PROGRAMS = virt-v2v diff --git a/v2v/fake-virtio-win/drivers/i386/Win7/netkvm.cat b/v2v/fake-virtio-win/drivers/i386/Win7/netkvm.cat new file mode 100644 index 0000000..be81e94 --- /dev/null +++ b/v2v/fake-virtio-win/drivers/i386/Win7/netkvm.cat @@ -0,0 +1 @@ +This is a fake netkvm.cat, used for testing only diff --git a/v2v/fake-virtio-win/drivers/i386/Win7/netkvm.inf b/v2v/fake-virtio-win/drivers/i386/Win7/netkvm.inf new file mode 100644 index 0000000..ab4a68f --- /dev/null +++ b/v2v/fake-virtio-win/drivers/i386/Win7/netkvm.inf @@ -0,0 +1 @@ +This is a fake netkvm.inf, used for testing only diff --git a/v2v/fake-virtio-win/drivers/i386/Win7/netkvm.sys b/v2v/fake-virtio-win/drivers/i386/Win7/netkvm.sys new file mode 100644 index 0000000..3a2afae --- /dev/null +++ b/v2v/fake-virtio-win/drivers/i386/Win7/netkvm.sys @@ -0,0 +1 @@ +This is a fake netkvm.sys, used for testing only diff --git a/v2v/fake-virtio-win/drivers/i386/Win7/qxl.cat b/v2v/fake-virtio-win/drivers/i386/Win7/qxl.cat new file mode 100644 index 0000000..0af6a9a --- /dev/null +++ b/v2v/fake-virtio-win/drivers/i386/Win7/qxl.cat @@ -0,0 +1 @@ +This is a fake qxl.cat, used for testing only diff --git a/v2v/fake-virtio-win/drivers/i386/Win7/qxl.inf b/v2v/fake-virtio-win/drivers/i386/Win7/qxl.inf new file mode 100644 index 0000000..3fb759d --- /dev/null +++ b/v2v/fake-virtio-win/drivers/i386/Win7/qxl.inf @@ -0,0 +1 @@ +This is a fake qxl.inf, used for testing only diff --git a/v2v/fake-virtio-win/drivers/i386/Win7/qxl.sys b/v2v/fake-virtio-win/drivers/i386/Win7/qxl.sys new file mode 100644 index 0000000..118ede0 --- /dev/null +++ b/v2v/fake-virtio-win/drivers/i386/Win7/qxl.sys @@ -0,0 +1 @@ +This is a fake qxl.sys, used for testing only diff --git a/v2v/fake-virtio-win/drivers/i386/Win7/vioscsi.cat b/v2v/fake-virtio-win/drivers/i386/Win7/vioscsi.cat new file mode 100644 index 0000000..056535f --- /dev/null +++ b/v2v/fake-virtio-win/drivers/i386/Win7/vioscsi.cat @@ -0,0 +1 @@ +This is a fake vioscsi.cat, used for testing only diff --git a/v2v/fake-virtio-win/drivers/i386/Win7/vioscsi.inf b/v2v/fake-virtio-win/drivers/i386/Win7/vioscsi.inf new file mode 100644 index 0000000..97b3884 --- /dev/null +++ b/v2v/fake-virtio-win/drivers/i386/Win7/vioscsi.inf @@ -0,0 +1 @@ +This is a fake vioscsi.inf, used for testing only diff --git a/v2v/fake-virtio-win/drivers/i386/Win7/vioscsi.sys b/v2v/fake-virtio-win/drivers/i386/Win7/vioscsi.sys new file mode 100644 index 0000000..102a797 --- /dev/null +++ b/v2v/fake-virtio-win/drivers/i386/Win7/vioscsi.sys @@ -0,0 +1 @@ +This is a fake vioscsi.sys, used for testing only diff --git a/v2v/fake-virtio-win/drivers/i386/Win7/viostor.cat b/v2v/fake-virtio-win/drivers/i386/Win7/viostor.cat new file mode 100644 index 0000000..6c32f85 --- /dev/null +++ b/v2v/fake-virtio-win/drivers/i386/Win7/viostor.cat @@ -0,0 +1 @@ +This is a fake viostor.cat, used for testing only diff --git a/v2v/fake-virtio-win/drivers/i386/Win7/viostor.inf b/v2v/fake-virtio-win/drivers/i386/Win7/viostor.inf new file mode 100644 index 0000000..18f416d --- /dev/null +++ b/v2v/fake-virtio-win/drivers/i386/Win7/viostor.inf @@ -0,0 +1 @@ +This is a fake viostor.inf, used for testing only diff --git a/v2v/fake-virtio-win/drivers/i386/Win7/viostor.sys b/v2v/fake-virtio-win/drivers/i386/Win7/viostor.sys new file mode 100644 index 0000000..3f9c147 --- /dev/null +++ b/v2v/fake-virtio-win/drivers/i386/Win7/viostor.sys @@ -0,0 +1 @@ +This is a fake viostor.sys, used for testing only diff --git a/v2v/test-v2v-cdrom.sh b/v2v/test-v2v-cdrom.sh index 1b03b13..42c8347 100755 --- a/v2v/test-v2v-cdrom.sh +++ b/v2v/test-v2v-cdrom.sh @@ -49,6 +49,7 @@ if ! test -f $f || ! test -s $f; then fi export VIRT_TOOLS_DATA_DIR="$PWD/fake-virt-tools" +export VIRTIO_WIN="$PWD/fake-virtio-win" d=test-v2v-cdrom.d rm -rf $d diff --git a/v2v/test-v2v-i-ova-two-disks.sh b/v2v/test-v2v-i-ova-two-disks.sh index ea50f16..fc7ace7 100755 --- a/v2v/test-v2v-i-ova-two-disks.sh +++ b/v2v/test-v2v-i-ova-two-disks.sh @@ -33,6 +33,7 @@ if [ "$(guestfish get-backend)" = "uml" ]; then fi export VIRT_TOOLS_DATA_DIR="$PWD/fake-virt-tools" +export VIRTIO_WIN="$PWD/fake-virtio-win" d=test-v2v-i-ova-two-disks.d rm -rf $d diff --git a/v2v/test-v2v-i-ova.sh b/v2v/test-v2v-i-ova.sh index 1ec6cce..266382e 100755 --- a/v2v/test-v2v-i-ova.sh +++ b/v2v/test-v2v-i-ova.sh @@ -39,6 +39,7 @@ if ! test -f $f || ! test -s $f; then fi export VIRT_TOOLS_DATA_DIR="$PWD/fake-virt-tools" +export VIRTIO_WIN="$PWD/fake-virtio-win" d=test-v2v-i-ova.d rm -rf $d diff --git a/v2v/test-v2v-windows-conversion.sh b/v2v/test-v2v-windows-conversion.sh index 3e3d645..d086bc4 100755 --- a/v2v/test-v2v-windows-conversion.sh +++ b/v2v/test-v2v-windows-conversion.sh @@ -42,6 +42,7 @@ if ! test -f $f || ! test -s $f; then fi export VIRT_TOOLS_DATA_DIR="$PWD/fake-virt-tools" +export VIRTIO_WIN="$PWD/fake-virtio-win" # Return a random element from the array 'choices'. function random_choice @@ -85,10 +86,17 @@ mktest () :> "$script" :> "$expected" -mktest "is-dir \"/Program Files/Red Hat/Firstboot\"" true -mktest "is-file \"/Program Files/Red Hat/Firstboot/firstboot.bat\"" true -mktest "is-dir \"/Program Files/Red Hat/Firstboot/scripts\"" true -mktest "is-dir \"/Windows/Drivers/VirtIO\"" true +firstboot_dir="/Program Files/Red Hat/Firstboot" +mktest "is-dir \"$firstboot_dir\"" true +mktest "is-file \"$firstboot_dir/firstboot.bat\"" true +mktest "is-dir \"$firstboot_dir/scripts\"" true +virtio_dir="/Windows/Drivers/VirtIO" +mktest "is-dir \"$virtio_dir\"" true +for drv in netkvm qxl vioscsi viostor; do + for sfx in cat inf sys; do + mktest "is-file \"$virtio_dir/$drv.$sfx\"" true + done +done guestfish --ro -a "$d/windows-sda" -i < "$script" > "$response" diff -u "$expected" "$response" -- 2.4.3
Roman Kagan
2015-Oct-08 13:50 UTC
[Libguestfs] [PATCH v2 5/5] v2v: add test for v2v with virtio-win drivers on iso
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@virtuozzo.com> --- changes since v1: - moved fake-virtio-win.iso under v2v - updated the test in accordance with the preceding patches .gitignore | 1 + v2v/Makefile.am | 8 +++ v2v/test-v2v-virtio-win-iso.sh | 110 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+) create mode 100755 v2v/test-v2v-virtio-win-iso.sh diff --git a/.gitignore b/.gitignore index ff90f12..cb5bc49 100644 --- a/.gitignore +++ b/.gitignore @@ -594,6 +594,7 @@ Makefile.in /v2v/centos-6.img /v2v/centos-7.0.img /v2v/fedora-20.img +/v2v/fake-virtio-win.iso /v2v/oUnit-* /v2v/rhel-5.10.img /v2v/rhel-6.5.img diff --git a/v2v/Makefile.am b/v2v/Makefile.am index 159141f..7f30240 100644 --- a/v2v/Makefile.am +++ b/v2v/Makefile.am @@ -116,6 +116,13 @@ FAKE_VIRT_TOOLS = \ fake_virtio_win_dir = fake-virtio-win FAKE_VIRTIO_WIN = $(wildcard $(fake_virtio_win_dir)/*/*/*/*) +fake_virtio_win_iso = fake-virtio-win.iso +check_DATA = $(fake_virtio_win_iso) +CLEANFILES += $(fake_virtio_win_iso) + +$(fake_virtio_win_iso): $(FAKE_VIRTIO_WIN) + $(GENISOIMAGE) -J -r -o $@ $(fake_virtio_win_dir) + if HAVE_OCAML bin_PROGRAMS = virt-v2v @@ -259,6 +266,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..090025c --- /dev/null +++ b/v2v/test-v2v-virtio-win-iso.sh @@ -0,0 +1,110 @@ +#!/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="$PWD/fake-virt-tools" +export VIRTIO_WIN="$PWD/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 +script="$d/test.fish" +expected="$d/expected" +response="$d/response" + +mktest () +{ + local cmd="$1" exp="$2" + + echo "echo '$cmd'" >> "$script" + echo "$cmd" >> "$expected" + + echo "$cmd" >> "$script" + echo "$exp" >> "$expected" +} + +:> "$script" +:> "$expected" + +firstboot_dir="/Program Files/Red Hat/Firstboot" +mktest "is-dir \"$firstboot_dir\"" true +mktest "is-file \"$firstboot_dir/firstboot.bat\"" true +mktest "is-dir \"$firstboot_dir/scripts\"" true +virtio_dir="/Windows/Drivers/VirtIO" +mktest "is-dir \"$virtio_dir\"" true +for drv in netkvm qxl vioscsi viostor; do + for sfx in cat inf sys; do + mktest "is-file \"$virtio_dir/$drv.$sfx\"" true + done +done + +guestfish --ro -a "$d/windows-sda" -i < "$script" > "$response" +diff -u "$expected" "$response" + +rm -r $d -- 2.4.3
Reasonably Related Threads
- Re: [PATCH 3/6] v2v:test:win: actually check the eventual layout
- Re: [PATCH 3/6] v2v:test:win: actually check the eventual layout
- [PATCH 3/6] v2v:test:win: actually check the eventual layout
- Re: [PATCH 3/6] v2v:test:win: actually check the eventual layout
- [PATCH 0/6] v2v: assorted improvements to tests for windows