[Libguestfs] [PATCH 03/10] tests: Convert all subdirectories of tests/ to use the test harness.

Richard W.M. Jones rjones at redhat.com
Tue Jul 28 17:24:33 UTC 2015


The general plan for converting each subdirectory is:

(1) Create a new subdirectory entry in generator/tests.ml.

(2) Add the tests, data files, etc to generator/tests.ml entry.

(3) Remove all TESTS/TEST_ENVIRONMENT variables.

(4) Add 'generator_built = tests.mk' and 'include $(srcdir)/tests.mk'.

(5) May need to add an empty 'EXTRA_DIST =' line, if there isn't one
already.

(6) Remove any SKIP_* checks from the tests (since the test harness
now does this for you).

(7) May need to update the test so it references any data files it
needs relative to environment variables like $srcdir, $builddir,
$top_builddir, etc.

(8) Remove any relative paths to binaries (eg. '../../fish/guestfish'
would become just 'guestfish') since we want to be able to test the
installed copy of libguestfs, and the ./run script will set the $PATH
correctly for local builds.

(9) Build it, and run the new tests to check it works.

(10) Check it works for an installed copy of the tests too.
---
 .gitignore                                    |   3 -
 generator/tests.ml                            | 267 ++++++++++++++++++++++++++
 tests/9p/Makefile.am                          |   7 +-
 tests/9p/test-9p.sh                           |   5 -
 tests/9p/tests.mk                             |  60 ++++++
 tests/bigdirs/Makefile.am                     |  12 +-
 tests/bigdirs/tests.mk                        |  30 +++
 tests/btrfs/Makefile.am                       |  15 +-
 tests/btrfs/test-btrfs-devices.sh             |   8 +-
 tests/btrfs/test-btrfs-misc.pl                |   3 -
 tests/btrfs/test-btrfs-subvolume-default.pl   |   3 -
 tests/btrfs/tests.mk                          |  63 ++++++
 tests/charsets/Makefile.am                    |   7 +-
 tests/charsets/test-charset-fidelity.c        |  12 +-
 tests/charsets/tests.mk                       |  60 ++++++
 tests/create/Makefile.am                      |   9 +-
 tests/create/tests.mk                         |  63 ++++++
 tests/discard/Makefile.am                     |   9 +-
 tests/discard/test-blkdiscard.pl              |   5 -
 tests/discard/test-discard.pl                 |   5 -
 tests/discard/test-fstrim.pl                  |   5 -
 tests/discard/tests.mk                        |  62 ++++++
 tests/disk-labels/Makefile.am                 |  10 +-
 tests/disk-labels/test-disk-labels.pl         |   4 +-
 tests/disk-labels/tests.mk                    |  60 ++++++
 tests/disks/Makefile.am                       |  14 +-
 tests/disks/test-max-disks.pl                 |   2 +-
 tests/disks/test-qemu-drive-libvirt.sh        |   4 +-
 tests/disks/tests.mk                          |  63 ++++++
 tests/events/Makefile.am                      |  19 +-
 tests/events/test-console-debug.pl            |   4 +-
 tests/events/tests.mk                         |  69 +++++++
 tests/fuzz/Makefile.am                        |  15 +-
 tests/fuzz/fuzz-inspection.pl                 |  11 +-
 tests/fuzz/tests.mk                           |  60 ++++++
 tests/hotplug/Makefile.am                     |  13 +-
 tests/hotplug/test-hot-add.pl                 |   4 +-
 tests/hotplug/test-hot-remove.pl              |   4 +-
 tests/hotplug/tests.mk                        |  61 ++++++
 tests/journal/Makefile.am                     |  10 +-
 tests/journal/test-journal.pl                 |   6 +-
 tests/journal/tests.mk                        |  60 ++++++
 tests/luks/Makefile.am                        |  11 +-
 tests/luks/test-luks-list.sh                  |   7 +-
 tests/luks/test-luks.sh                       |   7 +-
 tests/luks/tests.mk                           |  61 ++++++
 tests/lvm/Makefile.am                         |   9 +-
 tests/lvm/test-lvm-filtering.sh               |   7 +-
 tests/lvm/tests.mk                            |  61 ++++++
 tests/md/Makefile.am                          |  11 +-
 tests/md/test-inspect-fstab-md.sh             |  11 +-
 tests/md/test-inspect-fstab.sh                |   4 +-
 tests/md/test-list-filesystems.sh             |   7 +-
 tests/md/test-list-md-devices.sh              |   7 +-
 tests/md/test-mdadm.sh                        |   7 +-
 tests/md/tests.mk                             |  64 ++++++
 tests/mount-local/Makefile.am                 |  19 +-
 tests/mount-local/test-parallel-mount-local.c |  36 ++--
 tests/mount-local/tests.mk                    |  60 ++++++
 tests/mountable/Makefile.am                   |  10 +-
 tests/mountable/test-mountable-inspect.sh     |   9 +-
 tests/mountable/tests.mk                      |  63 ++++++
 tests/nbd/Makefile.am                         |  10 +-
 tests/nbd/test-nbd.pl                         |   6 +-
 tests/nbd/tests.mk                            |  60 ++++++
 tests/network/Makefile.am                     |  10 +-
 tests/network/test-network.sh                 |   5 -
 tests/network/tests.mk                        |  60 ++++++
 tests/ntfsclone/Makefile.am                   |  10 +-
 tests/ntfsclone/test-ntfsclone.sh             |  11 +-
 tests/ntfsclone/tests.mk                      |  60 ++++++
 tests/parallel/Makefile.am                    |  18 +-
 tests/parallel/test-parallel.c                |  11 +-
 tests/parallel/tests.mk                       |  30 +++
 tests/protocol/Makefile.am                    |  16 +-
 tests/protocol/tests.mk                       |  69 +++++++
 tests/qemu/Makefile.am                        |  18 +-
 tests/qemu/qemu-force-tcg.sh                  |   5 -
 tests/qemu/tests.mk                           |  66 +++++++
 tests/relative-paths/Makefile.am              |  11 +-
 tests/relative-paths/test-relative-paths.sh   |   8 +-
 tests/relative-paths/tests.mk                 |  60 ++++++
 tests/rsync/Makefile.am                       |   8 +-
 tests/rsync/test-rsync.sh                     |   8 +-
 tests/rsync/tests.mk                          |  60 ++++++
 tests/selinux/Makefile.am                     |  18 +-
 tests/selinux/run-test.pl                     |  10 +-
 tests/selinux/tests.mk                        |  64 ++++++
 tests/syslinux/Makefile.am                    |  13 +-
 tests/syslinux/test-syslinux.pl               |   4 +-
 tests/syslinux/tests.mk                       |  62 ++++++
 tests/tmpdirs/Makefile.am                     |  10 +-
 tests/tmpdirs/tests.mk                        |  63 ++++++
 tests/xfs/Makefile.am                         |  10 +-
 tests/xfs/test-xfs-misc.pl                    |   4 +-
 tests/xfs/tests.mk                            |  60 ++++++
 tests/xml/Makefile.am                         |  29 ++-
 tests/xml/rhbz701814.pl                       |   4 +-
 tests/xml/rhbz701814.sh                       |  22 +++
 tests/xml/tests.mk                            |  68 +++++++
 100 files changed, 2300 insertions(+), 438 deletions(-)
 create mode 100644 tests/9p/tests.mk
 create mode 100644 tests/bigdirs/tests.mk
 create mode 100644 tests/btrfs/tests.mk
 create mode 100644 tests/charsets/tests.mk
 create mode 100644 tests/create/tests.mk
 create mode 100644 tests/discard/tests.mk
 create mode 100644 tests/disk-labels/tests.mk
 create mode 100644 tests/disks/tests.mk
 create mode 100644 tests/events/tests.mk
 create mode 100644 tests/fuzz/tests.mk
 create mode 100644 tests/hotplug/tests.mk
 create mode 100644 tests/journal/tests.mk
 create mode 100644 tests/luks/tests.mk
 create mode 100644 tests/lvm/tests.mk
 create mode 100644 tests/md/tests.mk
 create mode 100644 tests/mount-local/tests.mk
 create mode 100644 tests/mountable/tests.mk
 create mode 100644 tests/nbd/tests.mk
 create mode 100644 tests/network/tests.mk
 create mode 100644 tests/ntfsclone/tests.mk
 create mode 100644 tests/parallel/tests.mk
 create mode 100644 tests/protocol/tests.mk
 create mode 100644 tests/qemu/tests.mk
 create mode 100644 tests/relative-paths/tests.mk
 create mode 100644 tests/rsync/tests.mk
 create mode 100644 tests/selinux/tests.mk
 create mode 100644 tests/syslinux/tests.mk
 create mode 100644 tests/tmpdirs/tests.mk
 create mode 100644 tests/xfs/tests.mk
 create mode 100755 tests/xml/rhbz701814.sh
 create mode 100644 tests/xml/tests.mk

diff --git a/.gitignore b/.gitignore
index 3cc68bc..6dbf1cd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -562,9 +562,6 @@ Makefile.in
 /tests/regressions/rhbz914931
 /tests/regressions/rhbz1044014.out
 /tests/regressions/rhbz1055452
-/tests/rsync/rsyncd.pid
-/tests/syslinux/extlinux-guest.img
-/tests/syslinux/syslinux-guest.img
 /test-tool/libguestfs-test-tool
 /test-tool/libguestfs-test-tool.1
 /test-tool/libguestfs-test-tool-helper
