[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
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.sh
This 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
On Mon, Oct 05, 2015 at 02:17:52PM +0100, Richard W.M. Jones wrote:
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
This wasn't my invention: somehow *all* 15 tests under v2v which used $abs_top_builddir or $abs_builddir obtained them exactly like I did in the patch. Want me to fix them all? Will probably be another patch, then.
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
This doesn't appear in EXTRA_DIST, so it won't be copied to the tarball.
Didn't know that. How is the tarball generated, so that I can test it before the next submission?
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.
rhsrvany.exe is used outside v2v, too (customize, sysprep, etc.). So I thought the fake stuff would be generally useful, not limited to v2v. Moreover the tests in p2v already have the same logic, which I patch here, too; should I drop them from the patch and revert to the original logic? Roman.
On Mon, Oct 05, 2015 at 06:12:03PM +0300, Roman Kagan wrote:
On Mon, Oct 05, 2015 at 02:17:52PM +0100, Richard W.M. Jones wrote:
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
This wasn't my invention: somehow *all* 15 tests under v2v which used $abs_top_builddir or $abs_builddir obtained them exactly like I did in the patch. Want me to fix them all? Will probably be another patch, then.
Ah I see - in that case you can leave it as you had it before, or change all of the tests, as you see fit.
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
This doesn't appear in EXTRA_DIST, so it won't be copied to the tarball.
Didn't know that. How is the tarball generated, so that I can test it before the next submission?
It's quite a common problem - we always forget it too. Do this command to see what gets included in the tarball: make dist tar ztf libguestfs-1.31.*.tar.gz | sort | less Also you can use: make dist make maintainer-check-extra-dist
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.
rhsrvany.exe is used outside v2v, too (customize, sysprep, etc.). So I thought the fake stuff would be generally useful, not limited to v2v.
Moreover the tests in p2v already have the same logic, which I patch here, too; should I drop them from the patch and revert to the original logic?
OK I see; probably still better for it to be under v2v/ or customize/ .. in any case, not another directory under tests/. Using tests/guests was a mistake by us. 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
On Mon, Oct 05, 2015 at 05:05:32PM +0100, Richard W.M. Jones wrote:
On Mon, Oct 05, 2015 at 06:12:03PM +0300, Roman Kagan wrote:
On Mon, Oct 05, 2015 at 02:17:52PM +0100, Richard W.M. Jones wrote:
This doesn't appear in EXTRA_DIST, so it won't be copied to the tarball.
Didn't know that. How is the tarball generated, so that I can test it before the next submission?
It's quite a common problem - we always forget it too. Do this command to see what gets included in the tarball:
make dist tar ztf libguestfs-1.31.*.tar.gz | sort | less
Also you can use:
make dist make maintainer-check-extra-dist
I can't get past make dist: # make V=1 INSTALLDIRS=vendor dist make dist-gzip am__post_remove_distdir='@:' make[1]: Entering directory '/home/rkagan/work/git/libguestfs' if test -d "libguestfs-1.31.11"; then find "libguestfs-1.31.11" -type d ! -perm -200 -exec chmod u+w {} ';' && rm -rf "libguestfs-1.31.11" || { sleep 5 && rm -rf "libguestfs-1.31.11"; }; else :; fi test -d "libguestfs-1.31.11" || mkdir "libguestfs-1.31.11" (cd gnulib/lib && make top_distdir=../../libguestfs-1.31.11 distdir=../../libguestfs-1.31.11/gnulib/lib \ am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir) make[2]: Entering directory '/home/rkagan/work/git/libguestfs/gnulib/lib' make[2]: Leaving directory '/home/rkagan/work/git/libguestfs/gnulib/lib' (cd gnulib/tests && make top_distdir=../../libguestfs-1.31.11 distdir=../../libguestfs-1.31.11/gnulib/tests \ am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir) make[2]: Entering directory '/home/rkagan/work/git/libguestfs/gnulib/tests' make[2]: Leaving directory '/home/rkagan/work/git/libguestfs/gnulib/tests' (cd tests/data && make top_distdir=../../libguestfs-1.31.11 distdir=../../libguestfs-1.31.11/tests/data \ am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir) make[2]: Entering directory '/home/rkagan/work/git/libguestfs/tests/data' make[2]: Leaving directory '/home/rkagan/work/git/libguestfs/tests/data' (cd generator && make top_distdir=../libguestfs-1.31.11 distdir=../libguestfs-1.31.11/generator \ am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir) make[2]: Entering directory '/home/rkagan/work/git/libguestfs/generator' make[2]: Leaving directory '/home/rkagan/work/git/libguestfs/generator' (cd src && make top_distdir=../libguestfs-1.31.11 distdir=../libguestfs-1.31.11/src \ am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir) make[2]: Entering directory '/home/rkagan/work/git/libguestfs/src' make[2]: Leaving directory '/home/rkagan/work/git/libguestfs/src' (cd examples && make top_distdir=../libguestfs-1.31.11 distdir=../libguestfs-1.31.11/examples \ am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir) make[2]: Entering directory '/home/rkagan/work/git/libguestfs/examples' make[2]: Leaving directory '/home/rkagan/work/git/libguestfs/examples' (cd po && make top_distdir=../libguestfs-1.31.11 distdir=../libguestfs-1.31.11/po \ am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir) make[2]: Entering directory '/home/rkagan/work/git/libguestfs/po' rm -f uk.gmo uk.gmo-t /usr/bin/msgfmt -c -o uk.gmo-t ./uk.po ./uk.po:998: 'msgid' and 'msgstr' entries do not both end with '\n' ./uk.po:9426: format specifications in 'msgid' and 'msgstr' for argument 2 are not the same /usr/bin/msgfmt: found 2 fatal errors Makefile:1713: recipe for target 'uk.gmo' failed make[2]: *** [uk.gmo] Error 1 make[2]: Leaving directory '/home/rkagan/work/git/libguestfs/po' Makefile:2027: recipe for target 'distdir' failed make[1]: *** [distdir] Error 1 make[1]: Leaving directory '/home/rkagan/work/git/libguestfs' Makefile:2129: recipe for target 'dist' failed make: *** [dist] Error 2 Any suggestion on where to look?
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.
rhsrvany.exe is used outside v2v, too (customize, sysprep, etc.). So I thought the fake stuff would be generally useful, not limited to v2v.
Moreover the tests in p2v already have the same logic, which I patch here, too; should I drop them from the patch and revert to the original logic?
OK I see; probably still better for it to be under v2v/ or customize/ .. in any case, not another directory under tests/. Using tests/guests was a mistake by us.
OK I'll try to cook up something like this. Is it OK to use v2v test stuff in, say, p2v? Or may be I just do this all under v2v and leave p2v alone? Roman.
On Tue, Oct 06, 2015 at 05:24:41PM +0300, Roman Kagan wrote:
I can't get past make dist:
# make V=1 INSTALLDIRS=vendor dist [...] rm -f uk.gmo uk.gmo-t /usr/bin/msgfmt -c -o uk.gmo-t ./uk.po ./uk.po:998: 'msgid' and 'msgstr' entries do not both end with '\n' ./uk.po:9426: format specifications in 'msgid' and 'msgstr' for argument 2 are not the same /usr/bin/msgfmt: found 2 fatal errors Makefile:1713: recipe for target 'uk.gmo' failed make[2]: *** [uk.gmo] Error 1 make[2]: Leaving directory '/home/rkagan/work/git/libguestfs/po' Makefile:2027: recipe for target 'distdir' failed make[1]: *** [distdir] Error 1 make[1]: Leaving directory '/home/rkagan/work/git/libguestfs' Makefile:2129: recipe for target 'dist' failed make: *** [dist] Error 2
Any suggestion on where to look?
This is a bug I introduced yesterday (commit fe4630e0332fecec4482061054063f217daef265). Just reverting that commit should make it work for now.
OK I'll try to cook up something like this. Is it OK to use v2v test stuff in, say, p2v? Or may be I just do this all under v2v and leave p2v alone?
Totally fine. Thanks, Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v
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
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.3
As 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
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
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
On Mon, Oct 05, 2015 at 02:50:52PM +0200, Pino Toscano wrote:
On Monday 05 October 2015 15:40:03 Roman Kagan wrote:
+{ 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".
Yes I have seen it but exactly because I foresee nothing but "true" in guestfish's output I want to avoid tedious beancounting when maintaining the expected result string.
+(( PIPESTATUS[0] == 0 ))
set -o pipefail (which is bash-specific)
I don't mind this change; want me to resubmit with it? Roman.
On Monday 05 October 2015 16:05:54 Roman Kagan wrote:
On Mon, Oct 05, 2015 at 02:50:52PM +0200, Pino Toscano wrote:
On Monday 05 October 2015 15:40:03 Roman Kagan wrote:
+{ 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".
Yes I have seen it but exactly because I foresee nothing but "true" in guestfish's output I want to avoid tedious beancounting when maintaining the expected result string.
Never say never... really, better make it slightly more generic, so expanding it later is no hassle. Also, comparing to the exact output expected is a check more that we got the number of lines expected.
+(( PIPESTATUS[0] == 0 ))
set -o pipefail (which is bash-specific)
I don't mind this change; want me to resubmit with it?
Yes, with the aforementioned change of the output check, which could make checking for the pipe status no more needed. Thanks, -- Pino Toscano
On Mon, Oct 05, 2015 at 03:19:21PM +0200, Pino Toscano wrote:
On Monday 05 October 2015 16:05:54 Roman Kagan wrote:
On Mon, Oct 05, 2015 at 02:50:52PM +0200, Pino Toscano wrote:
On Monday 05 October 2015 15:40:03 Roman Kagan wrote:
+{ 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".
Yes I have seen it but exactly because I foresee nothing but "true" in guestfish's output I want to avoid tedious beancounting when maintaining the expected result string.
Never say never... really, better make it slightly more generic, so expanding it later is no hassle.
It sure is. E.g. in another patch in the series I add more is-file commands here, and I generate them with a shell "for" loop; a constant string for the expected reply with a dozen of "true" lines would look weird IMO.
Also, comparing to the exact output expected is a check more that we got the number of lines expected.
This is rather a check for guestfish which we assume already tested here. Roman.
On Monday 05 October 2015 16:34:31 Roman Kagan wrote:
On Mon, Oct 05, 2015 at 03:19:21PM +0200, Pino Toscano wrote:
On Monday 05 October 2015 16:05:54 Roman Kagan wrote:
On Mon, Oct 05, 2015 at 02:50:52PM +0200, Pino Toscano wrote:
On Monday 05 October 2015 15:40:03 Roman Kagan wrote:
+{ 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".
Yes I have seen it but exactly because I foresee nothing but "true" in guestfish's output I want to avoid tedious beancounting when maintaining the expected result string.
Never say never... really, better make it slightly more generic, so expanding it later is no hassle.
It sure is. E.g. in another patch in the series I add more is-file commands here, and I generate them with a shell "for" loop; a constant string for the expected reply with a dozen of "true" lines would look weird IMO.
Again: what if tomorrow we add checks that output something different than "true"? Also, printing all the output on error would help in debugging eventual failures of this guestfish run.
Also, comparing to the exact output expected is a check more that we got the number of lines expected.
This is rather a check for guestfish which we assume already tested here.
More checks don't hurt, I'd say. -- Pino Toscano
On Mon, Oct 05, 2015 at 03:42:46PM +0200, Pino Toscano wrote:
On Monday 05 October 2015 16:34:31 Roman Kagan wrote:
On Mon, Oct 05, 2015 at 03:19:21PM +0200, Pino Toscano wrote:
On Monday 05 October 2015 16:05:54 Roman Kagan wrote:
On Mon, Oct 05, 2015 at 02:50:52PM +0200, Pino Toscano wrote:
On Monday 05 October 2015 15:40:03 Roman Kagan wrote:
+{ 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".
Yes I have seen it but exactly because I foresee nothing but "true" in guestfish's output I want to avoid tedious beancounting when maintaining the expected result string.
Never say never... really, better make it slightly more generic, so expanding it later is no hassle.
It sure is. E.g. in another patch in the series I add more is-file commands here, and I generate them with a shell "for" loop; a constant string for the expected reply with a dozen of "true" lines would look weird IMO.
Again: what if tomorrow we add checks that output something different than "true"?
We'll address that tomorrow when we see the demand. ATM there's a demand to add more "true" lines, and do so programmatically; a constant expected reply string is a poor fit for this job.
Also, printing all the output on error would help in debugging eventual failures of this guestfish run.
It wouldn't as you have no means to match the path to the result of the check.
Also, comparing to the exact output expected is a check more that we got the number of lines expected.
This is rather a check for guestfish which we assume already tested here.
More checks don't hurt, I'd say.
They sure do if they add maintenance cost at little testing value. Roman.
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
On Mon, Oct 05, 2015 at 02:24:18PM +0100, Richard W.M. Jones wrote:
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
This actually falls into two questions: how to match the expected output and how to report the failure. For the former, Pino has made a similar argument; however, considering the next patch in the series, "[PATCH 4/6] tests: use fake virtio-win drivers", I think that using a constant string for the expected output would look even uglier. For the latter, I toggled tracing on and off around the guestfish commands exactly to make the relevant report appear in case of a failure: you can see individually which files or directories are missing. Here's a sample output generated when qxl.sys is removed from the source directory: # make V=1 INSTALLDIRS=vendor -j32 -C v2v check TESTS=test-v2v-windows-conversion.sh make: Entering directory '/home/rkagan/work/git/libguestfs/v2v' make make[1]: Entering directory '/home/rkagan/work/git/libguestfs/v2v' make[1]: Nothing to be done for 'all'. make[1]: Leaving directory '/home/rkagan/work/git/libguestfs/v2v' make check-TESTS make[1]: Entering directory '/home/rkagan/work/git/libguestfs/v2v' /home/rkagan/work/git/libguestfs/run --test ./test-v2v-windows-conversion.sh [ 0.0] Opening the source -i libvirt -ic test:///home/rkagan/work/git/libguestfs/tests/guests/guests.xml windows [ 0.0] Creating an overlay to protect the source from being modified [ 0.3] Opening the overlay [ 5.1] Initializing the target -o local -os test-v2v-windows-conversion.d [ 5.1] Inspecting the overlay [ 5.6] Checking for sufficient free disk space in the guest [ 5.6] Estimating space required on target for each disk [ 5.6] Converting Microsoft Windows 7 Phony Edition to run on KVM virt-v2v: This guest has virtio drivers installed. [ 5.8] Mapping filesystem data to avoid copying unused and blank areas [ 5.9] Closing the overlay [ 6.0] Checking if the guest needs BIOS or UEFI to boot [ 6.0] Assigning disks to buses [ 6.0] Copying disk 1/1 to test-v2v-windows-conversion.d/windows-sda (raw) (100.00/100%) [ 6.2] Creating output metadata [ 6.2] Finishing off libguestfs: trace: is_dir "/Program Files/Red Hat/Firstboot" libguestfs: trace: is_dir = 1 libguestfs: trace: is_file "/Program Files/Red Hat/Firstboot/firstboot.bat" libguestfs: trace: is_file = 1 libguestfs: trace: is_dir "/Program Files/Red Hat/Firstboot/scripts" libguestfs: trace: is_dir = 1 libguestfs: trace: is_dir "/Windows/Drivers/VirtIO" libguestfs: trace: is_dir = 1 libguestfs: trace: is_file "/Windows/Drivers/VirtIO/netkvm.cat" libguestfs: trace: is_file = 1 libguestfs: trace: is_file "/Windows/Drivers/VirtIO/netkvm.inf" libguestfs: trace: is_file = 1 libguestfs: trace: is_file "/Windows/Drivers/VirtIO/netkvm.sys" libguestfs: trace: is_file = 1 libguestfs: trace: is_file "/Windows/Drivers/VirtIO/qxl.cat" libguestfs: trace: is_file = 1 libguestfs: trace: is_file "/Windows/Drivers/VirtIO/qxl.inf" libguestfs: trace: is_file = 1 libguestfs: trace: is_file "/Windows/Drivers/VirtIO/qxl.sys" libguestfs: trace: is_file = 0 libguestfs: trace: is_file "/Windows/Drivers/VirtIO/vioscsi.cat" libguestfs: trace: is_file = 1 libguestfs: trace: is_file "/Windows/Drivers/VirtIO/vioscsi.inf" libguestfs: trace: is_file = 1 libguestfs: trace: is_file "/Windows/Drivers/VirtIO/vioscsi.sys" libguestfs: trace: is_file = 1 libguestfs: trace: is_file "/Windows/Drivers/VirtIO/viostor.cat" libguestfs: trace: is_file = 1 libguestfs: trace: is_file "/Windows/Drivers/VirtIO/viostor.inf" libguestfs: trace: is_file = 1 libguestfs: trace: is_file "/Windows/Drivers/VirtIO/viostor.sys" libguestfs: trace: is_file = 1 libguestfs: trace: set_trace false libguestfs: trace: set_trace = 0 /home/rkagan/work/git/libguestfs/run: command failed with exit code 1 FAIL: test-v2v-windows-conversion.sh ================== 1 of 1 test failed ================== Makefile:2186: recipe for target 'check-TESTS' failed make[1]: *** [check-TESTS] Error 1 make[1]: Leaving directory '/home/rkagan/work/git/libguestfs/v2v' Makefile:2309: recipe for target 'check-am' failed make: *** [check-am] Error 2 make: Leaving directory '/home/rkagan/work/git/libguestfs/v2v' # I tend to think it's more comprehensible than the proposed ... test-v2v-windows-conversion.sh: test output was: true true true true true true true true true false true true true true true true ... Roman.
It's consistent with how we do it everywhere else (see for example: fish/test-copy.sh), but if having a long list of 'true' words is a problem you could also do: output=$( guestfish --ro -a $d/windows-sda -i <<EOF !echo "dir Firstboot" is-dir "/Program Files/Red Hat/Firstboot" ... ) if [ "$output" != "dir Firstboot true ... " ]; then ... Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v
The specific problem with enabling trace around "certain" commands is that we very often run the tests with LIBGUESTFS_TRACE=1 LIBGUESTFS_DEBUG=1 in the environment. In this case that doesn't make very much of a difference, except you're turning off trace at the end of the test when the person running the tests wanted it to be left on. 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
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
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
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
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
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
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
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
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
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
I'm just testing patches 1-3, and if they pass I will push them. On Thu, Oct 08, 2015 at 04:50:35PM +0300, Roman Kagan wrote:
+fake_virtio_win_dir = fake-virtio-win +FAKE_VIRTIO_WIN = $(wildcard $(fake_virtio_win_dir)/*/*/*/*)
Why the fake_virtio_win_dir variable? Unfortunately automake treats variables that have '*dir' in the name specially, but in this case I don't think you intended that. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v
On Thu, Oct 08, 2015 at 03:53:24PM +0100, Richard W.M. Jones wrote:
I'm just testing patches 1-3, and if they pass I will push them.
On Thu, Oct 08, 2015 at 04:50:35PM +0300, Roman Kagan wrote:
+fake_virtio_win_dir = fake-virtio-win +FAKE_VIRTIO_WIN = $(wildcard $(fake_virtio_win_dir)/*/*/*/*)
Why the fake_virtio_win_dir variable? Unfortunately automake treats variables that have '*dir' in the name specially, but in this case I don't think you intended that.
Absolutely not. I'm basically uninitiated in auto-foo and had no idea this could mean anything special to automake; I just needed a simple make variable. I've checked that it propagated as I expected into Makefile.in and then into Makefile, and that looked like enough to me. BTW patch 1 introduces fake_virt_tools_dir which probably has the same concern, doesn't it? Roman.
On Thu, Oct 08, 2015 at 06:16:18PM +0300, Roman Kagan wrote:
On Thu, Oct 08, 2015 at 03:53:24PM +0100, Richard W.M. Jones wrote:
I'm just testing patches 1-3, and if they pass I will push them.
On Thu, Oct 08, 2015 at 04:50:35PM +0300, Roman Kagan wrote:
+fake_virtio_win_dir = fake-virtio-win +FAKE_VIRTIO_WIN = $(wildcard $(fake_virtio_win_dir)/*/*/*/*)
Why the fake_virtio_win_dir variable? Unfortunately automake treats variables that have '*dir' in the name specially, but in this case I don't think you intended that.
Absolutely not. I'm basically uninitiated in auto-foo and had no idea this could mean anything special to automake; I just needed a simple make variable. I've checked that it propagated as I expected into Makefile.in and then into Makefile, and that looked like enough to me.
BTW patch 1 introduces fake_virt_tools_dir which probably has the same concern, doesn't it?
Yes I think it possibly does. I hate autotools too, but the alternatives are worse. I will push 4 & 5 shortly, and will then take a closer look at whether the _dir variable is a problem. Thanks, 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
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
This one looks OK too, so 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
participants (3)
-
Pino Toscano -
Richard W.M. Jones -
Roman Kagan