[Libguestfs] [PATCH v2 11/14] Convert all OCaml virt-* tools to use the test harness.

Richard W.M. Jones rjones at redhat.com
Fri Jul 31 15:13:32 UTC 2015


---
 .gitignore                                   |   4 +-
 builder/Makefile.am                          |  33 ++-----
 builder/test-virt-builder-list.sh            |   2 -
 builder/test-virt-builder.sh                 |  22 ++---
 builder/test-virt-index-validate.sh          |   8 +-
 builder/tests.mk                             |  77 +++++++++++++++
 builder/website/Makefile.am                  |  10 +-
 builder/website/tests.mk                     |  67 +++++++++++++
 configure.ac                                 |   2 +
 customize/Makefile.am                        |  16 +---
 customize/test-virt-customize.sh             |   2 +-
 customize/tests.mk                           |  60 ++++++++++++
 generator/tests.ml                           | 138 +++++++++++++++++++++++++++
 mllib/Makefile.am                            |  17 +---
 mllib/tests.mk                               |  64 +++++++++++++
 resize/Makefile.am                           |  16 +---
 resize/tests.mk                              |  60 ++++++++++++
 sparsify/Makefile.am                         |  17 +---
 sparsify/test-virt-sparsify-in-place.sh      |   5 -
 sparsify/tests.mk                            |  61 ++++++++++++
 sysprep/Makefile.am                          |  29 ++----
 sysprep/script1.sh                           |   2 +-
 sysprep/script2.sh                           |   2 +-
 sysprep/script4.sh                           |   2 +-
 sysprep/test-virt-sysprep-local-guests.sh.in |  24 +++++
 sysprep/test-virt-sysprep-passwords.sh       |   4 +-
 sysprep/test-virt-sysprep-script.sh          |  13 +--
 sysprep/tests.mk                             |  69 ++++++++++++++
 v2v/Makefile.am                              | 104 +-------------------
 v2v/test-v2v-cdrom.sh                        |  12 +--
 v2v/test-v2v-i-disk.sh                       |   7 +-
 v2v/test-v2v-i-ova-formats.sh                |  15 +--
 v2v/test-v2v-i-ova-gz.sh                     |   9 +-
 v2v/test-v2v-i-ova-two-disks.sh              |   9 +-
 v2v/test-v2v-i-ova.sh                        |  11 +--
 v2v/test-v2v-machine-readable.sh             |   5 -
 v2v/test-v2v-networks-and-bridges.sh         |  10 +-
 v2v/test-v2v-no-copy.sh                      |   8 +-
 v2v/test-v2v-o-glance.sh                     |   9 +-
 v2v/test-v2v-o-libvirt.sh                    |   8 +-
 v2v/test-v2v-o-null.sh                       |   8 +-
 v2v/test-v2v-o-qemu.sh                       |   8 +-
 v2v/test-v2v-o-rhev.sh                       |   8 +-
 v2v/test-v2v-o-vdsm-options.sh               |   8 +-
 v2v/test-v2v-of-option.sh                    |   8 +-
 v2v/test-v2v-on-option.sh                    |   8 +-
 v2v/test-v2v-print-source.sh                 |   8 +-
 v2v/test-v2v-real-conversions.sh             |  43 ++++-----
 v2v/test-v2v-sound.sh                        |   8 +-
 v2v/test-v2v-windows-conversion.sh           |   8 +-
 v2v/tests.mk                                 | 104 ++++++++++++++++++++
 51 files changed, 836 insertions(+), 416 deletions(-)
 create mode 100644 builder/tests.mk
 create mode 100644 builder/website/tests.mk
 create mode 100644 customize/tests.mk
 create mode 100644 mllib/tests.mk
 create mode 100644 resize/tests.mk
 create mode 100644 sparsify/tests.mk
 create mode 100755 sysprep/test-virt-sysprep-local-guests.sh.in
 create mode 100644 sysprep/tests.mk
 create mode 100644 v2v/tests.mk

diff --git a/.gitignore b/.gitignore
index ad40bff..5bbf80f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -486,12 +486,10 @@ Makefile.in
 /stamp-guestfs-release-notes.pod
 /stamp-h1
 /sysprep/.depend
-/sysprep/stamp-script1.sh
-/sysprep/stamp-script2.sh
-/sysprep/stamp-script4.sh
 /sysprep/stamp-virt-sysprep.pod
 /sysprep/sysprep-extra-options.pod
 /sysprep/sysprep-operations.pod
+/sysprep/test-virt-sysprep-local-guests.sh
 /sysprep/virt-sysprep
 /sysprep/virt-sysprep.1
 /test.err
diff --git a/builder/Makefile.am b/builder/Makefile.am
index 597b943..9d079fa 100644
--- a/builder/Makefile.am
+++ b/builder/Makefile.am
@@ -15,13 +15,16 @@
 # 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
-
 AM_YFLAGS = -d
 
+include $(top_srcdir)/subdir-rules.mk
+
+generator_built = tests.mk
+
 EXTRA_DIST = \
 	$(SOURCES_MLI) $(SOURCES_ML) $(SOURCES_C) \
 	libguestfs.gpg \
+	tests.mk \
 	test-index \
 	test-virt-builder.sh \
 	test-virt-builder-list.sh \
@@ -205,18 +208,10 @@ stamp-virt-builder.pod: virt-builder.pod $(top_srcdir)/customize/customize-synop
 
 CLEANFILES += stamp-virt-builder.pod
 
-# Tests.
-
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
-
-disk_images := \
-	$(shell for f in debian fedora ubuntu windows; do if [ -s "../tests/guests/$$f.img" ]; then echo $$f.xz; fi; done) \
-	$(shell if [ -s "../tests/guests/fedora.img" ]; then echo fedora.qcow2 fedora.qcow2.xz; fi)
+# Disk images for tests.
 
 CLEANFILES += *.qcow2 *.xz
 
-check_DATA = $(disk_images)
-
 fedora.qcow2: ../tests/guests/fedora.img
 	rm -f $@ $@-t
 	qemu-img convert -f raw -O qcow2 $< $@-t
@@ -232,20 +227,6 @@ fedora.qcow2.xz: fedora.qcow2
 	xz --best -c $< > $@-t
 	mv $@-t $@
 
-TESTS = \
-	test-virt-builder-list.sh \
-	test-virt-index-validate.sh
-
-if ENABLE_APPLIANCE
-TESTS += test-virt-builder.sh
-endif ENABLE_APPLIANCE
-
-check-valgrind:
-	$(MAKE) VG="$(top_builddir)/run @VG@" check
-
-check-slow:
-	$(MAKE) TESTS="test-virt-builder-planner.sh" check
-
 # Dependencies.
 depend: .depend
 
@@ -330,3 +311,5 @@ endif
 # in the distribution, so just remove them from the distdir.
 dist-hook:
 	rm -f $(distdir)/index-parse.c $(distdir)/index-parse.h $(distdir)/index-scan.c
+
+include $(srcdir)/tests.mk
diff --git a/builder/test-virt-builder-list.sh b/builder/test-virt-builder-list.sh
index 2b6dfad..e42e3ec 100755
--- a/builder/test-virt-builder-list.sh
+++ b/builder/test-virt-builder-list.sh
@@ -21,8 +21,6 @@
 export LANG=C
 set -e
 
-abs_builddir=$(pwd)
-
 export XDG_CONFIG_HOME=
 export XDG_CONFIG_DIRS="$abs_builddir/test-config"
 
diff --git a/builder/test-virt-builder.sh b/builder/test-virt-builder.sh
index f357d12..c6e99c4 100755
--- a/builder/test-virt-builder.sh
+++ b/builder/test-virt-builder.sh
@@ -19,17 +19,10 @@
 export LANG=C
 set -e
 
-abs_builddir=$(pwd)
-
 export XDG_CONFIG_HOME=
 export XDG_CONFIG_DIRS="$abs_builddir/test-config"
 
-if [ -n "$SKIP_TEST_VIRT_BUILDER_SH" ]; then
-    echo "$0: skipping test because environment variable is set."
-    exit 77
-fi
-
-if [ ! -f fedora.xz ]; then
+if [ ! -f $builddir/fedora.xz ]; then
     echo "$0: test skipped because there is no fedora.xz in the build directory"
     exit 77
 fi
@@ -64,19 +57,20 @@ $VG virt-builder phony-fedora \
     --root-password password:123456 \
     --mkdir /etc/foo/bar/baz \
     --write '/etc/foo/bar/baz/foo:Hello World' \
-    --upload Makefile:/Makefile \
-    --edit '/Makefile: s{^#.*}{}' \
-    --upload Makefile:/etc/foo/bar/baz \
-    --delete /Makefile \
+    --upload $srcdir/test-virt-builder.sh:/test \
+    --edit '/test: s{^#.*}{}' \
+    --upload $srcdir/test-virt-builder.sh:/etc/foo/bar/baz \
+    --delete /test \
     --link /etc/foo/bar/baz/foo:/foo \
     --link /etc/foo/bar/baz/foo:/foo1:/foo2:/foo3 \