diff --git a/generator/tests.ml b/generator/tests.ml
index ba25399..8bd07a0 100644
--- a/generator/tests.ml
+++ b/generator/tests.ml
@@ -33,6 +33,36 @@ let defaults = {
 (* The tests in each subdirectory. *)
 let tests = [
 
+  "tests/qemu", {
+    defaults with
+      check = [
+        "qemu-liveness.sh";
+        "qemu-snapshot-isolation.sh";
+        "qemu-force-tcg.sh";
+      ];
+      (* qemu-boot & qemu-speed-test are built but not run by default
+       * as they are mainly qemu & kernel diagnostic tools.
+       *)
+      check_programs = [
+        "qemu-boot";
+        "qemu-speed-test";
+      ];
+  };
+
+  "tests/protocol", {
+    defaults with
+      check = [
+	"test-both-ends-cancel.sh";
+        "test-cancellation-download-librarycancels.sh";
+	"test-cancellation-upload-daemoncancels.sh";
+	"test-error-messages";
+        "test-launch-race.pl";
+	"test-qemudie-killsub.sh";
+	"test-qemudie-midcommand.sh";
+	"test-qemudie-synch.sh";
+      ];
+  };
+
   "tests/c-api", {
     defaults with
       check_fast = [
@@ -60,6 +90,243 @@ let tests = [
       ];
   };
 
+  "tests/9p", {
+    defaults with
+      check = [
+        "test-9p.sh";
+      ];
+  };
+
+  "tests/bigdirs", {
+    defaults with
+      check_slow = [
+        "test-big-dirs.pl";
+      ];
+  };
+
+  "tests/btrfs", {
+    defaults with
+      check = [
+        "test-btrfs-misc.pl";
+        "test-btrfs-devices.sh";
+        "test-btrfs-subvolume-default.pl";
+        "test-btrfs-replace.sh";
+      ];
+  };
+
+  "tests/charsets", {
+    defaults with
+      check = [
+        "test-charset-fidelity";
+      ];
+  };
+
+  "tests/create", {
+    defaults with
+      check_fast = [
+        "test-disk-create.sh";
+      ];
+  };
+
+  "tests/discard", {
+    defaults with
+      check = [
+        "test-blkdiscard.pl";
+        "test-discard.pl";
+        "test-fstrim.pl";
+      ];
+  };
+
+  "tests/disk-labels", {
+    defaults with
+      check = [
+        "test-disk-labels.pl";
+      ];
+  };
+
+  "tests/disks", {
+    defaults with
+      check = [
+        "test-max-disks.pl";
+        "test-qemu-drive-libvirt.sh";
+        "test-qemu-drive.sh";
+      ];
+      check_scripts = [
+        "debug-qemu.sh";
+      ];
+  };
+
+  "tests/events", {
+    defaults with
+      check_fast = [
+        "test-libvirt-auth-callbacks";
+      ];
+      check = [
+        "test-console-debug.pl";
+      ];
+      check_data = [
+        "libvirt-auth.xml";
+      ];
+  };
+
+  "tests/fuzz", {
+    defaults with
+      check = [
+        "fuzz-inspection.pl";
+      ];
+  };
+
+  "tests/hotplug", {
+    defaults with
+      check = [
+        "test-hot-add.pl";
+        "test-hot-remove.pl";
+      ];
+  };
+
+  "tests/journal", {
+    defaults with
+      check = [
+        "test-journal.pl";
+      ];
+  };
+
+  "tests/luks", {
+    defaults with
+      check = [
+        "test-luks.sh";
+        "test-luks-list.sh";
+      ];
+  };
+
+  "tests/lvm", {
+    defaults with
+      check = [
+        "test-lvm-filtering.sh";
+        "test-lvm-mapping.pl";
+      ];
+  };
+
+  "tests/md", {
+    defaults with
+      check = [
+	"test-inspect-fstab.sh";
+	"test-inspect-fstab-md.sh";
+	"test-list-filesystems.sh";
+	"test-list-md-devices.sh";
+	"test-mdadm.sh";
+      ];
+  };
+
+  "tests/mountable", {
+    defaults with
+      check = [
+        "test-internal-parse-mountable";
+	"test-mountable-inspect.sh";
+      ];
+  };
+
+  "tests/mount-local", {
+    defaults with
+      check = [
+        "test-parallel-mount-local";
+      ];
+  };
+
+  "tests/nbd", {
+    defaults with
+      check = [
+        "test-nbd.pl";
+      ];
+  };
+
+  "tests/network", {
+    defaults with
+      check = [
+        "test-network.sh";
+      ];
+  };
+
+  "tests/ntfsclone", {
+    defaults with
+      check = [
+        "test-ntfsclone.sh";
+      ];
+  };
+
+  "tests/parallel", {
+    defaults with
+      check_slow = [
+        "test-parallel";
+      ];
+  };
+
+  "tests/relative-paths", {
+    defaults with
+      check = [
+        "test-relative-paths.sh";
+      ];
+  };
+
+  "tests/rsync", {
+    defaults with
+      check = [
+        "test-rsync.sh";
+      ];
+  };
+
+  "tests/selinux", {
+    defaults with
+      check = [
+        "test-xattrs-direct.sh";
+        "test-selinux-direct.sh";
+        "test-xattrs-fuse.sh";
+        "test-selinux-fuse.sh";
+      ];
+      check_scripts = [
+        "run-test.pl"
+      ];
+  };
+
+  "tests/syslinux", {
+    defaults with
+      check = [
+        "test-syslinux.sh";
+        "test-extlinux.sh";
+      ];
+      check_scripts = [
+        "test-syslinux.pl"
+      ];
+  };
+
+  "tests/tmpdirs", {
+    defaults with
+      check_fast = [
+        "test-tmpdirs.pl";
+      ];
+  };
+
+  "tests/xfs", {
+    defaults with
+      check = [
+        "test-xfs-misc.pl";
+      ];
+  };
+
+  "tests/xml", {
+    defaults with
+      check_fast = [
+        "rhbz701814.sh";
+      ];
+      check_scripts = [
+        "rhbz701814.pl";
+      ];
+      check_data = [
+	"rhbz701814-faked.xml";
+	"rhbz701814-node.xml"
+      ];
+  };
+
   "inspector", {
     defaults with
       check = [
diff --git a/tests/9p/Makefile.am b/tests/9p/Makefile.am
index 5c4629a..cbf7907 100644
--- a/tests/9p/Makefile.am
+++ b/tests/9p/Makefile.am
@@ -17,9 +17,8 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
-EXTRA_DIST = $(TESTS)
+generator_built = tests.mk
 
-TESTS = test-9p.sh
+EXTRA_DIST = test-9p.sh
 
-TESTS_ENVIRONMENT = abs_srcdir=$(abs_srcdir) \
-	$(top_builddir)/run --test
+include $(srcdir)/tests.mk
diff --git a/tests/9p/test-9p.sh b/tests/9p/test-9p.sh
index 9e396a4..5ab47ab 100755
--- a/tests/9p/test-9p.sh
+++ b/tests/9p/test-9p.sh
@@ -21,11 +21,6 @@
 
 set -e
 
-if [ -n "$SKIP_TEST_9P_SH" ]; then
-    echo "$0: test skipped because environment variable is set."
-    exit 77
-fi
-
 backend="$(guestfish get-backend)"
 if [[ "$backend" != "direct" ]]; then
     echo "$0: test skipped because backend ($backend) is not 'direct'."
diff --git a/tests/9p/tests.mk b/tests/9p/tests.mk
new file mode 100644
index 0000000..d706b07
--- /dev/null
+++ b/tests/9p/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)/tests/9p
+
+localtests_SCRIPTS = \
+	test-9p.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/tests/bigdirs/Makefile.am b/tests/bigdirs/Makefile.am
index 770d97d..34fbf74 100644
--- a/tests/bigdirs/Makefile.am
+++ b/tests/bigdirs/Makefile.am
@@ -17,14 +17,8 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
+generator_built = tests.mk
+
 EXTRA_DIST = test-big-dirs.pl
 
-# Don't run this test by default.  It takes a very long time to run
-# and is not especially informative.  However we have to have an empty
-# TESTS rule otherwise you can't run the test from the command line
-# using 'make TESTS=test-big-dirs.pl check'
-TESTS =
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
-
-check-slow:
-	$(MAKE) TESTS="test-big-dirs.pl" check
+include $(srcdir)/tests.mk
diff --git a/tests/bigdirs/tests.mk b/tests/bigdirs/tests.mk
new file mode 100644
index 0000000..daa233c
--- /dev/null
+++ b/tests/bigdirs/tests.mk
@@ -0,0 +1,30 @@
+# 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)/tests/bigdirs
+
+localtests_SCRIPTS = \
+	test-big-dirs.pl
+
+check-slow:
+	$(top_builddir)/run $(top_builddir)/test-harness --slow
+
+EXTRA_DIST += tests.mk
diff --git a/tests/btrfs/Makefile.am b/tests/btrfs/Makefile.am
index b6ef794..97de00b 100644
--- a/tests/btrfs/Makefile.am
+++ b/tests/btrfs/Makefile.am
@@ -17,13 +17,12 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
-TESTS = \
-	test-btrfs-misc.pl \
-	test-btrfs-devices.sh \
-	test-btrfs-subvolume-default.pl \
-	test-btrfs-replace.sh
-
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
+generator_built = tests.mk
 
 EXTRA_DIST = \
-	$(TESTS)
+	test-btrfs-devices.sh \
+	test-btrfs-misc.pl \
+	test-btrfs-replace.sh \
+	test-btrfs-subvolume-default.pl
+
+include $(srcdir)/tests.mk
diff --git a/tests/btrfs/test-btrfs-devices.sh b/tests/btrfs/test-btrfs-devices.sh
index 3935c60..785f767 100755
--- a/tests/btrfs/test-btrfs-devices.sh
+++ b/tests/btrfs/test-btrfs-devices.sh
@@ -24,12 +24,6 @@
 
 set -e
 
-# Allow the test to be skipped since btrfs is often broken.
-if [ -n "$SKIP_TEST_BTRFS_DEVICES_SH" ]; then
-    echo "$0: skipping test because environment variable is set."
-    exit 77
-fi
-
 # If btrfs is not available, bail.
 if ! guestfish -a /dev/null run : available btrfs; then
     echo "$0: skipping test because btrfs is not available"
@@ -55,7 +49,7 @@ mkfs-btrfs "/dev/sda1 /dev/sdb1"
 mount /dev/sda1 /
 
 mkdir /data1
-tar-in $srcdir/../data/filesanddirs-10M.tar.xz /data1 compress:xz
+tar-in $datadir/filesanddirs-10M.tar.xz /data1 compress:xz
 
 # In btrfs-progs 0.19, a test was added which prevents us from
 # deleting the mount device (/dev/sda1) although that restriction
diff --git a/tests/btrfs/test-btrfs-misc.pl b/tests/btrfs/test-btrfs-misc.pl
index 0a8e942..2c6c9dd 100755
--- a/tests/btrfs/test-btrfs-misc.pl
+++ b/tests/btrfs/test-btrfs-misc.pl
@@ -24,9 +24,6 @@ use Errno;
 
 use Sys::Guestfs;
 
-# Allow the test to be skipped since btrfs is often broken.
-exit 77 if $ENV{SKIP_TEST_BTRFS_MISC_PL};
-
 my $g = Sys::Guestfs->new ();
 
 $g->add_drive_scratch (1024*1024*1024);
diff --git a/tests/btrfs/test-btrfs-subvolume-default.pl b/tests/btrfs/test-btrfs-subvolume-default.pl
index fd20fa2..b7045ac 100755
--- a/tests/btrfs/test-btrfs-subvolume-default.pl
+++ b/tests/btrfs/test-btrfs-subvolume-default.pl
@@ -23,9 +23,6 @@ use warnings;
 
 use Sys::Guestfs;
 
-# Allow the test to be skipped since btrfs is often broken.
-exit 77 if $ENV{SKIP_TEST_BTRFS_SUBVOLUME_DEFAULT_PL};
-
 my $g = Sys::Guestfs->new ();
 
 $g->add_drive_scratch (1024*1024*1024);
diff --git a/tests/btrfs/tests.mk b/tests/btrfs/tests.mk
new file mode 100644
index 0000000..f8b49a4
--- /dev/null
+++ b/tests/btrfs/tests.mk
@@ -0,0 +1,63 @@
+# 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)/tests/btrfs
+
+localtests_SCRIPTS = \
+	test-btrfs-devices.sh \
+	test-btrfs-misc.pl \
+	test-btrfs-replace.sh \
+	test-btrfs-subvolume-default.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/tests/charsets/Makefile.am b/tests/charsets/Makefile.am
index b6e503e..274e84f 100644
--- a/tests/charsets/Makefile.am
+++ b/tests/charsets/Makefile.am
@@ -17,12 +17,11 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
-TESTS = \
-	test-charset-fidelity
+generator_built = tests.mk
 
-TESTS_ENVIRONMENT = $(top_builddir)/run --test $(VG)
+EXTRA_DIST =
 
-check_PROGRAMS = $(TESTS)
+include $(srcdir)/tests.mk
 
 test_charset_fidelity_SOURCES = test-charset-fidelity.c
 test_charset_fidelity_CPPFLAGS = \
diff --git a/tests/charsets/test-charset-fidelity.c b/tests/charsets/test-charset-fidelity.c
index 9a477ce..869b123 100644
--- a/tests/charsets/test-charset-fidelity.c
+++ b/tests/charsets/test-charset-fidelity.c
@@ -33,8 +33,6 @@
 #include "guestfs.h"
 #include "guestfs-internal-frontend.h"
 
-static const char ourenvvar[] = "SKIP_TEST_CHARSET_FIDELITY";
-
 struct filesystem {
   const char *fs_name;          /* Name of filesystem. */
   int fs_case_insensitive;      /* True if filesystem is case insensitive. */
@@ -74,19 +72,10 @@ static void ignore_lost_and_found (char **);
 int
 main (int argc, char *argv[])
 {
-  char *str;
   guestfs_h *g;
   size_t i;
   struct filesystem *fs;
 
-  /* Allow this test to be skipped. */
-  str = getenv (ourenvvar);
-  if (str && guestfs_int_is_true (str) > 0) {
-    printf ("%s: test skipped because environment variable is set.\n",
-            guestfs_int_program_name);
-    exit (77);
-  }
-
   g = guestfs_create ();
   if (g == NULL)
     error (EXIT_FAILURE, 0, "failed to create handle");
@@ -114,6 +103,7 @@ main (int argc, char *argv[])
 static void
 test_filesystem (guestfs_h *g, const struct filesystem *fs)
 {
+  static const char ourenvvar[] = "SKIP_TEST_CHARSET_FIDELITY";
   const char *feature[] = { fs->fs_feature, NULL };
   char envvar[sizeof (ourenvvar) + 20];
   char *str;
diff --git a/tests/charsets/tests.mk b/tests/charsets/tests.mk
new file mode 100644
index 0000000..d18e30e
--- /dev/null
+++ b/tests/charsets/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)/tests/charsets
+
+localtests_PROGRAMS = \
+	test-charset-fidelity
+
+# 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/tests/create/Makefile.am b/tests/create/Makefile.am
index cdcecd2..4f4fd42 100644
--- a/tests/create/Makefile.am
+++ b/tests/create/Makefile.am
@@ -17,11 +17,8 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
-TESTS = \
-	test-disk-create.sh
+generator_built = tests.mk
 
-TESTS_ENVIRONMENT = \
-	$(top_builddir)/run --test
+EXTRA_DIST = test-disk-create.sh
 
-EXTRA_DIST = \
-	$(TESTS)
+include $(srcdir)/tests.mk
diff --git a/tests/create/tests.mk b/tests/create/tests.mk
new file mode 100644
index 0000000..d0e98d2
--- /dev/null
+++ b/tests/create/tests.mk
@@ -0,0 +1,63 @@
+# 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)/tests/create
+
+localtests_SCRIPTS = \
+	test-disk-create.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/tests/discard/Makefile.am b/tests/discard/Makefile.am
index e109628..09aa77c 100644
--- a/tests/discard/Makefile.am
+++ b/tests/discard/Makefile.am
@@ -17,12 +17,11 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
-TESTS = \
+generator_built = tests.mk
+
+EXTRA_DIST = \
 	test-blkdiscard.pl \
 	test-discard.pl \
 	test-fstrim.pl
 
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
-
-EXTRA_DIST = \
-	$(TESTS)
+include $(srcdir)/tests.mk
diff --git a/tests/discard/test-blkdiscard.pl b/tests/discard/test-blkdiscard.pl
index e080350..2142a27 100755
--- a/tests/discard/test-blkdiscard.pl
+++ b/tests/discard/test-blkdiscard.pl
@@ -28,11 +28,6 @@ $ENV{"LANG"} = "C";
 
 $| = 1;
 
-if ($ENV{SKIP_TEST_BLKDISCARD_PL}) {
-    print "$0: skipped test because environment variable is set\n";
-    exit 77;
-}
-
 my $g = Sys::Guestfs->new ();
 
 # Discard is only supported when using qemu.
diff --git a/tests/discard/test-discard.pl b/tests/discard/test-discard.pl
index dbcf6a5..bd92d5e 100755
--- a/tests/discard/test-discard.pl
+++ b/tests/discard/test-discard.pl
@@ -28,11 +28,6 @@ $ENV{"LANG"} = "C";
 
 $| = 1;
 
-if ($ENV{SKIP_TEST_DISCARD_PL}) {
-    print "$0: skipped test because environment variable is set\n";
-    exit 77;
-}
-
 my $g = Sys::Guestfs->new ();
 
 # Discard is only supported when using qemu.
diff --git a/tests/discard/test-fstrim.pl b/tests/discard/test-fstrim.pl
index cbd28bf..b847fd4 100755
--- a/tests/discard/test-fstrim.pl
+++ b/tests/discard/test-fstrim.pl
@@ -28,11 +28,6 @@ $ENV{"LANG"} = "C";
 
 $| = 1;
 
-if ($ENV{SKIP_TEST_FSTRIM_PL}) {
-    print "$0: skipped test because environment variable is set\n";
-    exit 77;
-}
-
 my $g = Sys::Guestfs->new ();
 
 # Discard is only supported when using qemu.
diff --git a/tests/discard/tests.mk b/tests/discard/tests.mk
new file mode 100644
index 0000000..061b34e
--- /dev/null
+++ b/tests/discard/tests.mk
@@ -0,0 +1,62 @@
+# 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)/tests/discard
+
+localtests_SCRIPTS = \
+	test-blkdiscard.pl \
+	test-discard.pl \
+	test-fstrim.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/tests/disk-labels/Makefile.am b/tests/disk-labels/Makefile.am
index cd8f0e7..38fe06a 100644
--- a/tests/disk-labels/Makefile.am
+++ b/tests/disk-labels/Makefile.am
@@ -1,5 +1,5 @@
 # libguestfs
-# Copyright (C) 2012 Red Hat Inc.
+# Copyright (C) 2012-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -17,10 +17,8 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
-TESTS = \
-	test-disk-labels.pl
+generator_built = tests.mk
 
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
+EXTRA_DIST = test-disk-labels.pl
 
-EXTRA_DIST = \
-	$(TESTS)
+include $(srcdir)/tests.mk
diff --git a/tests/disk-labels/test-disk-labels.pl b/tests/disk-labels/test-disk-labels.pl
index a74e300..66f58c8 100755
--- a/tests/disk-labels/test-disk-labels.pl
+++ b/tests/disk-labels/test-disk-labels.pl
@@ -1,5 +1,5 @@
 #!/usr/bin/perl
-# Copyright (C) 2012 Red Hat Inc.
+# Copyright (C) 2012-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -23,8 +23,6 @@ use warnings;
 
 use Sys::Guestfs;
 
-exit 77 if $ENV{SKIP_TEST_DISK_LABELS_PL};
-
 if (Sys::Guestfs->new()->get_backend() eq "uml") {
     print "$0: test skipped because UML backend does not support disk labels\n";
     exit 77
diff --git a/tests/disk-labels/tests.mk b/tests/disk-labels/tests.mk
new file mode 100644
index 0000000..129007d
--- /dev/null
+++ b/tests/disk-labels/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)/tests/disk-labels
+
+localtests_SCRIPTS = \
+	test-disk-labels.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/tests/disks/Makefile.am b/tests/disks/Makefile.am
index ec95e82..fb858ec 100644
--- a/tests/disks/Makefile.am
+++ b/tests/disks/Makefile.am
@@ -17,16 +17,12 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
-TESTS = \
+generator_built = tests.mk
+
+EXTRA_DIST = \
+	debug-qemu.sh \
 	test-max-disks.pl \
 	test-qemu-drive-libvirt.sh \
 	test-qemu-drive.sh
 
-TESTS_ENVIRONMENT = \
-	abs_srcdir=$(abs_srcdir) \
-	abs_builddir=$(abs_builddir) \
-	$(top_builddir)/run --test
-
-EXTRA_DIST = \
-	debug-qemu.sh \
-	$(TESTS)
+include $(srcdir)/tests.mk
diff --git a/tests/disks/test-max-disks.pl b/tests/disks/test-max-disks.pl
index 9561b6b..6fd86fa 100755
--- a/tests/disks/test-max-disks.pl
+++ b/tests/disks/test-max-disks.pl
@@ -1,5 +1,5 @@
 #!/usr/bin/perl
-# Copyright (C) 2012 Red Hat Inc.
+# Copyright (C) 2012-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
diff --git a/tests/disks/test-qemu-drive-libvirt.sh b/tests/disks/test-qemu-drive-libvirt.sh
index 59d6101..e3610a6 100755
--- a/tests/disks/test-qemu-drive-libvirt.sh
+++ b/tests/disks/test-qemu-drive-libvirt.sh
@@ -31,12 +31,12 @@ if [ -z "$abs_builddir" ]; then
     exit 1
 fi
 
-if [ ! -x ../../src/libvirt-is-version ]; then
+if [ ! -x $top_builddir/src/libvirt-is-version ]; then
     echo "$0: test skipped because libvirt-is-version is not built yet"
     exit 77
 fi
 
-if ! ../../src/libvirt-is-version 1 1 3; then
+if ! $top_builddir/src/libvirt-is-version 1 1 3; then
     echo "$0: test skipped because libvirt is too old (< 1.1.3)"
     exit 77
 fi
diff --git a/tests/disks/tests.mk b/tests/disks/tests.mk
new file mode 100644
index 0000000..5382453
--- /dev/null
+++ b/tests/disks/tests.mk
@@ -0,0 +1,63 @@
+# 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)/tests/disks
+
+localtests_SCRIPTS = \
+	debug-qemu.sh \
+	test-max-disks.pl \
+	test-qemu-drive-libvirt.sh \
+	test-qemu-drive.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/tests/events/Makefile.am b/tests/events/Makefile.am
index 6569854..ef74bbf 100644
--- a/tests/events/Makefile.am
+++ b/tests/events/Makefile.am
@@ -17,20 +17,15 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
+generator_built = tests.mk
+
 EXTRA_DIST = \
-	test-console-debug.pl \
-	libvirt-auth.xml
+	libvirt-auth.xml \
+	test-console-debug.pl
 
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
-
-check_PROGRAMS =
-
-TESTS = test-console-debug.pl
+include $(srcdir)/tests.mk
 
 if HAVE_LIBVIRT
-TESTS += test-libvirt-auth-callbacks
-check_PROGRAMS += test-libvirt-auth-callbacks
-
 test_libvirt_auth_callbacks_SOURCES = test-libvirt-auth-callbacks.c
 test_libvirt_auth_callbacks_CPPFLAGS = \
 	-I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \
@@ -45,4 +40,8 @@ test_libvirt_auth_callbacks_LDADD = \
         $(LIBXML2_LIBS) \
         $(LTLIBINTL) \
         $(top_builddir)/gnulib/lib/libgnu.la
+else
+test-libvirt-auth-callbacks:
+	echo 'exit 77' > $@
+	chmod 0755 $@
 endif
diff --git a/tests/events/test-console-debug.pl b/tests/events/test-console-debug.pl
index eb6a774..f2057a6 100755
--- a/tests/events/test-console-debug.pl
+++ b/tests/events/test-console-debug.pl
@@ -1,5 +1,5 @@
 #!/usr/bin/perl
-# Copyright (C) 2013 Red Hat Inc.
+# Copyright (C) 2013-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -22,8 +22,6 @@ use warnings;
 
 use Sys::Guestfs;
 
-exit 77 if $ENV{SKIP_TEST_CONSOLE_DEBUG_PL};
-
 my $g = Sys::Guestfs->new ();
 
 my $log_messages = "";
diff --git a/tests/events/tests.mk b/tests/events/tests.mk
new file mode 100644
index 0000000..df36a2d
--- /dev/null
+++ b/tests/events/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)/tests/events
+
+localtests_DATA = \
+	libvirt-auth.xml
+
+localtests_SCRIPTS = \
+	test-console-debug.pl
+
+localtests_PROGRAMS = \
+	test-libvirt-auth-callbacks
+
+# 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/tests/fuzz/Makefile.am b/tests/fuzz/Makefile.am
index 67793d5..facd40b 100644
--- a/tests/fuzz/Makefile.am
+++ b/tests/fuzz/Makefile.am
@@ -1,5 +1,5 @@
 # libguestfs
-# Copyright (C) 2013 Red Hat Inc.
+# Copyright (C) 2013-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -17,15 +17,8 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
-EXTRA_DIST = \
-	$(TESTS)
+generator_built = tests.mk
 
-export ITERATIONS ?= 10
+EXTRA_DIST = fuzz-inspection.pl
 
-TESTS = \
-	fuzz-inspection.pl
-
-TESTS_ENVIRONMENT = $(top_builddir)/run --test $(VG)
-
-check-valgrind:
-	$(MAKE) VG="@VG@" check
+include $(srcdir)/tests.mk
diff --git a/tests/fuzz/fuzz-inspection.pl b/tests/fuzz/fuzz-inspection.pl
index 9fcd98e..c651ca9 100755
--- a/tests/fuzz/fuzz-inspection.pl
+++ b/tests/fuzz/fuzz-inspection.pl
@@ -33,19 +33,14 @@ $progname =~ s{.*/}{};
 
 my $trace_depth = 0;
 
-my $srcdir = $ENV{srcdir} || ".";
+my $srcdir = $ENV{srcdir};
 # Location of tests/data.
-my $datasrcdir = $srcdir . "/../data";
-my $databindir = "../data";
+my $datasrcdir = $ENV{datadir};
+my $databindir = $ENV{datadir};
 # Location of tests/guests/guest-aux.
 my $guestauxsrcdir = $srcdir . "/../guests/guest-aux";
 my $guestauxbindir = "../guests/guest-aux";
 
-if ($ENV{SKIP_FUZZ_INSPECTION_PL}) {
-    print "$progname: test skipped because environment variable set\n";
-    exit 77
-}
-
 # So srand returns the seed.
 if ($] < 5.014) {
     print "$progname: test skipped because perl < 5.14\n";
diff --git a/tests/fuzz/tests.mk b/tests/fuzz/tests.mk
new file mode 100644
index 0000000..c85f1e8
--- /dev/null
+++ b/tests/fuzz/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)/tests/fuzz
+
+localtests_SCRIPTS = \
+	fuzz-inspection.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/tests/hotplug/Makefile.am b/tests/hotplug/Makefile.am
index 9187c76..7f687a5 100644
--- a/tests/hotplug/Makefile.am
+++ b/tests/hotplug/Makefile.am
@@ -1,5 +1,5 @@
 # libguestfs
-# Copyright (C) 2012 Red Hat Inc.
+# Copyright (C) 2012-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -17,12 +17,11 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
-TESTS = \
-	test-hot-add.pl \
-	test-hot-remove.pl
-
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
+generator_built = tests.mk
 
 EXTRA_DIST = \
-	$(TESTS) \
+	test-hot-add.pl \
+	test-hot-remove.pl \
 	test-hotplug-repeated.pl
+
+include $(srcdir)/tests.mk
diff --git a/tests/hotplug/test-hot-add.pl b/tests/hotplug/test-hot-add.pl
index 034cff4..07701e3 100755
--- a/tests/hotplug/test-hot-add.pl
+++ b/tests/hotplug/test-hot-add.pl
@@ -1,5 +1,5 @@
 #!/usr/bin/perl
-# Copyright (C) 2012 Red Hat Inc.
+# Copyright (C) 2012-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -24,8 +24,6 @@ use Sys::Guestfs;
 
 my $g = Sys::Guestfs->new ();
 
-exit 77 if $ENV{SKIP_TEST_HOT_ADD_PL};
-
 # Skip the test if the default backend isn't libvirt, since only
 # the libvirt backend supports hotplugging.
 my $backend = $g->get_backend ();
diff --git a/tests/hotplug/test-hot-remove.pl b/tests/hotplug/test-hot-remove.pl
index 087399d..c2fc404 100755
--- a/tests/hotplug/test-hot-remove.pl
+++ b/tests/hotplug/test-hot-remove.pl
@@ -1,5 +1,5 @@
 #!/usr/bin/perl
-# Copyright (C) 2012 Red Hat Inc.
+# Copyright (C) 2012-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -24,8 +24,6 @@ use Sys::Guestfs;
 
 my $g = Sys::Guestfs->new ();
 
-exit 77 if $ENV{SKIP_TEST_HOT_REMOVE_PL};
-
 # Skip the test if the default backend isn't libvirt, since only
 # the libvirt backend supports hotplugging.
 my $backend = $g->get_backend ();
diff --git a/tests/hotplug/tests.mk b/tests/hotplug/tests.mk
new file mode 100644
index 0000000..8ccb901
--- /dev/null
+++ b/tests/hotplug/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)/tests/hotplug
+
+localtests_SCRIPTS = \
+	test-hot-add.pl \
+	test-hot-remove.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/tests/journal/Makefile.am b/tests/journal/Makefile.am
index ffdf5fe..c71e300 100644
--- a/tests/journal/Makefile.am
+++ b/tests/journal/Makefile.am
@@ -1,5 +1,5 @@
 # libguestfs
-# Copyright (C) 2013 Red Hat Inc.
+# Copyright (C) 2013-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -17,10 +17,8 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
-TESTS = \
-	test-journal.pl
+generator_built = tests.mk
 
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
+EXTRA_DIST = test-journal.pl
 
-EXTRA_DIST = \
-	$(TESTS)
+include $(srcdir)/tests.mk
diff --git a/tests/journal/test-journal.pl b/tests/journal/test-journal.pl
index 38950f9..018523d 100755
--- a/tests/journal/test-journal.pl
+++ b/tests/journal/test-journal.pl
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 # libguestfs
-# Copyright (C) 2013 Red Hat Inc.
+# Copyright (C) 2013-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -25,10 +25,8 @@ use warnings;
 
 use Sys::Guestfs;
 
-exit 77 if $ENV{SKIP_TEST_JOURNAL_PL};
-
 my $g = Sys::Guestfs->new ();
-$g->add_drive ("../guests/fedora.img", readonly => 1, format => "raw");
+$g->add_drive ("$ENV{phonydir}/fedora.img", readonly => 1, format => "raw");
 $g->launch ();
 
 # If journal feature is not available, bail.
diff --git a/tests/journal/tests.mk b/tests/journal/tests.mk
new file mode 100644
index 0000000..7b8a7f3
--- /dev/null
+++ b/tests/journal/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)/tests/journal
+
+localtests_SCRIPTS = \
+	test-journal.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/tests/luks/Makefile.am b/tests/luks/Makefile.am
index 3d1fb67..08cf007 100644
--- a/tests/luks/Makefile.am
+++ b/tests/luks/Makefile.am
@@ -17,11 +17,10 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
-TESTS = \
-	test-luks.sh \
-	test-luks-list.sh
-
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
+generator_built = tests.mk
 
 EXTRA_DIST = \
-	$(TESTS)
+	test-luks-list.sh \
+	test-luks.sh
+
+include $(srcdir)/tests.mk
diff --git a/tests/luks/test-luks-list.sh b/tests/luks/test-luks-list.sh
index be22e8b..a420535 100755
--- a/tests/luks/test-luks-list.sh
+++ b/tests/luks/test-luks-list.sh
@@ -1,6 +1,6 @@
 #!/bin/bash -
 # libguestfs
-# Copyright (C) 2011 Red Hat Inc.
+# Copyright (C) 2011-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -20,11 +20,6 @@
 
 set -e
 
-[ -n "$SKIP_TEST_LUKS_SH" ] && {
-    echo "test-luks-list.sh skipped (environment variable set)"
-    exit 77
-}
-
 # If luks is not available, bail.
 if ! guestfish -a /dev/null run : available luks; then
     echo "$0: skipping test because luks is not available"
diff --git a/tests/luks/test-luks.sh b/tests/luks/test-luks.sh
index 2f65750..3b9dda4 100755
--- a/tests/luks/test-luks.sh
+++ b/tests/luks/test-luks.sh
@@ -1,6 +1,6 @@
 #!/bin/bash -
 # libguestfs
-# Copyright (C) 2010 Red Hat Inc.
+# Copyright (C) 2010-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -20,11 +20,6 @@
 
 set -e
 
-[ -n "$SKIP_TEST_LUKS_SH" ] && {
-    echo "test-luks.sh skipped (environment variable set)"
-    exit 77
-}
-
 # If luks is not available, bail.
 if ! guestfish -a /dev/null run : available luks; then
     echo "$0: skipping test because luks is not available"
diff --git a/tests/luks/tests.mk b/tests/luks/tests.mk
new file mode 100644
index 0000000..d370b99
--- /dev/null
+++ b/tests/luks/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)/tests/luks
+
+localtests_SCRIPTS = \
+	test-luks-list.sh \
+	test-luks.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/tests/lvm/Makefile.am b/tests/lvm/Makefile.am
index 4c509f2..cc8c63e 100644
--- a/tests/lvm/Makefile.am
+++ b/tests/lvm/Makefile.am
@@ -17,11 +17,10 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
-TESTS = \
+generator_built = tests.mk
+
+EXTRA_DIST = \
 	test-lvm-filtering.sh \
 	test-lvm-mapping.pl
 
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
-
-EXTRA_DIST = \
-	$(TESTS)
+include $(srcdir)/tests.mk
diff --git a/tests/lvm/test-lvm-filtering.sh b/tests/lvm/test-lvm-filtering.sh
index f00d712..b8acd34 100755
--- a/tests/lvm/test-lvm-filtering.sh
+++ b/tests/lvm/test-lvm-filtering.sh
@@ -1,6 +1,6 @@
 #!/bin/bash -
 # libguestfs
-# Copyright (C) 2010 Red Hat Inc.
+# Copyright (C) 2010-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -20,11 +20,6 @@
 
 set -e
 
-if [ -n "$SKIP_TEST_LVM_FILTERING_SH" ]; then
-    echo "$0: skipping test because environment variable is set."
-    exit 77
-fi
-
 rm -f test-lvm-filtering-1.img test-lvm-filtering-2.img
 
 actual=$(guestfish <<'EOF'
diff --git a/tests/lvm/tests.mk b/tests/lvm/tests.mk
new file mode 100644
index 0000000..de3f4f0
--- /dev/null
+++ b/tests/lvm/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)/tests/lvm
+
+localtests_SCRIPTS = \
+	test-lvm-filtering.sh \
+	test-lvm-mapping.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/tests/md/Makefile.am b/tests/md/Makefile.am
index e1f5e54..c03eec9 100644
--- a/tests/md/Makefile.am
+++ b/tests/md/Makefile.am
@@ -17,14 +17,13 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
-TESTS = \
-	test-inspect-fstab.sh \
+generator_built = tests.mk
+
+EXTRA_DIST = \
 	test-inspect-fstab-md.sh \
+	test-inspect-fstab.sh \
 	test-list-filesystems.sh \
 	test-list-md-devices.sh \
 	test-mdadm.sh
 
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
-
-EXTRA_DIST = \
-	$(TESTS)
+include $(srcdir)/tests.mk
diff --git a/tests/md/test-inspect-fstab-md.sh b/tests/md/test-inspect-fstab-md.sh
index 43e1d3a..72323f5 100755
--- a/tests/md/test-inspect-fstab-md.sh
+++ b/tests/md/test-inspect-fstab-md.sh
@@ -1,6 +1,6 @@
 #!/bin/bash -
 # libguestfs
-# Copyright (C) 2011 Red Hat Inc.
+# Copyright (C) 2011-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -21,16 +21,11 @@
 set -e
 export LANG=C
 
-if [ -n "$SKIP_TEST_INSPECT_FSTAB_MD_SH" ]; then
-    echo "$0: test skipped because environment variable is set."
-    exit 77
-fi
-
 rm -f inspect-fstab-md-{1,2}.img inspect-fstab-md.fstab inspect-fstab-md.output
 
 # First, test the regular fedora image, which specifies /boot as /dev/md0
-cp ../guests/fedora-md1.img inspect-fstab-md-1.img
-cp ../guests/fedora-md2.img inspect-fstab-md-2.img
+cp $phonydir/fedora-md1.img inspect-fstab-md-1.img
+cp $phonydir/fedora-md2.img inspect-fstab-md-2.img
 
 guestfish -i inspect-fstab-md-[12].img <<'EOF' | sort > inspect-fstab-md.output
   exists /boot/grub/grub.conf
diff --git a/tests/md/test-inspect-fstab.sh b/tests/md/test-inspect-fstab.sh
index f31ec2e..ab65c12 100755
--- a/tests/md/test-inspect-fstab.sh
+++ b/tests/md/test-inspect-fstab.sh
@@ -1,6 +1,6 @@
 #!/bin/bash -
 # libguestfs
-# Copyright (C) 2011 Red Hat Inc.
+# Copyright (C) 2011-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -35,7 +35,7 @@ rm -f inspect-fstab-1.qcow2 inspect-fstab.fstab inspect-fstab.output
 # and then inspect it.
 guestfish -- \
   disk-create inspect-fstab-1.qcow2 qcow2 -1 \
-    backingfile:../guests/fedora.img backingformat:raw
+    backingfile:$phonydir/fedora.img backingformat:raw
 
 cat <<'EOF' > inspect-fstab.fstab
 /dev/VG/Root / ext2 default 0 0
diff --git a/tests/md/test-list-filesystems.sh b/tests/md/test-list-filesystems.sh
index 2bfa6f3..9e8544b 100755
--- a/tests/md/test-list-filesystems.sh
+++ b/tests/md/test-list-filesystems.sh
@@ -1,6 +1,6 @@
 #!/bin/bash -
 # libguestfs
-# Copyright (C) 2011 Red Hat Inc.
+# Copyright (C) 2011-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -20,11 +20,6 @@
 
 set -e
 
-if [ -n "$SKIP_TEST_LIST_FILESYSTEMS_SH" ]; then
-    echo "$0: test skipped because environment variable is set."
-    exit 77
-fi
-
 rm -f list-fs.output
 
 # Create 2 disks partitioned as:
diff --git a/tests/md/test-list-md-devices.sh b/tests/md/test-list-md-devices.sh
index 5a9cbe8..7cb2158 100755
--- a/tests/md/test-list-md-devices.sh
+++ b/tests/md/test-list-md-devices.sh
@@ -1,6 +1,6 @@
 #!/bin/bash -
 # libguestfs
-# Copyright (C) 2011 Red Hat Inc.
+# Copyright (C) 2011-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -20,11 +20,6 @@
 
 set -e
 
-if [ -n "$SKIP_TEST_LIST_MD_DEVICES_SH" ]; then
-    echo "$0: test skipped because environment variable is set."
-    exit 0
-fi
-
 output=$(
 guestfish <<EOF
 # Add 2 empty disks
diff --git a/tests/md/test-mdadm.sh b/tests/md/test-mdadm.sh
index 05b2432..071ee20 100755
--- a/tests/md/test-mdadm.sh
+++ b/tests/md/test-mdadm.sh
@@ -1,6 +1,6 @@
 #!/bin/bash -
 # libguestfs
-# Copyright (C) 2011 Red Hat Inc.
+# Copyright (C) 2011-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -20,11 +20,6 @@
 
 set -e
 
-if [ -n "$SKIP_TEST_MDADM_SH" ]; then
-    echo "$0: test skipped because environment variable is set."
-    exit 77
-fi
-
 rm -f mdadm-{1,2,3,4}.img
 
 guestfish <<EOF
diff --git a/tests/md/tests.mk b/tests/md/tests.mk
new file mode 100644
index 0000000..e6c395d
--- /dev/null
+++ b/tests/md/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)/tests/md
+
+localtests_SCRIPTS = \
+	test-inspect-fstab-md.sh \
+	test-inspect-fstab.sh \
+	test-list-filesystems.sh \
+	test-list-md-devices.sh \
+	test-mdadm.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/tests/mount-local/Makefile.am b/tests/mount-local/Makefile.am
index 89b92f2..172fff9 100644
--- a/tests/mount-local/Makefile.am
+++ b/tests/mount-local/Makefile.am
@@ -17,14 +17,14 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
+generator_built = tests.mk
+
+EXTRA_DIST =
+
+include $(srcdir)/tests.mk
+
 if HAVE_FUSE
 
-TESTS = test-parallel-mount-local
-
-TESTS_ENVIRONMENT = $(top_builddir)/run --test $(VG)
-
-check_PROGRAMS = $(TESTS)
-
 test_parallel_mount_local_SOURCES = \
 	test-parallel-mount-local.c \
 	$(top_srcdir)/df/estimate-max-threads.c \
@@ -46,7 +46,8 @@ test_parallel_mount_local_LDADD = \
 	$(LIBVIRT_LIBS) \
 	$(top_builddir)/gnulib/lib/libgnu.la
 
-check-valgrind:
-	$(MAKE) VG="$(top_builddir)/run @VG@" check
-
+else
+test-parallel-mount-local:
+	echo 'exit 77' > $@
+	chmod +x $@
 endif
diff --git a/tests/mount-local/test-parallel-mount-local.c b/tests/mount-local/test-parallel-mount-local.c
index 2032cbd..2f89dfe 100644
--- a/tests/mount-local/test-parallel-mount-local.c
+++ b/tests/mount-local/test-parallel-mount-local.c
@@ -63,6 +63,7 @@ static int guestunmount (const char *mp, unsigned flags);
 #define GUESTUNMOUNT_RMDIR  2
 
 static volatile sig_atomic_t quit = 0;
+static char *argv0 = NULL;
 
 static void
 catch_sigint (int signal)
@@ -79,9 +80,9 @@ int
 main (int argc, char *argv[])
 {
   size_t i;
-  char *skip;
   struct sigaction sa;
   int r, errors = 0;
+  const char *abs_builddir;
   void *status;
 
   srandom (time (NULL));
@@ -92,20 +93,28 @@ main (int argc, char *argv[])
     exit (EXIT_SUCCESS);
   }
 
-  /* Allow the test to be skipped by setting an environment variable. */
-  skip = getenv ("SKIP_TEST_PARALLEL_MOUNT_LOCAL");
-  if (skip && guestfs_int_is_true (skip) > 0) {
-    fprintf (stderr, "%s: test skipped because environment variable set.\n",
-             guestfs_int_program_name);
-    exit (77);
-  }
-
   if (access ("/dev/fuse", W_OK) == -1) {
     fprintf (stderr, "%s: test skipped because /dev/fuse is not writable.\n",
              guestfs_int_program_name);
     exit (77);
   }
 
+  /* We need an absolute path to the current binary.  The test harness
+   * passes $abs_builddir to us.
+   */
+  abs_builddir = getenv ("abs_builddir");
+  if (abs_builddir == NULL) {
+    fprintf (stderr,
+             "%s: $abs_builddir is not set.\n"
+             "Only run this program from the test harness.\n",
+             argv[0]);
+    exit (EXIT_FAILURE);
+  }
+  if (asprintf (&argv0, "%s/test-parallel-mount-local", abs_builddir) == -1) {
+    perror ("asprintf");
+    exit (EXIT_FAILURE);
+  }
+
   /* Choose the number of threads based on the amount of free memory. */
   nr_threads = MIN (MAX_THREADS, estimate_max_threads ());
 
@@ -157,6 +166,8 @@ main (int argc, char *argv[])
 
   cleanup_thread_state ();
 
+  free (argv0);
+
   exit (errors == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
 }
 
@@ -217,9 +228,8 @@ start_thread (void *statevp)
 
     if (pid == 0) { /* child */
       setpgid (0, 0);           /* so we don't get ^C from parent */
-      execlp ("./test-parallel-mount-local",
-              "test-parallel-mount-local", "--test", state->mp, NULL);
-      perror ("execlp");
+      execlp (argv0, "test-parallel-mount-local", "--test", state->mp, NULL);
+      perror (argv0);
       goto error;
     }
 
@@ -363,7 +373,7 @@ guestunmount (const char *mp, unsigned flags)
   }
 
   snprintf (cmd, sizeof cmd,
-            "../../fuse/guestunmount%s %s",
+            "guestunmount%s %s",
             (flags & GUESTUNMOUNT_SILENT) ? " --quiet" : "", mp);
 
   status = system (cmd);
diff --git a/tests/mount-local/tests.mk b/tests/mount-local/tests.mk
new file mode 100644
index 0000000..31f33ba
--- /dev/null
+++ b/tests/mount-local/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)/tests/mount-local
+
+localtests_PROGRAMS = \
+	test-parallel-mount-local
+
+# 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/tests/mountable/Makefile.am b/tests/mountable/Makefile.am
index 0e2cedd..c724b93 100644
--- a/tests/mountable/Makefile.am
+++ b/tests/mountable/Makefile.am
@@ -1,5 +1,5 @@
 # libguestfs
-# Copyright (C) 2012 Red Hat Inc.
+# Copyright (C) 2012-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -17,13 +17,11 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
-EXTRA_DIST = \
-	test-mountable-inspect.sh
+generator_built = tests.mk
 
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
+EXTRA_DIST = test-mountable-inspect.sh
 
-TESTS=test-internal-parse-mountable test-mountable-inspect.sh
-check_PROGRAMS = test-internal-parse-mountable
+include $(srcdir)/tests.mk
 
 test_internal_parse_mountable_SOURCES = test-internal-parse-mountable.c
 test_internal_parse_mountable_CPPFLAGS = \
diff --git a/tests/mountable/test-mountable-inspect.sh b/tests/mountable/test-mountable-inspect.sh
index 3b81fd0..7ba42a5 100755
--- a/tests/mountable/test-mountable-inspect.sh
+++ b/tests/mountable/test-mountable-inspect.sh
@@ -1,6 +1,6 @@
 #!/bin/bash -
 # libguestfs