-    --firstboot Makefile --firstboot-command 'echo "hello"' \
+    --firstboot $srcdir/test-virt-builder.sh \
+    --firstboot-command 'echo "hello"' \
     --firstboot-install "minicom,inkscape"
 
 # Check that some modifications were made.
 $VG guestfish --ro -i -a $output > test.out <<EOF
 # Uploaded files
-is-file /etc/foo/bar/baz/Makefile
+is-file /etc/foo/bar/baz/test-virt-builder.sh
 cat /etc/foo/bar/baz/foo
 is-symlink /foo
 is-symlink /foo1
diff --git a/builder/test-virt-index-validate.sh b/builder/test-virt-index-validate.sh
index b00a086..0e65591 100755
--- a/builder/test-virt-index-validate.sh
+++ b/builder/test-virt-index-validate.sh
@@ -19,7 +19,7 @@
 export LANG=C
 set -e
 
-! $VG virt-index-validate test-virt-index-validate-bad-1
-$VG virt-index-validate test-virt-index-validate-good-1
-$VG virt-index-validate test-virt-index-validate-good-2
-$VG virt-index-validate test-virt-index-validate-good-3
+! $VG virt-index-validate $srcdir/test-virt-index-validate-bad-1
+$VG virt-index-validate $srcdir/test-virt-index-validate-good-1
+$VG virt-index-validate $srcdir/test-virt-index-validate-good-2
+$VG virt-index-validate $srcdir/test-virt-index-validate-good-3
diff --git a/builder/tests.mk b/builder/tests.mk
new file mode 100644
index 0000000..0c26936
--- /dev/null
+++ b/builder/tests.mk
@@ -0,0 +1,77 @@
+# libguestfs generated file
+# WARNING: THIS FILE IS GENERATED FROM:
+#   generator/ *.ml
+# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
+#
+# Copyright (C) 2009-2015 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+localtestsdir = $(alltestsdir)/builder
+
+localtests_DATA = \
+	debian.xz \
+	fedora.qcow2 \
+	fedora.qcow2.xz \
+	fedora.xz \
+	ubuntu.xz \
+	windows.xz
+
+localtests_SCRIPTS = \
+	test-virt-builder-list.sh \
+	test-virt-builder-planner.sh \
+	test-virt-builder.sh \
+	test-virt-index-validate.sh
+
+# Note that we cannot create a simple 'check:' target since
+# automake will (silently) overrule it, so we do this instead:
+
+TESTS_ENVIRONMENT = $(top_builddir)/run
+TESTS = $(top_builddir)/test-harness
+
+check-valgrind:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind
+
+check-direct:
+	$(top_builddir)/run $(top_builddir)/test-harness --direct
+
+check-valgrind-direct:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct
+
+check-libvirt:
+	$(top_builddir)/run $(top_builddir)/test-harness --libvirt
+
+check-valgrind-libvirt:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt
+
+check-uml:
+	$(top_builddir)/run $(top_builddir)/test-harness --uml
+
+check-valgrind-uml:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml
+
+check-with-upstream-qemu:
+	$(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu
+
+check-with-upstream-libvirt:
+	$(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt
+
+check-fast:
+	$(top_builddir)/run $(top_builddir)/test-harness --fast
+
+check-slow:
+	$(top_builddir)/run $(top_builddir)/test-harness --slow
+
+EXTRA_DIST += tests.mk
diff --git a/builder/website/Makefile.am b/builder/website/Makefile.am
index 4a65156..0b678af 100644
--- a/builder/website/Makefile.am
+++ b/builder/website/Makefile.am
@@ -17,9 +17,12 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
+generator_built = tests.mk
+
 EXTRA_DIST = \
 	.gitignore \
 	compress.sh \
+	tests.mk \
 	test-guest.sh \
 	validate.sh \
 	README \
@@ -42,9 +45,4 @@ EXTRA_DIST = \
 
 CLEANFILES = *~
 
-# Validates the index file.
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
-TESTS = validate.sh
-
-check-valgrind:
-	$(MAKE) VG="$(top_builddir)/run @VG@" check
+include $(srcdir)/tests.mk
diff --git a/builder/website/tests.mk b/builder/website/tests.mk
new file mode 100644
index 0000000..0f716a7
--- /dev/null
+++ b/builder/website/tests.mk
@@ -0,0 +1,67 @@
+# libguestfs generated file
+# WARNING: THIS FILE IS GENERATED FROM:
+#   generator/ *.ml
+# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
+#
+# Copyright (C) 2009-2015 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+localtestsdir = $(alltestsdir)/builder/website
+
+localtests_DATA = \
+	index \
+	index.asc
+
+localtests_SCRIPTS = \
+	validate.sh
+
+# Note that we cannot create a simple 'check:' target since
+# automake will (silently) overrule it, so we do this instead:
+
+TESTS_ENVIRONMENT = $(top_builddir)/run
+TESTS = $(top_builddir)/test-harness
+
+check-valgrind:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind
+
+check-direct:
+	$(top_builddir)/run $(top_builddir)/test-harness --direct
+
+check-valgrind-direct:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct
+
+check-libvirt:
+	$(top_builddir)/run $(top_builddir)/test-harness --libvirt
+
+check-valgrind-libvirt:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt
+
+check-uml:
+	$(top_builddir)/run $(top_builddir)/test-harness --uml
+
+check-valgrind-uml:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml
+
+check-with-upstream-qemu:
+	$(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu
+
+check-with-upstream-libvirt:
+	$(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt
+
+check-fast:
+	$(top_builddir)/run $(top_builddir)/test-harness --fast
+
+EXTRA_DIST += tests.mk
diff --git a/configure.ac b/configure.ac
index df4bd5a..27d1740 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1718,6 +1718,8 @@ AC_CONFIG_FILES([podwrapper.pl],
                 [chmod +x,-w podwrapper.pl])
 AC_CONFIG_FILES([run],
                 [chmod +x,-w run])
+AC_CONFIG_FILES([sysprep/test-virt-sysprep-local-guests.sh],
+                [chmod +x,-w cat/test-virt-sysprep-local-guests.sh])
 
 AC_CONFIG_FILES([Makefile
                  align/Makefile
diff --git a/customize/Makefile.am b/customize/Makefile.am
index 1974b80..dcc1421 100644
--- a/customize/Makefile.am
+++ b/customize/Makefile.am
@@ -31,7 +31,8 @@ generator_built = \
 	customize_cmdline.mli \
 	customize_cmdline.ml \
 	customize-options.pod \
-	customize-synopsis.pod
+	customize-synopsis.pod \
+	tests.mk
 
 SOURCES_MLI = \
 	crypt.mli \
@@ -163,17 +164,6 @@ stamp-virt-customize.pod: virt-customize.pod $(top_srcdir)/customize/customize-s
 	  $<
 	touch $@
 
-# Tests.
-
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
-
-if ENABLE_APPLIANCE
-TESTS = test-virt-customize.sh
-endif
-
-check-valgrind:
-	$(MAKE) VG="$(top_builddir)/run @VG@" check
-
 # Dependencies.
 depend: .depend
 
@@ -193,3 +183,5 @@ endif
 DISTCLEANFILES = .depend
 
 .PHONY: depend docs
+
+include $(srcdir)/tests.mk
diff --git a/customize/test-virt-customize.sh b/customize/test-virt-customize.sh
index 979e6f0..2d17a67 100755
--- a/customize/test-virt-customize.sh
+++ b/customize/test-virt-customize.sh
@@ -22,7 +22,7 @@ set -e
 # virt-customize with the -n option doesn't modify the guest.  It ought
 # to be able to customize any of our Linux-like test guests.
 
-for f in ../tests/guests/{debian,fedora,ubuntu}.img; do
+for f in $phonydir/{debian,fedora,ubuntu}.img; do
     # Ignore zero-sized windows.img if ntfs-3g is not installed.
     if [ -s "$f" ]; then
         # Add --no-network so UML works.
diff --git a/customize/tests.mk b/customize/tests.mk
new file mode 100644
index 0000000..f79c51b
--- /dev/null
+++ b/customize/tests.mk
@@ -0,0 +1,60 @@
+# libguestfs generated file
+# WARNING: THIS FILE IS GENERATED FROM:
+#   generator/ *.ml
+# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
+#
+# Copyright (C) 2009-2015 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+localtestsdir = $(alltestsdir)/customize
+
+localtests_SCRIPTS = \
+	test-virt-customize.sh
+
+# Note that we cannot create a simple 'check:' target since
+# automake will (silently) overrule it, so we do this instead:
+
+TESTS_ENVIRONMENT = $(top_builddir)/run
+TESTS = $(top_builddir)/test-harness
+
+check-valgrind:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind
+
+check-direct:
+	$(top_builddir)/run $(top_builddir)/test-harness --direct
+
+check-valgrind-direct:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct
+
+check-libvirt:
+	$(top_builddir)/run $(top_builddir)/test-harness --libvirt
+
+check-valgrind-libvirt:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt
+
+check-uml:
+	$(top_builddir)/run $(top_builddir)/test-harness --uml
+
+check-valgrind-uml:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml
+
+check-with-upstream-qemu:
+	$(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu
+
+check-with-upstream-libvirt:
+	$(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt
+
+EXTRA_DIST += tests.mk
diff --git a/generator/tests.ml b/generator/tests.ml
index 2b2dd87..9602081 100644
--- a/generator/tests.ml
+++ b/generator/tests.ml
@@ -511,4 +511,142 @@ let tests = [
       ];
   };
 
+  (* Test tools written in OCaml. *)
+
+  "mllib", {
+    defaults with
+      check_fast = [
+        "common_utils_tests";
+        "JSON_tests";
+      ];
+  };
+
+  "customize", {
+    defaults with
+      check = [
+        "test-virt-customize.sh"
+      ];
+  };
+
+  "builder", {
+    defaults with
+      check_fast = [
+        "test-virt-builder-list.sh";
+        "test-virt-index-validate.sh"
+      ];
+      check = [
+        "test-virt-builder.sh"
+      ];
+      check_slow = [
+        "test-virt-builder-planner.sh"
+      ];
+      check_data = [
+        "debian.xz";
+        "fedora.xz";
+        "ubuntu.xz";
+        "windows.xz";
+        "fedora.qcow2";
+        "fedora.qcow2.xz";
+      ];
+  };
+
+  "builder/website", {
+    defaults with
+      check_fast = [
+        "validate.sh"
+      ];
+      check_data = [
+        "index";
+        "index.asc"
+      ];
+  };
+
+  "resize", {
+    defaults with
+      check = [
+        "test-virt-resize.pl"
+      ];
+  };
+
+  "sparsify", {
+    defaults with
+      check = [
+        "test-virt-sparsify.sh";
+        "test-virt-sparsify-in-place.sh";
+      ];
+  };
+
+  "sysprep", {
+    defaults with
+      check = [
+        "test-virt-sysprep.sh";
+        "test-virt-sysprep-passwords.sh";
+        "test-virt-sysprep-script.sh";
+      ];
+      check_local_guests = [
+        "test-virt-sysprep-local-guests.sh";
+      ];
+  };
+
+  (* The virt-v2v tests here are not meant to be thorough tests of guest
+   * conversion.  There is a test suite used to test conversion which is
+   * kept outside libguestfs because it contains lots of proprietary
+   * unredistributable guests like Windows.
+   *
+   * The tests here instead are testing:
+   *
+   * - virt-v2v command line arguments
+   * - virt-v2v reads and writes files to the correct places
+   * - valgrind & memory leaks
+   * - any conversion properties that can be tested using just the
+   *   phony guests (but we don't go out of our way here)
+   * - that up to date guests don't crash virt-v2v
+   *)
+  "v2v", {
+    defaults with
+      check_fast = [
+        "test-v2v-i-ova-formats.sh";
+        "test-v2v-i-ova-gz.sh";
+        "test-v2v-i-ova-two-disks.sh";
+        "v2v_unit_tests";
+      ];
+      check = [
+        "test-v2v-cdrom.sh";
+        "test-v2v-i-ova.sh";
+        "test-v2v-i-disk.sh";
+        "test-v2v-machine-readable.sh";
+        "test-v2v-networks-and-bridges.sh";
+        "test-v2v-no-copy.sh";
+        "test-v2v-o-glance.sh";
+        "test-v2v-o-libvirt.sh";
+        "test-v2v-o-null.sh";
+        "test-v2v-o-qemu.sh";
+        "test-v2v-o-rhev.sh";
+        "test-v2v-o-vdsm-options.sh";
+        "test-v2v-of-option.sh";
+        "test-v2v-on-option.sh";
+        "test-v2v-print-source.sh";
+        "test-v2v-sound.sh";
+        "test-v2v-windows-conversion.sh";
+      ];
+      check_slow = [
+        "test-v2v-real-conversions.sh";
+      ];
+      check_data = [
+	"test-v2v-cdrom.expected";
+	"test-v2v-cdrom.xml";
+	"test-v2v-i-ova.ovf";
+	"test-v2v-i-ova.xml";
+	"test-v2v-i-ova-formats.expected";
+	"test-v2v-i-ova-formats.ovf";
+	"test-v2v-i-ova-gz.expected";
+	"test-v2v-i-ova-gz.ovf";
+	"test-v2v-i-ova-two-disks.expected";
+	"test-v2v-i-ova-two-disks.ovf";
+	"test-v2v-networks-and-bridges-expected.xml";
+	"test-v2v-networks-and-bridges.xml";
+	"test-v2v-sound.xml";
+      ];
+  };
+
 ]
diff --git a/mllib/Makefile.am b/mllib/Makefile.am
index 272c981..bef33d9 100644
--- a/mllib/Makefile.am
+++ b/mllib/Makefile.am
@@ -17,6 +17,8 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
+generator_built = tests.mk
+
 EXTRA_DIST = \
 	$(SOURCES_MLI) \
 	$(filter-out config.ml libdir.ml,$(SOURCES_ML)) \
@@ -182,21 +184,8 @@ JSON_tests_LINK = \
 	  $(OCAMLFIND) $(BEST) $(OCAMLFLAGS) $(OCAMLPACKAGES) $(OCAMLPACKAGES_TESTS) $(OCAMLLINKFLAGS) \
 	  $(JSON_tests_THEOBJECTS) -o $@
 
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
-
-TESTS =
-check_PROGRAMS =
-
-if HAVE_OCAML_PKG_OUNIT
-check_PROGRAMS += common_utils_tests JSON_tests
-TESTS += common_utils_tests JSON_tests
-endif
-
 CLEANFILES += oUnit-*
 
-check-valgrind:
-	$(MAKE) VG="$(top_builddir)/run @VG@" check
-
 # Dependencies.
 depend: .depend
 
@@ -216,3 +205,5 @@ endif
 DISTCLEANFILES = .depend
 
 .PHONY: depend docs
+
+include $(srcdir)/tests.mk
diff --git a/mllib/tests.mk b/mllib/tests.mk
new file mode 100644
index 0000000..0ae0029
--- /dev/null
+++ b/mllib/tests.mk
@@ -0,0 +1,64 @@
+# libguestfs generated file
+# WARNING: THIS FILE IS GENERATED FROM:
+#   generator/ *.ml
+# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
+#
+# Copyright (C) 2009-2015 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+localtestsdir = $(alltestsdir)/mllib
+
+localtests_PROGRAMS = \
+	JSON_tests \
+	common_utils_tests
+
+# Note that we cannot create a simple 'check:' target since
+# automake will (silently) overrule it, so we do this instead:
+
+TESTS_ENVIRONMENT = $(top_builddir)/run
+TESTS = $(top_builddir)/test-harness
+
+check-valgrind:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind
+
+check-direct:
+	$(top_builddir)/run $(top_builddir)/test-harness --direct
+
+check-valgrind-direct:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct
+
+check-libvirt:
+	$(top_builddir)/run $(top_builddir)/test-harness --libvirt
+
+check-valgrind-libvirt:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt
+
+check-uml:
+	$(top_builddir)/run $(top_builddir)/test-harness --uml
+
+check-valgrind-uml:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml
+
+check-with-upstream-qemu:
+	$(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu
+
+check-with-upstream-libvirt:
+	$(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt
+
+check-fast:
+	$(top_builddir)/run $(top_builddir)/test-harness --fast
+
+EXTRA_DIST += tests.mk
diff --git a/resize/Makefile.am b/resize/Makefile.am
index 657b626..773eac4 100644
--- a/resize/Makefile.am
+++ b/resize/Makefile.am
@@ -17,6 +17,8 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
+generator_built = tests.mk
+
 EXTRA_DIST = \
 	$(SOURCES_MLI) $(SOURCES_ML) $(SOURCES_C) \
 	virt-resize.pod \
@@ -127,18 +129,6 @@ stamp-virt-resize.pod: virt-resize.pod
 
 CLEANFILES += stamp-virt-resize.pod
 
-# Tests.
-
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
-
-TESTS =
-if ENABLE_APPLIANCE
-TESTS += test-virt-resize.pl
-endif
-
-check-valgrind:
-	$(MAKE) VG="$(top_builddir)/run @VG@" check
-
 # Dependencies.
 depend: .depend
 
@@ -158,3 +148,5 @@ endif
 DISTCLEANFILES = .depend
 
 .PHONY: depend docs
+
+include $(srcdir)/tests.mk
diff --git a/resize/tests.mk b/resize/tests.mk
new file mode 100644
index 0000000..88dd8e0
--- /dev/null
+++ b/resize/tests.mk
@@ -0,0 +1,60 @@
+# libguestfs generated file
+# WARNING: THIS FILE IS GENERATED FROM:
+#   generator/ *.ml
+# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
+#
+# Copyright (C) 2009-2015 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+localtestsdir = $(alltestsdir)/resize
+
+localtests_SCRIPTS = \
+	test-virt-resize.pl
+
+# Note that we cannot create a simple 'check:' target since
+# automake will (silently) overrule it, so we do this instead:
+
+TESTS_ENVIRONMENT = $(top_builddir)/run
+TESTS = $(top_builddir)/test-harness
+
+check-valgrind:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind
+
+check-direct:
+	$(top_builddir)/run $(top_builddir)/test-harness --direct
+
+check-valgrind-direct:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct
+
+check-libvirt:
+	$(top_builddir)/run $(top_builddir)/test-harness --libvirt
+
+check-valgrind-libvirt:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt
+
+check-uml:
+	$(top_builddir)/run $(top_builddir)/test-harness --uml
+
+check-valgrind-uml:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml
+
+check-with-upstream-qemu:
+	$(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu
+
+check-with-upstream-libvirt:
+	$(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt
+
+EXTRA_DIST += tests.mk
diff --git a/sparsify/Makefile.am b/sparsify/Makefile.am
index 98ab729..4e0b8c9 100644
--- a/sparsify/Makefile.am
+++ b/sparsify/Makefile.am
@@ -17,6 +17,8 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
+generator_built = tests.mk
+
 EXTRA_DIST = \
 	$(SOURCES_ML) $(SOURCES_C) \
 	virt-sparsify.pod \
@@ -120,19 +122,6 @@ stamp-virt-sparsify.pod: virt-sparsify.pod
 
 CLEANFILES += stamp-virt-sparsify.pod
 
-# Tests.
-
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
-
-if ENABLE_APPLIANCE
-TESTS = \
-	test-virt-sparsify.sh \
-	test-virt-sparsify-in-place.sh
-endif ENABLE_APPLIANCE
-
-check-valgrind:
-	$(MAKE) VG="$(top_builddir)/run @VG@" check
-
 # Dependencies.
 depend: .depend
 
@@ -152,3 +141,5 @@ endif
 DISTCLEANFILES = .depend
 
 .PHONY: depend docs
+
+include $(srcdir)/tests.mk
diff --git a/sparsify/test-virt-sparsify-in-place.sh b/sparsify/test-virt-sparsify-in-place.sh
index 64ead1a..0b86562 100755
--- a/sparsify/test-virt-sparsify-in-place.sh
+++ b/sparsify/test-virt-sparsify-in-place.sh
@@ -19,11 +19,6 @@
 export LANG=C
 set -e
 
-if [ -n "$SKIP_TEST_VIRT_SPARSIFY_IN_PLACE_SH" ]; then
-    echo "$0: skipping test (environment variable set)"
-    exit 77
-fi
-
 if [ "$(guestfish get-backend)" = "uml" ]; then
     echo "$0: skipping test because uml backend does not support discard"
     exit 77
diff --git a/sparsify/tests.mk b/sparsify/tests.mk
new file mode 100644
index 0000000..f375c03
--- /dev/null
+++ b/sparsify/tests.mk
@@ -0,0 +1,61 @@
+# libguestfs generated file
+# WARNING: THIS FILE IS GENERATED FROM:
+#   generator/ *.ml
+# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
+#
+# Copyright (C) 2009-2015 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+localtestsdir = $(alltestsdir)/sparsify
+
+localtests_SCRIPTS = \
+	test-virt-sparsify-in-place.sh \
+	test-virt-sparsify.sh
+
+# Note that we cannot create a simple 'check:' target since
+# automake will (silently) overrule it, so we do this instead:
+
+TESTS_ENVIRONMENT = $(top_builddir)/run
+TESTS = $(top_builddir)/test-harness
+
+check-valgrind:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind
+
+check-direct:
+	$(top_builddir)/run $(top_builddir)/test-harness --direct
+
+check-valgrind-direct:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct
+
+check-libvirt:
+	$(top_builddir)/run $(top_builddir)/test-harness --libvirt
+
+check-valgrind-libvirt:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt
+
+check-uml:
+	$(top_builddir)/run $(top_builddir)/test-harness --uml
+
+check-valgrind-uml:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml
+
+check-with-upstream-qemu:
+	$(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu
+
+check-with-upstream-libvirt:
+	$(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt
+
+EXTRA_DIST += tests.mk
diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am
index 9424c40..c430671 100644
--- a/sysprep/Makefile.am
+++ b/sysprep/Makefile.am
@@ -17,10 +17,14 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
+generator_built = tests.mk
+
 EXTRA_DIST = \
 	$(SOURCES_MLI) $(SOURCES_ML) $(SOURCES_C) \
 	script1.sh script2.sh script3.sh script4.sh \
+	tests.mk \
 	test-virt-sysprep.sh \
+	test-virt-sysprep-local-guests.sh \
 	test-virt-sysprep-passwords.sh \
 	test-virt-sysprep-script.sh \
 	virt-sysprep.pod
@@ -200,29 +204,6 @@ sysprep-operations.pod: virt-sysprep
 	$(top_builddir)/run ./$< --dump-pod > $@-t
 	mv $@-t $@
 
-# Tests.
-
-TESTS_ENVIRONMENT = \
-	abs_builddir=$(abs_builddir) \
-	abs_srcdir=$(abs_srcdir) \
-	PATH=$(abs_top_builddir)/fuse:$(PATH) \
-	$(top_builddir)/run --test
-
-if ENABLE_APPLIANCE
-TESTS = \
-	test-virt-sysprep.sh \
-	test-virt-sysprep-passwords.sh \
-	test-virt-sysprep-script.sh
-endif ENABLE_APPLIANCE
-
-check-valgrind:
-	$(MAKE) TESTS="test-virt-sysprep.sh" VG="$(top_builddir)/run @VG@" check
-
-check-valgrind-local-guests:
-	for g in $(GUESTS); do \
-	  $(top_builddir)/run --test @VG@ ./virt-sysprep -n -c "$(libvirt_ro_uri)" -d "$$g" || exit $$?; \
-	done
-
 # Dependencies.
 depend: .depend
 
@@ -242,3 +223,5 @@ endif
 DISTCLEANFILES = .depend
 
 .PHONY: depend docs
+
+include $(srcdir)/tests.mk
diff --git a/sysprep/script1.sh b/sysprep/script1.sh
index 6ba274c..8726a6f 100755
--- a/sysprep/script1.sh
+++ b/sysprep/script1.sh
@@ -18,4 +18,4 @@
 
 # This is used by test-virt-sysprep-script.sh.
 
-pwd > $abs_builddir/stamp-script1.sh
+pwd > $tmpdir/stamp-script1.sh
diff --git a/sysprep/script2.sh b/sysprep/script2.sh
index a8ca21f..163f36e 100755
--- a/sysprep/script2.sh
+++ b/sysprep/script2.sh
@@ -20,4 +20,4 @@
 
 rm -f etc/resolv.conf
 
-pwd > $abs_builddir/stamp-script2.sh
+pwd > $tmpdir/stamp-script2.sh
diff --git a/sysprep/script4.sh b/sysprep/script4.sh
index fe377e0..313ab85 100755
--- a/sysprep/script4.sh
+++ b/sysprep/script4.sh
@@ -18,4 +18,4 @@
 
 # This is used by test-virt-sysprep-script.sh.
 
-pwd >> $abs_builddir/stamp-script4.sh
+pwd >> $tmpdir/stamp-script4.sh
diff --git a/sysprep/test-virt-sysprep-local-guests.sh.in b/sysprep/test-virt-sysprep-local-guests.sh.in
new file mode 100755
index 0000000..36ef713
--- /dev/null
+++ b/sysprep/test-virt-sysprep-local-guests.sh.in
@@ -0,0 +1,24 @@
+#!/bin/bash -
+# libguestfs
+# Copyright (C) 2015 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+export LANG=C
+set -e
+
+for g in "$@"; do
+    $VG virt-sysprep -n -c "@libvirt_ro_uri@" -d "$g"
+done
diff --git a/sysprep/test-virt-sysprep-passwords.sh b/sysprep/test-virt-sysprep-passwords.sh
index b5189c8..74ae5e7 100755
--- a/sysprep/test-virt-sysprep-passwords.sh
+++ b/sysprep/test-virt-sysprep-passwords.sh
@@ -26,7 +26,7 @@ if [ "$(guestfish get-backend)" = "uml" ]; then
     exit 77
 fi
 
-if [ ! -s ../tests/guests/fedora.img ]; then
+if [ ! -s $phonydir/fedora.img ]; then
     echo "$0: skipping test because there is no phony Fedora test image"
     exit 77
 fi
@@ -37,7 +37,7 @@ fi
 rm -f passwords.qcow2 password
 guestfish -- \
     disk-create passwords.qcow2 qcow2 -1 \
-      backingfile:../tests/guests/fedora.img backingformat:raw
+      backingfile:$phonydir/fedora.img backingformat:raw
 
 guestfish -a passwords.qcow2 -i <<'EOF'
 write-append /etc/shadow "test01::15677:0:99999:7:::\n"
diff --git a/sysprep/test-virt-sysprep-script.sh b/sysprep/test-virt-sysprep-script.sh
index 10ba1d1..0dbf964 100755
--- a/sysprep/test-virt-sysprep-script.sh
+++ b/sysprep/test-virt-sysprep-script.sh
@@ -20,11 +20,6 @@ export LANG=C
 set -e
 #set -x
 
-if [ -n "$SKIP_TEST_VIRT_SYSPREP_SCRIPT_SH" ]; then
-    echo "$0: test skipped because environment variable is set."
-    exit 77
-fi
-
 if [ ! -w /dev/fuse ]; then
     echo "$0: SKIPPING test, because there is no /dev/fuse."
     exit 77
@@ -32,7 +27,7 @@ fi
 
 # Check that multiple scripts can run.
 rm -f stamp-script1.sh stamp-script2.sh stamp-script4.sh
-if ! virt-sysprep -q -n -a ../tests/guests/fedora.img --enable script \
+if ! virt-sysprep -q -n -a $phonydir/fedora.img --enable script \
         --script $abs_srcdir/script1.sh --script $abs_srcdir/script2.sh; then
     echo "$0: virt-sysprep wasn't expected to exit with error."
     exit 1
@@ -43,19 +38,19 @@ if [ ! -f stamp-script1.sh -o ! -f stamp-script2.sh ]; then
 fi
 
 # Check that if a script fails, virt-sysprep exits with an error.
-if virt-sysprep -q -n -a ../tests/guests/fedora.img --enable script \
+if virt-sysprep -q -n -a $phonydir/fedora.img --enable script \
         --script $abs_srcdir/script3.sh; then
     echo "$0: virt-sysprep didn't exit with an error."
     exit 1
 fi
 
 # Check that virt-sysprep uses a new temporary directory every time.
-if ! virt-sysprep -q -n -a ../tests/guests/fedora.img --enable script \
+if ! virt-sysprep -q -n -a $phonydir/fedora.img --enable script \
         --script $abs_srcdir/script4.sh; then
     echo "$0: virt-sysprep (script4.sh, try #1) wasn't expected to exit with error."
     exit 1
 fi
-if ! virt-sysprep -q -n -a ../tests/guests/fedora.img --enable script \
+if ! virt-sysprep -q -n -a $phonydir/fedora.img --enable script \
         --script $abs_srcdir/script4.sh; then
     echo "$0: virt-sysprep (script4.sh, try #2) wasn't expected to exit with error."
     exit 1
diff --git a/sysprep/tests.mk b/sysprep/tests.mk
new file mode 100644
index 0000000..38df683
--- /dev/null
+++ b/sysprep/tests.mk
@@ -0,0 +1,69 @@
+# libguestfs generated file
+# WARNING: THIS FILE IS GENERATED FROM:
+#   generator/ *.ml
+# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
+#
+# Copyright (C) 2009-2015 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+localtestsdir = $(alltestsdir)/sysprep
+
+localtests_SCRIPTS = \
+	test-virt-sysprep-local-guests.sh \
+	test-virt-sysprep-passwords.sh \
+	test-virt-sysprep-script.sh \
+	test-virt-sysprep.sh
+
+# Note that we cannot create a simple 'check:' target since
+# automake will (silently) overrule it, so we do this instead:
+
+TESTS_ENVIRONMENT = $(top_builddir)/run
+TESTS = $(top_builddir)/test-harness
+
+check-valgrind:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind
+
+check-direct:
+	$(top_builddir)/run $(top_builddir)/test-harness --direct
+
+check-valgrind-direct:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct
+
+check-libvirt:
+	$(top_builddir)/run $(top_builddir)/test-harness --libvirt
+
+check-valgrind-libvirt:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt
+
+check-uml:
+	$(top_builddir)/run $(top_builddir)/test-harness --uml
+
+check-valgrind-uml:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml
+
+check-with-upstream-qemu:
+	$(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu
+
+check-with-upstream-libvirt:
+	$(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt
+
+check-local-guests:
+	$(top_builddir)/run $(top_builddir)/test-harness --local-guests
+
+check-valgrind-local-guests:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind --local-guests
+
+EXTRA_DIST += tests.mk
diff --git a/v2v/Makefile.am b/v2v/Makefile.am
index 06da002..7435d5c 100644
--- a/v2v/Makefile.am
+++ b/v2v/Makefile.am
@@ -17,24 +17,13 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
+generator_built = tests.mk
+
 EXTRA_DIST = \
 	$(SOURCES_MLI) $(SOURCES_ML) $(SOURCES_C) \
 	v2v_unit_tests.ml \
-	$(TESTS) $(SLOW_TESTS) \
+	tests.mk \
 	HACKING \
-	test-v2v-cdrom.expected \
-	test-v2v-cdrom.xml \
-	test-v2v-i-ova.ovf \
-	test-v2v-i-ova.xml \
-	test-v2v-i-ova-formats.expected \
-	test-v2v-i-ova-formats.ovf \
-	test-v2v-i-ova-gz.expected \
-	test-v2v-i-ova-gz.ovf \
-	test-v2v-i-ova-two-disks.expected \
-	test-v2v-i-ova-two-disks.ovf \
-	test-v2v-networks-and-bridges-expected.xml \
-	test-v2v-networks-and-bridges.xml \
-	test-v2v-sound.xml \
 	virt-v2v.pod
 
 CLEANFILES = *~ *.annot *.cmi *.cmo *.cmx *.cmxa *.o virt-v2v
@@ -200,92 +189,7 @@ stamp-virt-v2v.pod: virt-v2v.pod
 
 CLEANFILES += stamp-virt-v2v.pod
 
-# Tests.
-
-# The virt-v2v tests here are not meant to be thorough tests of guest
-# conversion.  There is a test suite used to test conversion which is
-# kept outside libguestfs because it contains lots of proprietary
-# unredistributable guests like Windows.
-#
-# The tests here instead are testing:
-#
-# - virt-v2v command line arguments
-# - virt-v2v reads and writes files to the correct places
-# - valgrind & memory leaks
-# - any conversion properties that can be tested using just the
-#   phony guests (but we don't go out of our way here)
-# - that up to date guests don't crash virt-v2v
-
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
-
-TESTS = \
-	test-v2v-i-ova-formats.sh \
-	test-v2v-i-ova-gz.sh \
-	test-v2v-i-ova-two-disks.sh
-
-if HAVE_OCAML_PKG_OUNIT
-TESTS += v2v_unit_tests
-endif
-
-if ENABLE_APPLIANCE
-TESTS += \
-	test-v2v-cdrom.sh \
-	test-v2v-i-ova.sh \
-	test-v2v-i-disk.sh \
-	test-v2v-machine-readable.sh \
-	test-v2v-networks-and-bridges.sh \
-	test-v2v-no-copy.sh \
-	test-v2v-o-glance.sh \
-	test-v2v-o-libvirt.sh \
-	test-v2v-o-null.sh \
-	test-v2v-o-qemu.sh \
-	test-v2v-o-rhev.sh \
-	test-v2v-o-vdsm-options.sh \
-	test-v2v-of-option.sh \
-	test-v2v-on-option.sh \
-	test-v2v-print-source.sh \
-	test-v2v-sound.sh \
-	test-v2v-windows-conversion.sh
-endif ENABLE_APPLIANCE
-
-check-valgrind:
-	$(MAKE) VG="$(top_builddir)/run @VG@" check
-
-SLOW_TESTS = \
-	test-v2v-real-conversions.sh
-
-check-slow: $(real_guests:%=%.img)
-	$(MAKE) check TESTS="$(SLOW_TESTS)"
-
-# A selection of real guests that test-v2v-real-conversions.sh will
-# try to convert.  This is only used by 'make check-slow'.
-
-real_guests = \
-	centos-6 \
-	centos-7.0 \
-	fedora-20 \
-	rhel-5.10 \
-	rhel-6.5 \
-	rhel-7.0
-
-$(real_guests:%=%.img):
-	rm -f $@
-	n=`basename $@ .img`;                                            \
-	vb="$(top_builddir)/run $(top_builddir)/builder/virt-builder";   \
-	if $$vb --help >/dev/null && $$vb --notes $$n >/dev/null; then   \
-	  $$vb $$n;                                                      \
-	else                                                             \
-	  touch $$n.img;                                                 \
-	fi
-
-CLEANFILES += $(real_guests:%=%.img)
-
 # Unit tests.
-check_PROGRAMS =
-if HAVE_OCAML_PKG_OUNIT
-check_PROGRAMS += v2v_unit_tests
-endif
-
 v2v_unit_tests_BOBJECTS = \
 	$(top_builddir)/mllib/config.cmo \
 	$(top_builddir)/mllib/common_gettext.cmo \
@@ -340,3 +244,5 @@ endif
 DISTCLEANFILES = .depend
 
 .PHONY: depend docs
+
+include $(srcdir)/tests.mk
diff --git a/v2v/test-v2v-cdrom.sh b/v2v/test-v2v-cdrom.sh
index 93975c2..82de447 100755
--- a/v2v/test-v2v-cdrom.sh
+++ b/v2v/test-v2v-cdrom.sh
@@ -23,26 +23,20 @@ unset CDPATH
 export LANG=C
 set -e
 
-if [ -n "$SKIP_TEST_V2V_CDROM_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_builddir="$(pwd)"
 libvirt_uri="test://$abs_builddir/test-v2v-cdrom.xml"
 
-f=../tests/guests/windows.img
+f=$phonydir/windows.img
 if ! test -f $f || ! test -s $f; then
     echo "$0: test skipped because phony Windows image was not created"
     exit 77
 fi
 
-f=../tests/guests/blank-disk.img
+f=$phonydir/blank-disk.img
 if ! test -f $f || ! test -s $f; then
     echo "$0: test skipped because blank-disk.img was not created"
     exit 77
@@ -71,7 +65,7 @@ awk '/<disk /{p=1;print;next} p&&/<\/disk>/{p=0;print;next} ;p' \
     $d/windows.xml |
     grep -v '<source file' > $d/disks
 
-if ! diff -u test-v2v-cdrom.expected $d/disks; then
+if ! diff -u $srcdir/test-v2v-cdrom.expected $d/disks; then
     echo "$0: unexpected disk assignments"
     cat $d/disks
     exit 1
diff --git a/v2v/test-v2v-i-disk.sh b/v2v/test-v2v-i-disk.sh
index b15e0d0..e385bf3 100755
--- a/v2v/test-v2v-i-disk.sh
+++ b/v2v/test-v2v-i-disk.sh
@@ -22,17 +22,12 @@ unset CDPATH
 export LANG=C
 set -e
 
-if [ -n "$SKIP_TEST_V2V_I_DISK_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
 
-f=../tests/guests/windows.img
+f=$phonydir/windows.img
 if ! test -f $f || ! test -s $f; then
     echo "$0: test skipped because phony Windows image was not created"
     exit 77
diff --git a/v2v/test-v2v-i-ova-formats.sh b/v2v/test-v2v-i-ova-formats.sh
index bd3e048..67dbbde 100755
--- a/v2v/test-v2v-i-ova-formats.sh
+++ b/v2v/test-v2v-i-ova-formats.sh
@@ -24,11 +24,6 @@ set -e
 
 formats="tar zip tar-gz tar-xz"
 
-if [ -n "$SKIP_TEST_V2V_I_OVA_FORMATS_SH" ]; then
-    echo "$0: test skipped because environment variable is set"
-    exit 77
-fi
-
 if ! zip --version >/dev/null 2>&1; then
     echo "$0: test skipped because 'zip' utility is not available"
     exit 77
@@ -65,17 +60,17 @@ echo -e "SHA1(disk1.vmdk)=$sha\r" > disk1.mf
 for format in $formats; do
     case "$format" in
         tar)
-            tar -cf test-$format.ova ../test-v2v-i-ova-formats.ovf disk1.vmdk disk1.mf
+            tar -cf test-$format.ova $srcdir/test-v2v-i-ova-formats.ovf disk1.vmdk disk1.mf
             ;;
         zip)
-            zip -r test ../test-v2v-i-ova-formats.ovf disk1.vmdk disk1.mf
+            zip -r test $srcdir/test-v2v-i-ova-formats.ovf disk1.vmdk disk1.mf
             mv test.zip test-$format.ova
             ;;
         tar-gz)
-            tar -czf test-$format.ova ../test-v2v-i-ova-formats.ovf disk1.vmdk disk1.mf
+            tar -czf test-$format.ova $srcdir/test-v2v-i-ova-formats.ovf disk1.vmdk disk1.mf
             ;;
         tar-xz)
-            tar -cJf test-$format.ova ../test-v2v-i-ova-formats.ovf disk1.vmdk disk1.mf
+            tar -cJf test-$format.ova $srcdir/test-v2v-i-ova-formats.ovf disk1.vmdk disk1.mf
             ;;
         *)
             echo "Unhandled format '$format'"
@@ -94,7 +89,7 @@ for format in $formats; do
     sed 's,[^ \t]*\(disk.*.vmdk\),\1,' > $d/source
 
     # Check the parsed source is what we expect.
-    diff -u test-v2v-i-ova-formats.expected $d/source
+    diff -u $srcdir/test-v2v-i-ova-formats.expected $d/source
 done
 
 rm -rf $d
diff --git a/v2v/test-v2v-i-ova-gz.sh b/v2v/test-v2v-i-ova-gz.sh
index 6c630fb..18cce91 100755
--- a/v2v/test-v2v-i-ova-gz.sh
+++ b/v2v/test-v2v-i-ova-gz.sh
@@ -22,11 +22,6 @@ unset CDPATH
 export LANG=C
 set -e
 
-if [ -n "$SKIP_TEST_V2V_I_OVA_GZ_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
@@ -49,7 +44,7 @@ gzip disk1.vmdk
 sha=`sha1sum disk1.vmdk | awk '{print $1}'`
 echo -e "SHA1(disk1.vmdk)=$sha\r" > disk1.mf
 
-tar -cf test.ova ../test-v2v-i-ova-gz.ovf disk1.vmdk.gz disk1.mf
+tar -cf test.ova $srcdir/test-v2v-i-ova-gz.ovf disk1.vmdk.gz disk1.mf
 popd
 
 # Run virt-v2v but only as far as the --print-source stage, and
@@ -60,6 +55,6 @@ $VG virt-v2v --debug-gc --quiet \
 sed 's,[^ \t]*\(\.vmdk\),\1,' > $d/source
 
 # Check the parsed source is what we expect.
-diff -u test-v2v-i-ova-gz.expected $d/source
+diff -u $srcdir/test-v2v-i-ova-gz.expected $d/source
 
 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..db27573 100755
--- a/v2v/test-v2v-i-ova-two-disks.sh
+++ b/v2v/test-v2v-i-ova-two-disks.sh
@@ -22,11 +22,6 @@ unset CDPATH
 export LANG=C
 set -e
 
-if [ -n "$SKIP_TEST_V2V_I_OVA_TWO_DISKS_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
@@ -53,7 +48,7 @@ truncate -s 100k disk2.vmdk
 sha=`sha1sum disk2.vmdk | awk '{print $1}'`
 echo -e "SHA1(disk2.vmdk)=$sha\r" > disk2.mf
 
-tar -cf test.ova ../test-v2v-i-ova-two-disks.ovf disk1.vmdk disk1.mf disk2.vmdk disk2.mf
+tar -cf test.ova $srcdir/test-v2v-i-ova-two-disks.ovf disk1.vmdk disk1.mf disk2.vmdk disk2.mf
 popd
 
 # Run virt-v2v but only as far as the --print-source stage, and
@@ -64,6 +59,6 @@ $VG virt-v2v --debug-gc --quiet \
 sed 's,[^ \t]*\(disk.*.vmdk\),\1,' > $d/source
 
 # Check the parsed source is what we expect.
-diff -u test-v2v-i-ova-two-disks.expected $d/source
+diff -u $srcdir/test-v2v-i-ova-two-disks.expected $d/source
 
 rm -rf $d
diff --git a/v2v/test-v2v-i-ova.sh b/v2v/test-v2v-i-ova.sh
index 5047eca..1eef6aa 100755
--- a/v2v/test-v2v-i-ova.sh
+++ b/v2v/test-v2v-i-ova.sh
@@ -22,17 +22,12 @@ unset CDPATH
 export LANG=C
 set -e
 
-if [ -n "$SKIP_TEST_V2V_I_OVA_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
 
-f=../tests/guests/windows.img
+f=$phonydir/windows.img
 if ! test -f $f || ! test -s $f; then
     echo "$0: test skipped because phony Windows image was not created"
     exit 77
@@ -55,7 +50,7 @@ ova=test-ova.ova
 raw=TestOva-sda
 
 qemu-img convert $f -O vmdk $d/$vmdk
-cp $ovf $d/$ovf
+cp $srcdir/test-v2v-i-ova.ovf $d/$ovf
 sha1=`sha1sum $d/$ovf | awk '{print $1}'`
 echo "SHA1($ovf)= $sha1" > $d/$mf
 sha1=`sha1sum $d/$vmdk | awk '{print $1}'`
@@ -83,6 +78,6 @@ sed \
     < $d/TestOva.xml.old > $d/TestOva.xml
 
 # Check the libvirt XML output.
-diff -u test-v2v-i-ova.xml $d/TestOva.xml
+diff -u $srcdir/test-v2v-i-ova.xml $d/TestOva.xml
 
 rm -rf $d
diff --git a/v2v/test-v2v-machine-readable.sh b/v2v/test-v2v-machine-readable.sh
index 3e94ae5..7b0ae9c 100755
--- a/v2v/test-v2v-machine-readable.sh
+++ b/v2v/test-v2v-machine-readable.sh
@@ -22,11 +22,6 @@ unset CDPATH
 export LANG=C
 set -e
 
-if [ -n "$SKIP_TEST_V2V_MACHINE_READABLE_SH" ]; then
-    echo "$0: test skipped because environment variable is set"
-    exit 77
-fi
-
 $VG virt-v2v --debug-gc --machine-readable > test-v2v-machine-readable.out
 grep virt-v2v test-v2v-machine-readable.out
 grep libguestfs-rewrite test-v2v-machine-readable.out
diff --git a/v2v/test-v2v-networks-and-bridges.sh b/v2v/test-v2v-networks-and-bridges.sh
index 68743d6..0446a3e 100755
--- a/v2v/test-v2v-networks-and-bridges.sh
+++ b/v2v/test-v2v-networks-and-bridges.sh
@@ -22,20 +22,14 @@ unset CDPATH
 export LANG=C
 set -e
 
-if [ -n "$SKIP_TEST_V2V_NETWORKS_AND_BRIDGES_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_builddir="$(pwd)"
 libvirt_uri="test://$abs_builddir/test-v2v-networks-and-bridges.xml"
 
-f=../tests/guests/windows.img
+f=$phonydir/windows.img
 if ! test -f $f || ! test -s $f; then
     echo "$0: test skipped because phony Windows image was not created"
     exit 77
@@ -72,6 +66,6 @@ sed -n '/interface/,/\/interface/p' $d/windows.xml |
   grep -v 'model type=' > $d/networks
 
 # Test that the output has mapped the networks and bridges correctly.
-diff -ur test-v2v-networks-and-bridges-expected.xml $d/networks
+diff -ur $srcdir/test-v2v-networks-and-bridges-expected.xml $d/networks
 
 rm -r $d
diff --git a/v2v/test-v2v-no-copy.sh b/v2v/test-v2v-no-copy.sh
index f0408dc..8afe94e 100755
--- a/v2v/test-v2v-no-copy.sh
+++ b/v2v/test-v2v-no-copy.sh
@@ -22,20 +22,14 @@ unset CDPATH
 export LANG=C
 set -e
 
-if [ -n "$SKIP_TEST_V2V_NO_COPY_SH" ]; then
-    echo "$0: test skipped because environment variable is set"
-    exit 77
-fi
-
 if [ "$(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
+f=$phonydir/windows.img
 if ! test -f $f || ! test -s $f; then
     echo "$0: test skipped because phony Windows image was not created"
     exit 77
diff --git a/v2v/test-v2v-o-glance.sh b/v2v/test-v2v-o-glance.sh
index 121177f..e4d7d6a 100755
--- a/v2v/test-v2v-o-glance.sh
+++ b/v2v/test-v2v-o-glance.sh
@@ -22,20 +22,14 @@ unset CDPATH
 export LANG=C
 set -e
 
-if [ -n "$SKIP_TEST_V2V_O_GLANCE_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
+f=$phonydir/windows.img
 if ! test -f $f || ! test -s $f; then
     echo "$0: test skipped because phony Windows image was not created"
     exit 77
@@ -50,6 +44,7 @@ fi
 # We don't want to upload to the real glance, so introduce a fake
 # glance binary.
 ln -sf "$(which echo)" glance
+export PATH=.:$PATH
 
 $VG virt-v2v --debug-gc \
     -i libvirt -ic "$libvirt_uri" windows \
diff --git a/v2v/test-v2v-o-libvirt.sh b/v2v/test-v2v-o-libvirt.sh
index 77b38e0..964198e 100755
--- a/v2v/test-v2v-o-libvirt.sh
+++ b/v2v/test-v2v-o-libvirt.sh
@@ -22,11 +22,6 @@ unset CDPATH
 export LANG=C
 set -e
 
-if [ -n "$SKIP_TEST_V2V_O_LIBVIRT_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
@@ -40,10 +35,9 @@ if [ "$(id -u)" -eq 0 ]; then
     exit 77
 fi
 
-abs_top_builddir="$(cd ..; pwd)"
 libvirt_uri="test://$abs_top_builddir/tests/guests/guests.xml"
 
-f=../tests/guests/windows.img
+f=$phonydir/windows.img
 if ! test -f $f || ! test -s $f; then
     echo "$0: test skipped because phony Windows image was not created"
     exit 77
diff --git a/v2v/test-v2v-o-null.sh b/v2v/test-v2v-o-null.sh
index 9ed581b..14413e1 100755
--- a/v2v/test-v2v-o-null.sh
+++ b/v2v/test-v2v-o-null.sh
@@ -22,20 +22,14 @@ unset CDPATH
 export LANG=C
 set -e
 
-if [ -n "$SKIP_TEST_V2V_O_NULL_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
+f=$phonydir/windows.img
 if ! test -f $f || ! test -s $f; then
     echo "$0: test skipped because phony Windows image was not created"
     exit 77
diff --git a/v2v/test-v2v-o-qemu.sh b/v2v/test-v2v-o-qemu.sh
index 9de2b56..a1a92f5 100755
--- a/v2v/test-v2v-o-qemu.sh
+++ b/v2v/test-v2v-o-qemu.sh
@@ -22,20 +22,14 @@ unset CDPATH
 export LANG=C
 set -e
 
-if [ -n "$SKIP_TEST_V2V_O_QEMU_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
+f=$phonydir/windows.img
 if ! test -f $f || ! test -s $f; then
     echo "$0: test skipped because phony Windows image was not created"
     exit 77
diff --git a/v2v/test-v2v-o-rhev.sh b/v2v/test-v2v-o-rhev.sh
index 1162e31..5baba2b 100755
--- a/v2v/test-v2v-o-rhev.sh
+++ b/v2v/test-v2v-o-rhev.sh
@@ -22,20 +22,14 @@ unset CDPATH
 export LANG=C
 set -e
 
-if [ -n "$SKIP_TEST_V2V_O_RHEV_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
+f=$phonydir/windows.img
 if ! test -f $f || ! test -s $f; then
     echo "$0: test skipped because phony Windows image was not created"
     exit 77
diff --git a/v2v/test-v2v-o-vdsm-options.sh b/v2v/test-v2v-o-vdsm-options.sh
index c170467..36920e8 100755
--- a/v2v/test-v2v-o-vdsm-options.sh
+++ b/v2v/test-v2v-o-vdsm-options.sh
@@ -22,20 +22,14 @@ unset CDPATH
 export LANG=C
 set -e
 
-if [ -n "$SKIP_TEST_V2V_O_VDSM_OPTIONS_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
+f=$phonydir/windows.img
 if ! test -f $f || ! test -s $f; then
     echo "$0: test skipped because phony Windows image was not created"
     exit 77
diff --git a/v2v/test-v2v-of-option.sh b/v2v/test-v2v-of-option.sh
index 27441cf..f87c09c 100755
--- a/v2v/test-v2v-of-option.sh
+++ b/v2v/test-v2v-of-option.sh
@@ -22,20 +22,14 @@ unset CDPATH
 export LANG=C
 set -e
 
-if [ -n "$SKIP_TEST_V2V_OF_OPTION_SH" ]; then
-    echo "$0: test skipped because environment variable is set"
-    exit 77
-fi
-
 if [ "$(guestfish get-backend)" = "uml" ]; then
     echo "$0: test skipped because UML backend does not support network or qcow2"
     exit 77
 fi
 
-abs_top_builddir="$(cd ..; pwd)"
 libvirt_uri="test://$abs_top_builddir/tests/guests/guests.xml"
 
-f=../tests/guests/windows.img
+f=$phonydir/windows.img
 if ! test -f $f || ! test -s $f; then
     echo "$0: test skipped because phony Windows image was not created"
     exit 77
diff --git a/v2v/test-v2v-on-option.sh b/v2v/test-v2v-on-option.sh
index e3edb67..e65c61f 100755
--- a/v2v/test-v2v-on-option.sh
+++ b/v2v/test-v2v-on-option.sh
@@ -22,20 +22,14 @@ unset CDPATH
 export LANG=C
 set -e
 
-if [ -n "$SKIP_TEST_V2V_ON_OPTION_SH" ]; then
-    echo "$0: test skipped because environment variable is set"
-    exit 77
-fi
-
 if [ "$(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
+f=$phonydir/windows.img
 if ! test -f $f || ! test -s $f; then
     echo "$0: test skipped because phony Windows image was not created"
     exit 77
diff --git a/v2v/test-v2v-print-source.sh b/v2v/test-v2v-print-source.sh
index e7a8382..ad8516d 100755
--- a/v2v/test-v2v-print-source.sh
+++ b/v2v/test-v2v-print-source.sh
@@ -22,15 +22,9 @@ unset CDPATH
 export LANG=C
 set -e
 
-if [ -n "$SKIP_TEST_V2V_PRINT_SOURCE_SH" ]; then
-    echo "$0: test skipped because environment variable is set"
-    exit 77
-fi
-
-abs_top_builddir="$(cd ..; pwd)"
 libvirt_uri="test://$abs_top_builddir/tests/guests/guests.xml"
 
-f=../tests/guests/windows.img
+f=$phonydir/windows.img
 if ! test -f $f || ! test -s $f; then
     echo "$0: test skipped because phony Windows image was not created"
     exit 77
diff --git a/v2v/test-v2v-real-conversions.sh b/v2v/test-v2v-real-conversions.sh
index bb98488..adb7b4e 100755
--- a/v2v/test-v2v-real-conversions.sh
+++ b/v2v/test-v2v-real-conversions.sh
@@ -18,31 +18,24 @@
 
 # Test virt-v2v on some real guests.
 #
-# The phony Fedora guest isn't sufficient for testing.  The
-# Makefile.am builds some real guests using virt-builder and we just
-# run virt-v2v on those (to make sure it doesn't crash / assert).
+# The phony Fedora guest isn't sufficient for testing.  Build some
+# real guests and run virt-v2v on those (to make sure it doesn't
+# crash / assert).
 
 unset CDPATH
 export LANG=C
 set -e
 
-if [ -n "$SKIP_TEST_V2V_REAL_CONVERSIONS_SH" ]; then
-    echo "$0: test skipped because environment variable is set"
-    exit 77
-fi
+real_guests="centos-6 centos-7.0 fedora-22 rhel-5.10 rhel-6.5 rhel-7.0"
 
-d=test-v2v-real-conversions.d
-rm -rf $d
-mkdir $d
-
-for file in *.img; do
-    if test -f $file && test -s $file ; then
-        n=`basename $file .img`
+for g in $real_guests; do
+    if virt-builder --help >/dev/null && virt-builder --notes $g >/dev/null; then
+        virt-builder $g
 
         # Create some minimal test metadata.
-        cat > $d/$n-input.xml <<EOF
+        cat > $g-input.xml <<EOF
 <domain type='test'>
-  <name>$n</name>
+  <name>$g</name>
   <memory>1048576</memory>
   <os>
     <type>hvm</type>
@@ -51,7 +44,7 @@ for file in *.img; do
   <devices>
     <disk type='file' device='disk'>
       <driver name='qemu' type='raw'/>
-      <source file='$(pwd)/$file'/>
+      <source file='$(pwd)/$g.img'/>
       <target dev='vda' bus='virtio'/>
     </disk>
   </devices>
@@ -59,24 +52,22 @@ for file in *.img; do
 EOF
 
       virt-v2v --debug-gc \
-          -i libvirtxml $d/$n-input.xml \
-          -o local -os $d
+          -i libvirtxml $g-input.xml \
+          -o local -os $(pwd)
 
       # Test the libvirt XML metadata and a disk was created.
-      test -f $d/$n.xml
-      test -f $d/$n-sda
+      test -f $g.xml
+      test -f $g-sda
 
       # Test the disk has a similar size to the original.
-      size_before="$(du $file | awk '{print $1}')"
-      size_after="$(du $d/$n-sda | awk '{print $1}')"
+      size_before="$(du $g.img | awk '{print $1}')"
+      size_after="$(du $g-sda | awk '{print $1}')"
       diff="$(( 100 * size_after / size_before ))"
       if test $diff -lt 50; then
           echo "$0: disk image may have been corrupted or truncated"
           echo "size_before=$size_before size_after=$size_after diff=$diff"
-          ls -l $file $d/$n-sda
+          ls -l $file $g-sda
           exit 1
       fi
     fi
 done
-
-rm -r $d
diff --git a/v2v/test-v2v-sound.sh b/v2v/test-v2v-sound.sh
index 7cb6f24..54fa2f0 100755
--- a/v2v/test-v2v-sound.sh
+++ b/v2v/test-v2v-sound.sh
@@ -22,20 +22,14 @@ unset CDPATH
 export LANG=C
 set -e
 
-if [ -n "$SKIP_TEST_V2V_SOUND_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_builddir="$(pwd)"
 libvirt_uri="test://$abs_builddir/test-v2v-sound.xml"
 
-f=../tests/guests/windows.img
+f=$phonydir/windows.img
 if ! test -f $f || ! test -s $f; then
     echo "$0: test skipped because phony Windows image was not created"
     exit 77
diff --git a/v2v/test-v2v-windows-conversion.sh b/v2v/test-v2v-windows-conversion.sh
index 7e8e628..f2464cb 100755
--- a/v2v/test-v2v-windows-conversion.sh
+++ b/v2v/test-v2v-windows-conversion.sh
@@ -22,20 +22,14 @@ unset CDPATH
 export LANG=C
 set -e
 
-if [ -n "$SKIP_TEST_V2V_WINDOWS_CONVERSION_SH" ]; then
-    echo "$0: test skipped because environment variable is set"
-    exit 77
-fi
-
 if [ "$(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
+f=$phonydir/windows.img
 if ! test -f $f || ! test -s $f; then
     echo "$0: test skipped because phony Windows image was not created"
     exit 77
diff --git a/v2v/tests.mk b/v2v/tests.mk
new file mode 100644
index 0000000..ac7780c
--- /dev/null
+++ b/v2v/tests.mk
@@ -0,0 +1,104 @@
+# libguestfs generated file
+# WARNING: THIS FILE IS GENERATED FROM:
+#   generator/ *.ml
+# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
+#
+# Copyright (C) 2009-2015 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+localtestsdir = $(alltestsdir)/v2v
+
+localtests_DATA = \
+	test-v2v-cdrom.expected \
+	test-v2v-cdrom.xml \
+	test-v2v-i-ova-formats.expected \
+	test-v2v-i-ova-formats.ovf \
+	test-v2v-i-ova-gz.expected \
+	test-v2v-i-ova-gz.ovf \
+	test-v2v-i-ova-two-disks.expected \
+	test-v2v-i-ova-two-disks.ovf \
+	test-v2v-i-ova.ovf \
+	test-v2v-i-ova.xml \
+	test-v2v-networks-and-bridges-expected.xml \
+	test-v2v-networks-and-bridges.xml \
+	test-v2v-sound.xml
+
+localtests_SCRIPTS = \
+	test-v2v-cdrom.sh \
+	test-v2v-i-disk.sh \
+	test-v2v-i-ova-formats.sh \
+	test-v2v-i-ova-gz.sh \
+	test-v2v-i-ova-two-disks.sh \
+	test-v2v-i-ova.sh \
+	test-v2v-machine-readable.sh \
+	test-v2v-networks-and-bridges.sh \
+	test-v2v-no-copy.sh \
+	test-v2v-o-glance.sh \
+	test-v2v-o-libvirt.sh \
+	test-v2v-o-null.sh \
+	test-v2v-o-qemu.sh \
+	test-v2v-o-rhev.sh \
+	test-v2v-o-vdsm-options.sh \
+	test-v2v-of-option.sh \
+	test-v2v-on-option.sh \
+	test-v2v-print-source.sh \
+	test-v2v-real-conversions.sh \
+	test-v2v-sound.sh \
+	test-v2v-windows-conversion.sh
+
+localtests_PROGRAMS = \
+	v2v_unit_tests
+
+# Note that we cannot create a simple 'check:' target since
+# automake will (silently) overrule it, so we do this instead:
+
+TESTS_ENVIRONMENT = $(top_builddir)/run
+TESTS = $(top_builddir)/test-harness
+
+check-valgrind:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind
+
+check-direct:
+	$(top_builddir)/run $(top_builddir)/test-harness --direct
+
+check-valgrind-direct:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct
+
+check-libvirt:
+	$(top_builddir)/run $(top_builddir)/test-harness --libvirt
+
+check-valgrind-libvirt:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt
+
+check-uml:
+	$(top_builddir)/run $(top_builddir)/test-harness --uml
+
+check-valgrind-uml:
+	$(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml
+
+check-with-upstream-qemu:
+	$(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu
+
+check-with-upstream-libvirt:
+	$(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt
+
+check-fast:
+	$(top_builddir)/run $(top_builddir)/test-harness --fast
+
+check-slow:
+	$(top_builddir)/run $(top_builddir)/test-harness --slow
+
+EXTRA_DIST += tests.mk
-- 
2.5.0




More information about the Libguestfs mailing list