-# Copyright (C) 2013 Red Hat Inc.
+# Copyright (C) 2013-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -22,11 +22,6 @@ export LANG=C
 canonical="sed s,/dev/vd,/dev/sd,g"
 
 # Allow the test to be skipped since btrfs is often broken.
-if [ -n "$SKIP_TEST_MOUNTABLE_INSPECT_SH" ]; then
-    echo "$0: skipping test because environment variable is set."
-    exit 77
-fi
-
 if [ "$(guestfish get-backend)" = "uml" ]; then
     echo "$0: skipping test because uml backend does not support qcow2"
     exit 77
@@ -44,7 +39,7 @@ rm -f root.tmp test.qcow2 test.output
 # and then inspect it.
 guestfish -- \
   disk-create test.qcow2 qcow2 -1 \
-    backingfile:../guests/fedora-btrfs.img backingformat:raw
+    backingfile:$phonydir/fedora-btrfs.img backingformat:raw
 
 # Test that basic inspection works and the expected filesystems are
 # found
diff --git a/tests/mountable/tests.mk b/tests/mountable/tests.mk
new file mode 100644
index 0000000..e9940ef
--- /dev/null
+++ b/tests/mountable/tests.mk
@@ -0,0 +1,63 @@
+# 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)/tests/mountable
+
+localtests_SCRIPTS = \
+	test-mountable-inspect.sh
+
+localtests_PROGRAMS = \
+	test-internal-parse-mountable
+
+# 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/tests/nbd/Makefile.am b/tests/nbd/Makefile.am
index 09d79c8..923f819 100644
--- a/tests/nbd/Makefile.am
+++ b/tests/nbd/Makefile.am
@@ -1,5 +1,5 @@
 # libguestfs
-# Copyright (C) 2013 Red Hat Inc.
+# Copyright (C) 2013-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -17,10 +17,8 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
-TESTS = \
-	test-nbd.pl
+generator_built = tests.mk
 
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
+EXTRA_DIST = test-nbd.pl
 
-EXTRA_DIST = \
-	$(TESTS)
+include $(srcdir)/tests.mk
diff --git a/tests/nbd/test-nbd.pl b/tests/nbd/test-nbd.pl
index 6353b25..03bd18f 100755
--- a/tests/nbd/test-nbd.pl
+++ b/tests/nbd/test-nbd.pl
@@ -1,5 +1,5 @@
 #!/usr/bin/perl
-# Copyright (C) 2013 Red Hat Inc.
+# Copyright (C) 2013-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -22,13 +22,11 @@ use POSIX qw(getcwd);
 
 use Sys::Guestfs;
 
-my $disk = "../guests/fedora.img";
+my $disk = "$ENV{phonydir}/fedora.img";
 
 my $pid = 0;
 END { kill 15, $pid if $pid > 0 };
 
-exit 77 if $ENV{SKIP_TEST_NBD_PL};
-
 if (Sys::Guestfs->new()->get_backend() eq "uml") {
     print "$0: test skipped because UML backend does not support NBD\n";
     exit 77
diff --git a/tests/nbd/tests.mk b/tests/nbd/tests.mk
new file mode 100644
index 0000000..33f87a9
--- /dev/null
+++ b/tests/nbd/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)/tests/nbd
+
+localtests_SCRIPTS = \
+	test-nbd.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/tests/network/Makefile.am b/tests/network/Makefile.am
index 2d47ca1..5fa75e2 100644
--- a/tests/network/Makefile.am
+++ b/tests/network/Makefile.am
@@ -1,5 +1,5 @@
 # libguestfs
-# Copyright (C) 2013 Red Hat Inc.
+# Copyright (C) 2013-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -17,10 +17,8 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
-TESTS = \
-	test-network.sh
+generator_built = tests.mk
 
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
+EXTRA_DIST = test-network.sh
 
-EXTRA_DIST = \
-	$(TESTS)
+include $(srcdir)/tests.mk
diff --git a/tests/network/test-network.sh b/tests/network/test-network.sh
index 51f3667..435840e 100755
--- a/tests/network/test-network.sh
+++ b/tests/network/test-network.sh
@@ -23,11 +23,6 @@
 set -e
 export LANG=C
 
-if [ -n "$SKIP_TEST_NETWORK_SH" ]; then
-    echo "$0: test skipped because environment variable is set."
-    exit 77
-fi
-
 backend="$(guestfish get-backend)"
 if [[ "$backend" =~ ^uml ]]; then
     echo "$0: test skipped because backend ($backend) is 'uml'."
diff --git a/tests/network/tests.mk b/tests/network/tests.mk
new file mode 100644
index 0000000..847a5b3
--- /dev/null
+++ b/tests/network/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)/tests/network
+
+localtests_SCRIPTS = \
+	test-network.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/tests/ntfsclone/Makefile.am b/tests/ntfsclone/Makefile.am
index 80795c5..e66af4c 100644
--- a/tests/ntfsclone/Makefile.am
+++ b/tests/ntfsclone/Makefile.am
@@ -1,5 +1,5 @@
 # libguestfs
-# Copyright (C) 2012 Red Hat Inc.
+# Copyright (C) 2012-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -17,10 +17,8 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
-TESTS = \
-	test-ntfsclone.sh
+generator_built = tests.mk
 
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
+EXTRA_DIST = test-ntfsclone.sh
 
-EXTRA_DIST = \
-	$(TESTS)
+include $(srcdir)/tests.mk
diff --git a/tests/ntfsclone/test-ntfsclone.sh b/tests/ntfsclone/test-ntfsclone.sh
index 30c21bf..f9271d4 100755
--- a/tests/ntfsclone/test-ntfsclone.sh
+++ b/tests/ntfsclone/test-ntfsclone.sh
@@ -1,6 +1,6 @@
 #!/bin/bash -
 # libguestfs
-# Copyright (C) 2012 Red Hat Inc.
+# Copyright (C) 2012-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -20,11 +20,6 @@
 
 set -e
 
-if [ -n "$SKIP_TEST_NTFSCLONE_SH" ]; then
-    echo "$0: test skipped because environment variable is set."
-    exit 77
-fi
-
 rm -f test-ntfsclone.img ntfsclone-backup1 ntfsclone-backup2
 
 # Skip if ntfs-3g is not supported by the appliance.
@@ -33,13 +28,13 @@ if ! guestfish add /dev/null : run : available "ntfs3g"; then
     exit 77
 fi
 
-if [ ! -s ../guests/windows.img ]; then
+if [ ! -s $phonydir/windows.img ]; then
     echo "$0: skipped because windows.img is zero-sized"
     exit 77
 fi
 
 # Export the filesystems to the backup file.
-guestfish --ro -a ../guests/windows.img <<EOF
+guestfish --ro -a $phonydir/windows.img <<EOF
 run
 ntfsclone-out /dev/sda1 ntfsclone-backup1 preservetimestamps:true force:true
 ntfsclone-out /dev/sda2 ntfsclone-backup2 metadataonly:true ignorefscheck:true
diff --git a/tests/ntfsclone/tests.mk b/tests/ntfsclone/tests.mk
new file mode 100644
index 0000000..ac3fd37
--- /dev/null
+++ b/tests/ntfsclone/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)/tests/ntfsclone
+
+localtests_SCRIPTS = \
+	test-ntfsclone.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/tests/parallel/Makefile.am b/tests/parallel/Makefile.am
index 9421bfc..fc26bc3 100644
--- a/tests/parallel/Makefile.am
+++ b/tests/parallel/Makefile.am
@@ -1,5 +1,5 @@
 # libguestfs
-# Copyright (C) 2012 Red Hat Inc.
+# Copyright (C) 2012-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -17,13 +17,11 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
-# Don't run this test by default.  However we have to have an empty
-# TESTS rule otherwise you can't run the test from the command line
-# using 'make TESTS=test-parallel check'
-TESTS =
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
+generator_built = tests.mk
 
-check_PROGRAMS = test-parallel
+EXTRA_DIST =
+
+include $(srcdir)/tests.mk
 
 test_parallel_SOURCES = test-parallel.c
 test_parallel_CPPFLAGS = \
@@ -37,9 +35,3 @@ test_parallel_LDADD = \
 	$(top_builddir)/src/libutils.la \
 	$(top_builddir)/src/libguestfs.la \
 	$(top_builddir)/gnulib/lib/libgnu.la
-
-#check-valgrind:
-#	$(MAKE) VG="$(top_builddir)/run @VG@" TESTS="test-parallel" check
-
-check-slow:
-	$(MAKE) TESTS="test-parallel" check
diff --git a/tests/parallel/test-parallel.c b/tests/parallel/test-parallel.c
index d018ec7..4cd9d73 100644
--- a/tests/parallel/test-parallel.c
+++ b/tests/parallel/test-parallel.c
@@ -1,5 +1,5 @@
 /* libguestfs
- * Copyright (C) 2012 Red Hat Inc.
+ * Copyright (C) 2012-2014 Red Hat Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -66,7 +66,6 @@ catch_sigint (int signal)
 int
 main (int argc, char *argv[])
 {
-  char *skip;
   struct sigaction sa;
   int r;
   size_t i, errors = 0;
@@ -74,14 +73,6 @@ main (int argc, char *argv[])
 
   srandom (time (NULL));
 
-  /* Allow the test to be skipped by setting an environment variable. */
-  skip = getenv ("SKIP_TEST_PARALLEL");
-  if (skip && guestfs_int_is_true (skip) > 0) {
-    fprintf (stderr, "%s: test skipped because environment variable set.\n",
-             guestfs_int_program_name);
-    exit (77);
-  }
-
   memset (&sa, 0, sizeof sa);
   sa.sa_handler = catch_sigint;
   sa.sa_flags = SA_RESTART;
diff --git a/tests/parallel/tests.mk b/tests/parallel/tests.mk
new file mode 100644
index 0000000..803a2c4
--- /dev/null
+++ b/tests/parallel/tests.mk
@@ -0,0 +1,30 @@
+# 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)/tests/parallel
+
+localtests_PROGRAMS = \
+	test-parallel
+
+check-slow:
+	$(top_builddir)/run $(top_builddir)/test-harness --slow
+
+EXTRA_DIST += tests.mk
diff --git a/tests/protocol/Makefile.am b/tests/protocol/Makefile.am
index 27e64c1..f6b847c 100644
--- a/tests/protocol/Makefile.am
+++ b/tests/protocol/Makefile.am
@@ -17,6 +17,8 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
+generator_built = tests.mk
+
 EXTRA_DIST = \
 	test-both-ends-cancel.sh \
 	test-cancellation-download-librarycancels.sh \
@@ -26,19 +28,7 @@ EXTRA_DIST = \
 	test-qemudie-midcommand.sh \
 	test-qemudie-synch.sh
 
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
-
-TESTS = \
-	test-both-ends-cancel.sh \
-	test-cancellation-download-librarycancels.sh \
-	test-cancellation-upload-daemoncancels.sh \
-	test-error-messages \
-	test-launch-race.pl \
-	test-qemudie-killsub.sh \
-	test-qemudie-midcommand.sh \
-	test-qemudie-synch.sh
-
-check_PROGRAMS = test-error-messages
+include $(srcdir)/tests.mk
 
 test_error_messages_SOURCES = \
 	test-error-messages.c
diff --git a/tests/protocol/tests.mk b/tests/protocol/tests.mk
new file mode 100644
index 0000000..c15a3d0
--- /dev/null
+++ b/tests/protocol/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)/tests/protocol
+
+localtests_SCRIPTS = \
+	test-both-ends-cancel.sh \
+	test-cancellation-download-librarycancels.sh \
+	test-cancellation-upload-daemoncancels.sh \
+	test-launch-race.pl \
+	test-qemudie-killsub.sh \
+	test-qemudie-midcommand.sh \
+	test-qemudie-synch.sh
+
+localtests_PROGRAMS = \
+	test-error-messages
+
+# 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/tests/qemu/Makefile.am b/tests/qemu/Makefile.am
index 478b3f1..707e303 100644
--- a/tests/qemu/Makefile.am
+++ b/tests/qemu/Makefile.am
@@ -1,5 +1,5 @@
 # libguestfs
-# Copyright (C) 2011 Red Hat Inc.
+# Copyright (C) 2011-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -21,23 +21,17 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
-TESTS = \
-	qemu-liveness.sh \
-	qemu-snapshot-isolation.sh \
-	qemu-force-tcg.sh
-
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
+generator_built = tests.mk
 
 EXTRA_DIST = \
-	$(TESTS) \
 	guestfs-md5.sh \
+	qemu-liveness.sh \
+	qemu-snapshot-isolation.sh \
+	qemu-force-tcg.sh \
 	qemu-boot.c \
 	qemu-speed-test.c
 
-# qemu-boot & qemu-speed-test are built but not run by default as they
-# are mainly qemu & kernel diagnostic tools.
-
-check_PROGRAMS = qemu-boot qemu-speed-test
+include $(srcdir)/tests.mk
 
 qemu_boot_SOURCES = \
 	../../df/estimate-max-threads.c \
diff --git a/tests/qemu/qemu-force-tcg.sh b/tests/qemu/qemu-force-tcg.sh
index 79b32b7..28ce470 100755
--- a/tests/qemu/qemu-force-tcg.sh
+++ b/tests/qemu/qemu-force-tcg.sh
@@ -18,11 +18,6 @@
 
 # Check force_tcg really forces TCG mode.
 
-if [ -n "$SKIP_QEMU_FORCE_TCG_SH" ]; then
-    echo "$0: test skipped because environment variable is set."
-    exit 77
-fi
-
 # Only applicable to the direct and libvirt backends:
 if [ "$(guestfish get-backend)" = "uml" ]; then
     echo "$0: skipping test because it is only applicable when qemu is being used."
diff --git a/tests/qemu/tests.mk b/tests/qemu/tests.mk
new file mode 100644
index 0000000..e58eea6
--- /dev/null
+++ b/tests/qemu/tests.mk
@@ -0,0 +1,66 @@
+# 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)/tests/qemu
+
+localtests_SCRIPTS = \
+	qemu-force-tcg.sh \
+	qemu-liveness.sh \
+	qemu-snapshot-isolation.sh
+
+localtests_PROGRAMS = \
+	qemu-boot \
+	qemu-speed-test
+
+# 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/tests/relative-paths/Makefile.am b/tests/relative-paths/Makefile.am
index beb60d9..90bf40f 100644
--- a/tests/relative-paths/Makefile.am
+++ b/tests/relative-paths/Makefile.am
@@ -25,13 +25,8 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
-TESTS = \
-	test-relative-paths.sh
+generator_built = tests.mk
 
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
+EXTRA_DIST = test-relative-paths.sh
 
-check-valgrind:
-	$(MAKE) VG="$(top_builddir)/run @VG@" check
-
-EXTRA_DIST = \
-	$(TESTS)
+include $(srcdir)/tests.mk
diff --git a/tests/relative-paths/test-relative-paths.sh b/tests/relative-paths/test-relative-paths.sh
index 4924cc3..37082c1 100755
--- a/tests/relative-paths/test-relative-paths.sh
+++ b/tests/relative-paths/test-relative-paths.sh
@@ -18,11 +18,6 @@
 
 set -e
 
-if [ -n "$SKIP_TEST_RELATIVE_PATHS_SH" ]; then
-    echo "$0: skipped (environment variable set)"
-    exit 77
-fi
-
 # UML doesn't support qcow2.  Conceivably there might be a similar
 # problem with UML COW images which would require a separate test.
 if [ "$(guestfish get-backend)" = "uml" ]; then
@@ -50,7 +45,8 @@ qemu-img create -f qcow2 backing3 10M
 qemu-img create -f qcow2 -b ./backing3 overlay3
 
 qemu-img create -f qcow2 backing4 10M
-qemu-img create -f qcow2 -b ../../tests/relative-paths/backing4 overlay4
+b="$(basename $(pwd))"
+qemu-img create -f qcow2 -b ../$b/backing4 overlay4
 
 qemu-img create -f qcow2 backing5 10M
 pushd dir1
diff --git a/tests/relative-paths/tests.mk b/tests/relative-paths/tests.mk
new file mode 100644
index 0000000..483d39e
--- /dev/null
+++ b/tests/relative-paths/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)/tests/relative-paths
+
+localtests_SCRIPTS = \
+	test-relative-paths.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/tests/rsync/Makefile.am b/tests/rsync/Makefile.am
index b548d91..31b5941 100644
--- a/tests/rsync/Makefile.am
+++ b/tests/rsync/Makefile.am
@@ -17,10 +17,8 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
-TESTS = \
-	test-rsync.sh
+generator_built = tests.mk
 
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
+EXTRA_DIST = test-rsync.sh
 
-EXTRA_DIST = \
-	$(TESTS)
+include $(srcdir)/tests.mk
diff --git a/tests/rsync/test-rsync.sh b/tests/rsync/test-rsync.sh
index 53fcab8..894987d 100755
--- a/tests/rsync/test-rsync.sh
+++ b/tests/rsync/test-rsync.sh
@@ -1,6 +1,6 @@
 #!/bin/bash -
 # libguestfs
-# Copyright (C) 2012 Red Hat Inc.
+# Copyright (C) 2012-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -22,11 +22,6 @@
 unset CDPATH
 set -e
 
-if [ -n "$SKIP_TEST_RSYNC_SH" ]; then
-    echo "$0: test skipped because environment variable is set."
-    exit 77
-fi
-
 # Check we have the rsync command.
 if ! rsync --help >/dev/null 2>&1; then
     echo "$0: skipping test because local rsync command is not available"
@@ -68,7 +63,6 @@ if ! guestfish -a /dev/null run : available rsync; then
 fi
 
 pwd="$(pwd)"
-datadir="$(cd ../../tests/data && pwd)"
 
 rm -rf tmp
 mkdir tmp
diff --git a/tests/rsync/tests.mk b/tests/rsync/tests.mk
new file mode 100644
index 0000000..90b806b
--- /dev/null
+++ b/tests/rsync/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)/tests/rsync
+
+localtests_SCRIPTS = \
+	test-rsync.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/tests/selinux/Makefile.am b/tests/selinux/Makefile.am
index 71943b2..9525d81 100644
--- a/tests/selinux/Makefile.am
+++ b/tests/selinux/Makefile.am
@@ -1,5 +1,5 @@
 # libguestfs
-# Copyright (C) 2012 Red Hat Inc.
+# Copyright (C) 2012-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -20,21 +20,13 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
-TESTS = \
-	test-xattrs-direct.sh \
-	test-selinux-direct.sh
-
-if HAVE_FUSE
-TESTS += \
-	test-xattrs-fuse.sh \
-	test-selinux-fuse.sh
-endif
-
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
+generator_built = tests.mk
 
 EXTRA_DIST = \
 	run-test.pl \
 	test-xattrs-direct.sh \
-	test-xattrs-fuse.sh \
 	test-selinux-direct.sh \
+	test-xattrs-fuse.sh \
 	test-selinux-fuse.sh
+
+include $(srcdir)/tests.mk
diff --git a/tests/selinux/run-test.pl b/tests/selinux/run-test.pl
index 89846ae..38cca6a 100755
--- a/tests/selinux/run-test.pl
+++ b/tests/selinux/run-test.pl
@@ -1,5 +1,5 @@
 #!/usr/bin/perl
-# Copyright (C) 2012 Red Hat Inc.
+# Copyright (C) 2012-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -49,12 +49,6 @@ die unless $test_type eq "xattrs" || $test_type eq "selinux";
 my $test_via = $ARGV[1];
 die unless $test_via eq "direct" || $test_via eq "fuse";
 
-my $env_name = "SKIP_TEST_SELINUX_" . uc ($test_type) . "_" . uc ($test_via);
-if ($ENV{$env_name}) {
-    print "$prog $test_type $test_via: test skipped because $env_name is set.\n";
-    exit 77
-}
-
 # SELinux labelling won't work (and can be skipped) if SELinux isn't
 # installed or isn't enabled on the host.
 if ($test_type eq "selinux") {
@@ -170,7 +164,7 @@ sub run_fuse_tests
     }
 
     # Unmount the test directory.
-    if (system ("../../fuse/guestunmount", $mpdir) != 0) {
+    if (system ("guestunmount", $mpdir) != 0) {
         die "failed to unmount FUSE directory\n";
     }
 
diff --git a/tests/selinux/tests.mk b/tests/selinux/tests.mk
new file mode 100644
index 0000000..7d6b9f5
--- /dev/null
+++ b/tests/selinux/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)/tests/selinux
+
+localtests_SCRIPTS = \
+	run-test.pl \
+	test-selinux-direct.sh \
+	test-selinux-fuse.sh \
+	test-xattrs-direct.sh \
+	test-xattrs-fuse.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/tests/syslinux/Makefile.am b/tests/syslinux/Makefile.am
index bb9a024..86567e3 100644
--- a/tests/syslinux/Makefile.am
+++ b/tests/syslinux/Makefile.am
@@ -1,5 +1,5 @@
 # libguestfs
-# Copyright (C) 2013 Red Hat Inc.
+# Copyright (C) 2013-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -17,14 +17,11 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
-TESTS = \
-	test-syslinux.sh \
-	test-extlinux.sh
-
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
+generator_built = tests.mk
 
 EXTRA_DIST = \
-	$(TESTS) \
+	test-syslinux.sh \
+	test-extlinux.sh \
 	test-syslinux.pl
 
-CLEANFILES = syslinux-guest.img extlinux-guest.img
+include $(srcdir)/tests.mk
diff --git a/tests/syslinux/test-syslinux.pl b/tests/syslinux/test-syslinux.pl
index cea0e54..67830c0 100755
--- a/tests/syslinux/test-syslinux.pl
+++ b/tests/syslinux/test-syslinux.pl
@@ -1,5 +1,5 @@
 #!/usr/bin/perl
-# Copyright (C) 2013 Red Hat Inc.
+# Copyright (C) 2013-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -22,8 +22,6 @@ use warnings;
 
 use Sys::Guestfs;
 
-exit 77 if $ENV{SKIP_TEST_SYSLINUX_PL};
-
 my $bootloader = $ENV{BOOTLOADER} || "syslinux";
 
 my $disk = "$bootloader-guest.img";
diff --git a/tests/syslinux/tests.mk b/tests/syslinux/tests.mk
new file mode 100644
index 0000000..bb69c97
--- /dev/null
+++ b/tests/syslinux/tests.mk
@@ -0,0 +1,62 @@
+# 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)/tests/syslinux
+
+localtests_SCRIPTS = \
+	test-extlinux.sh \
+	test-syslinux.pl \
+	test-syslinux.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/tests/tmpdirs/Makefile.am b/tests/tmpdirs/Makefile.am
index 32fd632..c433d00 100644
--- a/tests/tmpdirs/Makefile.am
+++ b/tests/tmpdirs/Makefile.am
@@ -1,5 +1,5 @@
 # libguestfs
-# Copyright (C) 2012 Red Hat Inc.
+# Copyright (C) 2012-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -17,10 +17,8 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
-TESTS = \
-	test-tmpdirs.pl
+generator_built = tests.mk
 
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
+EXTRA_DIST = test-tmpdirs.pl
 
-EXTRA_DIST = \
-	$(TESTS)
+include $(srcdir)/tests.mk
diff --git a/tests/tmpdirs/tests.mk b/tests/tmpdirs/tests.mk
new file mode 100644
index 0000000..4ede29b
--- /dev/null
+++ b/tests/tmpdirs/tests.mk
@@ -0,0 +1,63 @@
+# 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)/tests/tmpdirs
+
+localtests_SCRIPTS = \
+	test-tmpdirs.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
+
+check-fast:
+	$(top_builddir)/run $(top_builddir)/test-harness --fast
+
+EXTRA_DIST += tests.mk
diff --git a/tests/xfs/Makefile.am b/tests/xfs/Makefile.am
index fbe0e15..446837c 100644
--- a/tests/xfs/Makefile.am
+++ b/tests/xfs/Makefile.am
@@ -1,5 +1,5 @@
 # libguestfs
-# Copyright (C) 2013 Red Hat Inc.
+# Copyright (C) 2013-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -17,10 +17,8 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
-TESTS = \
-	test-xfs-misc.pl
+generator_built = tests.mk
 
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
+EXTRA_DIST = test-xfs-misc.pl
 
-EXTRA_DIST = \
-	$(TESTS)
+include $(srcdir)/tests.mk
diff --git a/tests/xfs/test-xfs-misc.pl b/tests/xfs/test-xfs-misc.pl
index 1d09474..07da0df 100755
--- a/tests/xfs/test-xfs-misc.pl
+++ b/tests/xfs/test-xfs-misc.pl
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 # libguestfs
-# Copyright (C) 2013 Red Hat Inc.
+# Copyright (C) 2013-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -23,8 +23,6 @@ use warnings;
 
 use Sys::Guestfs;
 
-exit 77 if $ENV{SKIP_TEST_XFS_MISC_PL};
-
 my $g = Sys::Guestfs->new ();
 
 $g->add_drive_scratch (1024*1024*1024);
diff --git a/tests/xfs/tests.mk b/tests/xfs/tests.mk
new file mode 100644
index 0000000..9b05c7b
--- /dev/null
+++ b/tests/xfs/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)/tests/xfs
+
+localtests_SCRIPTS = \
+	test-xfs-misc.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/tests/xml/Makefile.am b/tests/xml/Makefile.am
index aa57619..86fe077 100644
--- a/tests/xml/Makefile.am
+++ b/tests/xml/Makefile.am
@@ -1,5 +1,5 @@
 # libguestfs
-# Copyright (C) 2012 Red Hat Inc.
+# Copyright (C) 2012-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -17,30 +17,23 @@
 
 include $(top_srcdir)/subdir-rules.mk
 
-if HAVE_LIBVIRT
+generator_built = tests.mk
+
+EXTRA_DIST = \
+	rhbz701814.pl \
+	rhbz701814.sh \
+	rhbz701814-faked.xml \
+	rhbz701814-node.xml
+
+include $(srcdir)/tests.mk
 
 # This LD_PRELOAD library can be used to precisely control the XML
 # returned by libvirt.
-check_LTLIBRARIES = libfakevirtxml.la
+localtests_LTLIBRARIES = libfakevirtxml.la
 
 libfakevirtxml_la_SOURCES = fake-libvirt-xml.c
 libfakevirtxml_la_CFLAGS = $(LIBVIRT_CFLAGS)
 # -version-info and -rpath force libtool to build a shared library.
 libfakevirtxml_la_LDFLAGS = -version-info 0:0:0 -rpath /nowhere
 
-TESTS_ENVIRONMENT = \
-	abs_srcdir=$(abs_srcdir) \
-	LD_PRELOAD=.libs/libfakevirtxml.so \
-	$(top_builddir)/run --test
-
-TESTS = \
-	rhbz701814.pl
-
-endif
-
-EXTRA_DIST = \
-	rhbz701814.pl \
-	rhbz701814-faked.xml \
-	rhbz701814-node.xml
-
 CLEANFILES = *~
diff --git a/tests/xml/rhbz701814.pl b/tests/xml/rhbz701814.pl
index 01fa128..9e03029 100755
--- a/tests/xml/rhbz701814.pl
+++ b/tests/xml/rhbz701814.pl
@@ -1,5 +1,5 @@
 #!/usr/bin/perl -w
-# Copyright (C) 2012 Red Hat Inc.
+# Copyright (C) 2012-2014 Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -25,8 +25,8 @@ use Sys::Guestfs;
 my $srcdir = $ENV{srcdir};
 die "\$srcdir environment variable is not set" unless defined $srcdir;
 $ENV{FAKE_LIBVIRT_XML} = "$srcdir/rhbz701814-faked.xml";
+
 my $abs_srcdir = $ENV{abs_srcdir};
-
 my $uri = "test://$abs_srcdir/rhbz701814-node.xml";
 
 my $g = Sys::Guestfs->new ();
diff --git a/tests/xml/rhbz701814.sh b/tests/xml/rhbz701814.sh
new file mode 100755
index 0000000..cbedafa
--- /dev/null
+++ b/tests/xml/rhbz701814.sh
@@ -0,0 +1,22 @@
+#!/bin/sh -
+# Copyright (C) 2014 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+# Regression test for:
+# https://bugzilla.redhat.com/show_bug.cgi?id=701814
+
+LD_PRELOAD=.libs/libfakevirtxml.so \
+exec $srcdir/rhbz701814.pl
diff --git a/tests/xml/tests.mk b/tests/xml/tests.mk
new file mode 100644
index 0000000..3b01551
--- /dev/null
+++ b/tests/xml/tests.mk
@@ -0,0 +1,68 @@
+# 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)/tests/xml
+
+localtests_DATA = \
+	rhbz701814-faked.xml \
+	rhbz701814-node.xml
+
+localtests_SCRIPTS = \
+	rhbz701814.pl \
+	rhbz701814.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
-- 
2.4.3




More information about the Libguestfs mailing list