summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-11-12 17:54:31 +0000
committerRichard W.M. Jones <rjones@redhat.com>2012-11-13 15:26:29 +0000
commit3636c5fcff69e7a5a5afa126a597883db4c781bb (patch)
tree0d1406c121f1fb684b54f0d33b564246774bb826
parentc4a3ea066be9823d4572b57fd05940345904b826 (diff)
downloadlibguestfs-3636c5fcff69e7a5a5afa126a597883db4c781bb.tar.gz
libguestfs-3636c5fcff69e7a5a5afa126a597883db4c781bb.tar.xz
libguestfs-3636c5fcff69e7a5a5afa126a597883db4c781bb.zip
tests: Replace 'make extra-tests' with individual tests.
'make extra-tests' was a monolithic set of tests that did all sorts of things: valgrind, tests over local guests, tests with upstream qemu, tests with upstream libvirt, tests with the appliance attach method. This made it hard to perform individual tests, eg. just valgrind testing. It was also hard to maintain because the tests were not located in the same directories as the programs and sometimes duplicated tests that were run elsewhere. This commit splits up 'make extra-tests' into 5 separate targets: make check-valgrind # run a subset of tests under valgrind make check-valgrind-local-guests # test under valgrind with local guests make check-with-appliance # test with attach-method == appliance make check-with-upstream-qemu # test with an alternate/upstream qemu make check-with-upstream-libvirt # test with an alternate/upstream libvirt (You can also still run 'make extra-tests' which is now simply a rule that runs the above 5 targets in order). This replaces everything that was in the tests/extra directory, so that has now gone.
-rw-r--r--.gitignore4
-rw-r--r--Makefile.am63
-rw-r--r--README18
-rw-r--r--align/Makefile.am3
-rwxr-xr-xalign/test-virt-alignment-scan.sh2
-rw-r--r--cat/Makefile.am13
-rwxr-xr-xcat/test-virt-cat.sh4
-rwxr-xr-xcat/test-virt-filesystems.sh4
-rwxr-xr-xcat/test-virt-ls.sh8
-rw-r--r--configure.ac3
-rw-r--r--df/Makefile.am6
-rwxr-xr-xdf/test-virt-df.sh2
-rw-r--r--fish/Makefile.am3
-rwxr-xr-xfish/test-inspect.sh2
-rwxr-xr-xfish/test-prep.sh2
-rwxr-xr-xfish/test-run.sh2
-rw-r--r--format/Makefile.am3
-rwxr-xr-xformat/test-virt-format.sh6
-rw-r--r--inspector/Makefile.am8
-rwxr-xr-xinspector/test-virt-inspector.sh4
-rw-r--r--ocaml/Makefile.am4
-rwxr-xr-xpick-guests.pl.in (renamed from tests/extra/pick-guests.pl)13
-rw-r--r--resize/Makefile.am3
-rwxr-xr-xresize/test-virt-resize.sh2
-rw-r--r--sparsify/Makefile.am3
-rwxr-xr-xsparsify/test-virt-sparsify.sh2
-rw-r--r--src/guestfs.pod61
-rw-r--r--sysprep/Makefile.am8
-rwxr-xr-xsysprep/test-virt-sysprep.sh8
-rw-r--r--test-tool/Makefile.am3
-rw-r--r--tests/c-api/Makefile.am3
-rw-r--r--tests/extra/Makefile.am229
-rwxr-xr-xtests/extra/test-with-launch-appliance.sh27
-rwxr-xr-xtests/extra/test-with-upstream-libvirt.sh38
-rwxr-xr-xtests/extra/test-with-upstream-qemu.sh50
-rw-r--r--tests/mount-local/Makefile.am3
36 files changed, 225 insertions, 392 deletions
diff --git a/.gitignore b/.gitignore
index 83cbd52b..b61e44f6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -299,6 +299,7 @@ Makefile.in
/php/extension/php_guestfs_php.h
/php/extension/run-tests.php
/php/extension/tmp-php.ini
+/pick-guests.pl
/po-docs/*/*.1
/po-docs/*/*.3
/po-docs/*/*.8
@@ -316,6 +317,7 @@ Makefile.in
/python/guestfs.pyc
/python/guestfs.pyo
/python/__pycache__
+/qemu-wrapper.sh
/rescue/stamp-virt-rescue.pod
/rescue/virt-rescue
/rescue/virt-rescue.1
@@ -407,8 +409,6 @@ Makefile.in
/tests/data/initrd-x86_64.img.gz
/tests/data/test-grep.txt.gz
/tests/data/test.iso
-/tests/extra/qemu-wrapper.sh
-/tests/extra/valgrind.log
/tests/guests/debian.img
/tests/guests/fedora.img
/tests/guests/fedora-md1.img
diff --git a/Makefile.am b/Makefile.am
index e0932107..d484dc15 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -59,9 +59,6 @@ SUBDIRS += tests/hotplug
SUBDIRS += tests/regressions
endif
-# Extra tests don't run by default. You have to do 'make extra-tests'.
-SUBDIRS += tests/extra
-
# libguestfs-test-tool
SUBDIRS += test-tool
@@ -281,8 +278,9 @@ stamp-guestfs-release-notes.pod: guestfs-release-notes.pod
# Make clean.
CLEANFILES = \
- pod2htm?.tmp \
html/*.html \
+ pod2htm?.tmp \
+ qemu-wrapper.sh \
stamp-guestfs-release-notes.pod
# If you don't want to run all of the tests ('make check') then this
@@ -292,7 +290,60 @@ CLEANFILES = \
quickcheck:
$(top_builddir)/run test-tool/libguestfs-test-tool $(QUICKCHECK_TEST_TOOL_ARGS)
-# Run extra-tests in tests/extra/ subdirectory.
+# Non-standard tests.
extra-tests:
- make -C tests/extra $@
+ $(MAKE) -j1 \
+ valgrind \
+ valgrind-local-guests \
+ check-with-appliance \
+ check-with-upstream-qemu \
+ check-with-upstream-libvirt
+
+check-valgrind: build-test-guests
+ @for f in `grep -l '^$@:' $(SUBDIRS:%=%/Makefile.am)`; do \
+ echo $(MAKE) -C `dirname $$f` $@; \
+ $(MAKE) -C `dirname $$f` $@ || exit $$?; \
+ done
+
+check-valgrind-local-guests:
+ @GUESTS=`$(top_builddir)/run ./pick-guests.pl 5`; \
+ for f in `grep -l '^$@:' $(SUBDIRS:%=%/Makefile.am)`; do \
+ echo $(MAKE) GUESTS="$$GUESTS" -C `dirname $$f` $@; \
+ $(MAKE) GUESTS="$$GUESTS" -C `dirname $$f` $@ || exit $$?; \
+ done
+
+build-test-guests:
+ $(MAKE) -C tests/guests check
+
+check-with-appliance:
+ @method=`$(top_builddir)/run ./fish/guestfish get-attach-method`; \
+ if [ "$$method" != "appliance" ]; then \
+ $(MAKE) LIBGUESTFS_ATTACH_METHOD=appliance check || exit $$?; \
+ fi
+
+QEMUDIR = $(HOME)/d/qemu
+QEMUBINARY = $(QEMUDIR)/x86_64-softmmu/qemu-system-x86_64
+
+check-with-upstream-qemu:
+ @if $(QEMUBINARY) --help >/dev/null 2>&1; then \
+ $(MAKE) check-with-upstream-qemu-1 || exit $$?; \
+ fi
+
+check-with-upstream-qemu-1: $(top_builddir)/qemu-wrapper.sh
+ $(QEMUBINARY) --version
+ $(MAKE) LIBGUESTFS_QEMU=$(top_builddir)/qemu-wrapper.sh check
+
+$(top_builddir)/qemu-wrapper.sh: Makefile
+ rm -f $@ $@-t
+ echo exec "$(QEMUBINARY)" -L "$(QEMUDIR)/pc-bios" "$$@" > $@-t
+ chmod +x,-w $@-t
+ mv $@-t $@
+
+LIBVIRTDIR = $(HOME)/d/libvirt
+
+check-with-upstream-libvirt:
+ @method=`$(top_builddir)/run ./fish/guestfish get-attach-method`; \
+ if [ "$$method" = "libvirt" ] && [ -x "$(LIBVIRTDIR)/run" ]; then \
+ $(LIBVIRTDIR)/run $(MAKE) check || exit $$?; \
+ fi
diff --git a/README b/README
index 40fe8e46..1c0c6ef5 100644
--- a/README
+++ b/README
@@ -164,13 +164,19 @@ Finally run the tests:
make check
-There are some extra tests, but these require that you have some
-libvirt guests installed, that these guests' disks are accessible by
-the current user, and these tests may fail for other reasons which are
-not necessarily because of real problems. If you want to run these
-extra tests do:
+Also:
- make extra-tests
+ make check-valgrind
+
+runs a subset of the test suite under valgrind (requires valgrind to
+be installed obviously).
+
+ make extra-tests
+
+runs check-valgrind + even more tests, but these require that you have
+some libvirt guests installed, that these guests' disks are accessible
+by the current user, and these tests may fail for other reasons which
+are not necessarily because of real problems.
If everything works, you can install the library and tools by running
this command as root:
diff --git a/align/Makefile.am b/align/Makefile.am
index 4e3fdfe8..c44b8e3e 100644
--- a/align/Makefile.am
+++ b/align/Makefile.am
@@ -80,3 +80,6 @@ if ENABLE_APPLIANCE
TESTS += \
test-virt-alignment-scan.sh
endif
+
+check-valgrind:
+ $(MAKE) VG="$(top_builddir)/run @VG@" check
diff --git a/align/test-virt-alignment-scan.sh b/align/test-virt-alignment-scan.sh
index 058981eb..a7799027 100755
--- a/align/test-virt-alignment-scan.sh
+++ b/align/test-virt-alignment-scan.sh
@@ -16,7 +16,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-./virt-alignment-scan -a ../tests/guests/fedora.img
+$VG ./virt-alignment-scan -a ../tests/guests/fedora.img
r=$?
# 0, 2 and 3 are reasonable non-error exit codes. Others are errors.
diff --git a/cat/Makefile.am b/cat/Makefile.am
index 3549248c..daea4461 100644
--- a/cat/Makefile.am
+++ b/cat/Makefile.am
@@ -134,5 +134,16 @@ stamp-virt-filesystems.pod: virt-filesystems.pod
TESTS_ENVIRONMENT = $(top_builddir)/run --test
if ENABLE_APPLIANCE
-TESTS = test-virt-cat.sh test-virt-filesystems.sh test-virt-ls.sh
+TESTS = \
+ test-virt-cat.sh \
+ test-virt-filesystems.sh \
+ test-virt-ls.sh
endif ENABLE_APPLIANCE
+
+check-valgrind:
+ $(MAKE) VG="$(top_builddir)/run @VG@" check
+
+check-valgrind-local-guests:
+ for g in $(GUESTS); do \
+ $(top_builddir)/run --test @VG@ ./virt-filesystems -c "$(libvirt_ro_uri)" -d "$$g" --all --long -h --uuid || exit $$?; \
+ done
diff --git a/cat/test-virt-cat.sh b/cat/test-virt-cat.sh
index 5c051560..ee306bf7 100755
--- a/cat/test-virt-cat.sh
+++ b/cat/test-virt-cat.sh
@@ -20,11 +20,11 @@ export LANG=C
set -e
# Read out the test files from the image using virt-cat.
-if [ "$(./virt-cat ../tests/guests/fedora.img /etc/test1)" != "abcdefg" ]; then
+if [ "$($VG ./virt-cat ../tests/guests/fedora.img /etc/test1)" != "abcdefg" ]; then
echo "$0: error: mismatch in file test1"
exit 1
fi
-if [ "$(./virt-cat ../tests/guests/fedora.img /etc/test2)" != "" ]; then
+if [ "$($VG ./virt-cat ../tests/guests/fedora.img /etc/test2)" != "" ]; then
echo "$0: error: mismatch in file test2"
exit 1
fi
diff --git a/cat/test-virt-filesystems.sh b/cat/test-virt-filesystems.sh
index b413bacf..96a398e4 100755
--- a/cat/test-virt-filesystems.sh
+++ b/cat/test-virt-filesystems.sh
@@ -19,7 +19,7 @@
export LANG=C
set -e
-output="$(./virt-filesystems -a ../tests/guests/fedora.img | sort)"
+output="$($VG ./virt-filesystems -a ../tests/guests/fedora.img | sort)"
expected="/dev/VG/LV1
/dev/VG/LV2
/dev/VG/LV3
@@ -32,7 +32,7 @@ if [ "$output" != "$expected" ]; then
exit 1
fi
-output="$(./virt-filesystems -a ../tests/guests/fedora.img --all --long --uuid -h --no-title | awk '{print $1}' | sort -u)"
+output="$($VG ./virt-filesystems -a ../tests/guests/fedora.img --all --long --uuid -h --no-title | awk '{print $1}' | sort -u)"
expected="/dev/VG
/dev/VG/LV1
/dev/VG/LV2
diff --git a/cat/test-virt-ls.sh b/cat/test-virt-ls.sh
index 9cfe9db9..55fc1140 100755
--- a/cat/test-virt-ls.sh
+++ b/cat/test-virt-ls.sh
@@ -20,7 +20,7 @@ export LANG=C
set -e
# Read out the test directory using virt-ls.
-if [ "$(./virt-ls ../tests/guests/fedora.img /bin)" != "ls
+if [ "$($VG ./virt-ls ../tests/guests/fedora.img /bin)" != "ls
test1
test2
test3
@@ -33,7 +33,7 @@ test7" ]; then
fi
# Try the -lR option.
-output="$(./virt-ls -lR ../tests/guests/fedora.img /boot | awk '{print $1 $2 $4}')"
+output="$($VG ./virt-ls -lR ../tests/guests/fedora.img /boot | awk '{print $1 $2 $4}')"
expected="d0755/boot
d0755/boot/grub
-0644/boot/grub/grub.conf
@@ -47,3 +47,7 @@ if [ "$output" != "$expected" ]; then
echo "--------------------------------------------------"
exit 1
fi
+
+# Try the -l and -R options. XXX Should check the output.
+$VG ./virt-ls -l ../tests/guests/fedora.img /
+$VG ./virt-ls -R ../tests/guests/fedora.img /
diff --git a/configure.ac b/configure.ac
index 4d6083d0..c3740ba7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1338,6 +1338,8 @@ AC_CONFIG_FILES([appliance/libguestfs-make-fixed-appliance],
[chmod +x,-w appliance/libguestfs-make-fixed-appliance])
AC_CONFIG_FILES([inspector/test-xmllint.sh],
[chmod +x,-w inspector/test-xmllint.sh])
+AC_CONFIG_FILES([pick-guests.pl],
+ [chmod +x,-w pick-guests.pl])
AC_CONFIG_FILES([podwrapper.pl],
[chmod +x,-w podwrapper.pl])
AC_CONFIG_FILES([run],
@@ -1397,7 +1399,6 @@ AC_CONFIG_FILES([Makefile
tests/data/Makefile
tests/disks/Makefile
tests/disk-labels/Makefile
- tests/extra/Makefile
tests/guests/Makefile
tests/hotplug/Makefile
tests/luks/Makefile
diff --git a/df/Makefile.am b/df/Makefile.am
index b91efd38..52ec9b76 100644
--- a/df/Makefile.am
+++ b/df/Makefile.am
@@ -80,3 +80,9 @@ TESTS_ENVIRONMENT = $(top_builddir)/run --test
if ENABLE_APPLIANCE
TESTS = test-virt-df.sh
endif ENABLE_APPLIANCE
+
+check-valgrind:
+ $(MAKE) VG="$(top_builddir)/run @VG@" check
+
+check-valgrind-local-guests:
+ $(top_builddir)/run --test @VG@ ./virt-df -c "$(libvirt_ro_uri)"
diff --git a/df/test-virt-df.sh b/df/test-virt-df.sh
index dd5abf66..55f08321 100755
--- a/df/test-virt-df.sh
+++ b/df/test-virt-df.sh
@@ -20,7 +20,7 @@ export LANG=C
set -e
# Run virt-df.
-output=$(./virt-df ../tests/guests/fedora.img)
+output=$($VG ./virt-df ../tests/guests/fedora.img)
# Check title is the first line.
if [[ ! $output =~ ^Filesystem.* ]]; then
diff --git a/fish/Makefile.am b/fish/Makefile.am
index 100b1b38..08002967 100644
--- a/fish/Makefile.am
+++ b/fish/Makefile.am
@@ -270,6 +270,9 @@ TESTS += \
test-upload-to-dir.sh
endif
+check-valgrind:
+ $(MAKE) TESTS="test-inspect.sh test-prep.sh test-run.sh" VG="$(top_builddir)/run @VG@" check
+
EXTRA_DIST += \
test-a.sh \
test-add-domain.sh \
diff --git a/fish/test-inspect.sh b/fish/test-inspect.sh
index cea56221..8f8abe67 100755
--- a/fish/test-inspect.sh
+++ b/fish/test-inspect.sh
@@ -18,4 +18,4 @@
set -e
-./guestfish -a ../tests/guests/fedora.img -i exit
+$VG ./guestfish -a ../tests/guests/fedora.img -i exit
diff --git a/fish/test-prep.sh b/fish/test-prep.sh
index e75b9d41..0107c0da 100755
--- a/fish/test-prep.sh
+++ b/fish/test-prep.sh
@@ -22,7 +22,7 @@ rm -f test*.img
# It would be nice if we could keep this automatically in sync
# with the prepared disk types. XXX
-./guestfish \
+$VG ./guestfish \
-N disk -N part -N fs \
-N lv:/dev/VG1/LV \
-N lvfs:/dev/VG2/LV \
diff --git a/fish/test-run.sh b/fish/test-run.sh
index 98d5d91e..ec6e0d39 100755
--- a/fish/test-run.sh
+++ b/fish/test-run.sh
@@ -18,4 +18,4 @@
set -e
-./guestfish -a ../tests/guests/fedora.img run
+$VG ./guestfish -a ../tests/guests/fedora.img run
diff --git a/format/Makefile.am b/format/Makefile.am
index 63cba519..560598d1 100644
--- a/format/Makefile.am
+++ b/format/Makefile.am
@@ -74,4 +74,7 @@ if ENABLE_APPLIANCE
TESTS = test-virt-format.sh
endif ENABLE_APPLIANCE
+check-valgrind:
+ $(MAKE) VG="$(top_builddir)/run @VG@" check
+
EXTRA_DIST += test-virt-format.sh
diff --git a/format/test-virt-format.sh b/format/test-virt-format.sh
index a6f81e00..1fd5baac 100755
--- a/format/test-virt-format.sh
+++ b/format/test-virt-format.sh
@@ -27,11 +27,11 @@ fi
rm -f test1.img
-../fish/guestfish -N bootrootlv exit
+$VG ../fish/guestfish -N bootrootlv exit
-./virt-format --filesystem=ext3 -a test1.img
+$VG ./virt-format --filesystem=ext3 -a test1.img
-if [ "$(../cat/virt-filesystems -a test1.img)" != "/dev/sda1" ]; then
+if [ "$($VG ../cat/virt-filesystems -a test1.img)" != "/dev/sda1" ]; then
echo "$0: unexpected output after using virt-format"
exit 1
fi
diff --git a/inspector/Makefile.am b/inspector/Makefile.am
index a72d7f18..6004f12c 100644
--- a/inspector/Makefile.am
+++ b/inspector/Makefile.am
@@ -99,6 +99,14 @@ if HAVE_XMLLINT
TESTS += test-xmllint.sh
endif
+check-valgrind:
+ $(MAKE) TESTS="test-virt-inspector.sh" VG="$(top_builddir)/run @VG@" check
+
+check-valgrind-local-guests:
+ for g in $(GUESTS); do \
+ $(top_builddir)/run --test @VG@ ./virt-inspector -c "$(libvirt_ro_uri)" -d "$$g" || exit $$?; \
+ done
+
endif
# These rules require virt-inspector so there is no good time that we
diff --git a/inspector/test-virt-inspector.sh b/inspector/test-virt-inspector.sh
index 517ae1e4..fad5e583 100755
--- a/inspector/test-virt-inspector.sh
+++ b/inspector/test-virt-inspector.sh
@@ -20,11 +20,11 @@ export LANG=C
set -e
for f in ../tests/guests/{debian,fedora,ubuntu,windows}.img; do
- ./virt-inspector -a $f
+ $VG ./virt-inspector -a $f
done
# We could also test this image, but mdadm is problematic for
# many users.
-# ./virt-inspector \
+# $VG ./virt-inspector \
# -a ../tests/guests/fedora-md1.img \
# -a ../tests/guests/fedora-md2.img
diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am
index 82645743..a17f6166 100644
--- a/ocaml/Makefile.am
+++ b/ocaml/Makefile.am
@@ -183,6 +183,10 @@ t/guestfs_070_threads.cmo: t/guestfs_070_threads.ml mlguestfs.cma
t/guestfs_070_threads.cmx: t/guestfs_070_threads.ml mlguestfs.cmxa
$(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) -package unix,threads -thread -linkpkg -c $< -o $@
+check-valgrind:
+ $(MAKE) VG="$(top_builddir)/run @VG@" check
+
+# Dependencies.
%.cmi: %.mli
$(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -package unix -c $< -o $(builddir)/$@
%.cmo: %.ml mlguestfs.cma
diff --git a/tests/extra/pick-guests.pl b/pick-guests.pl.in
index d2e4a225..1ec2c2aa 100755
--- a/tests/extra/pick-guests.pl
+++ b/pick-guests.pl.in
@@ -1,5 +1,5 @@
#!/usr/bin/perl -w
-# libguestfs
+# @configure_input@
# Copyright (C) 2009-2012 Red Hat Inc.
#
# This program is free software; you can redistribute it and/or modify
@@ -17,7 +17,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# Pick guests at random on the local machine which are accessible.
-# Note that the Makefile sets $LIBVIRT_DEFAULT_URI.
+# This is used by 'make check-valgrind-local-guests'.
use strict;
@@ -28,7 +28,7 @@ use List::Util qw(shuffle);
die "$0 nr-guests\n" unless @ARGV == 1;
my $n = $ARGV[0];
-my $vmm = Sys::Virt->new;
+my $vmm = Sys::Virt->new (uri => '@libvirt_ro_uri@');
my @domains = ($vmm->list_domains, $vmm->list_defined_domains);
# Only guests which are accessible by the current (non-root) user. On
@@ -42,7 +42,8 @@ foreach my $dom (@domains) {
my $name = $dom->get_name;
my $g = Sys::Guestfs->new;
eval {
- $g->add_domain ($name, readonly => 1);
+ $g->add_domain ($name, readonly => 1,
+ libvirturi => '@libvirt_ro_uri@');
# $g->launch (); - don't actually need to do this
};
push @accessible, $name unless $@;
@@ -55,5 +56,7 @@ $n = @accessible if @accessible < $n;
# Return the first n guests from the list.
for (my $i = 0; $i < $n; ++$i) {
- print $accessible[$i], "\n";
+ print " " if $i > 0;
+ print $accessible[$i];
}
+print "\n";
diff --git a/resize/Makefile.am b/resize/Makefile.am
index 7d4cade5..8ba4c5b5 100644
--- a/resize/Makefile.am
+++ b/resize/Makefile.am
@@ -116,6 +116,9 @@ if ENABLE_APPLIANCE
TESTS += test-virt-resize.sh
endif
+check-valgrind:
+ $(MAKE) VG="$(top_builddir)/run @VG@" check
+
# Dependencies.
depend: .depend
diff --git a/resize/test-virt-resize.sh b/resize/test-virt-resize.sh
index 78b4821e..0831df4c 100755
--- a/resize/test-virt-resize.sh
+++ b/resize/test-virt-resize.sh
@@ -24,7 +24,7 @@ set -e
# This exercises a number of interesting codepaths including resizing
# LV content, handling GPT, and using qcow2 as a target.
-../fish/guestfish -N bootrootlv:/dev/VG/LV:ext2:ext4:400M:32M:gpt </dev/null
+$VG ../fish/guestfish -N bootrootlv:/dev/VG/LV:ext2:ext4:400M:32M:gpt </dev/null
qemu-img create -f qcow2 test2.img 500M
$VG ./virt-resize -d --debug-gc \
diff --git a/sparsify/Makefile.am b/sparsify/Makefile.am
index 01174cf3..3d428870 100644
--- a/sparsify/Makefile.am
+++ b/sparsify/Makefile.am
@@ -105,6 +105,9 @@ if ENABLE_APPLIANCE
TESTS = test-virt-sparsify.sh
endif ENABLE_APPLIANCE
+check-valgrind:
+ $(MAKE) VG="$(top_builddir)/run @VG@" check
+
# Dependencies.
depend: .depend
diff --git a/sparsify/test-virt-sparsify.sh b/sparsify/test-virt-sparsify.sh
index f85ac082..3f03377e 100755
--- a/sparsify/test-virt-sparsify.sh
+++ b/sparsify/test-virt-sparsify.sh
@@ -24,7 +24,7 @@ rm -f test1.img test2.img
# Create a filesystem, fill it with data, then delete the data. Then
# prove that sparsifying it reduces the size of the final filesystem.
-../fish/guestfish \
+$VG ../fish/guestfish \
-N bootrootlv:/dev/VG/LV:ext2:ext4:400M:32M:gpt <<EOF
mount /dev/VG/LV /
mkdir /boot
diff --git a/src/guestfs.pod b/src/guestfs.pod
index e0246619..f4223d2a 100644
--- a/src/guestfs.pod
+++ b/src/guestfs.pod
@@ -3462,7 +3462,7 @@ Debugging the daemon is a problem because it runs inside a minimal
environment. However you can fprintf messages in the daemon to
stderr, and they will show up if you use C<guestfish -v>.
-=head2 FORMATTING CODE AND OTHER CONVENTIONS
+=head2 FORMATTING CODE
Our C source code generally adheres to some basic code-formatting
conventions. The existing code base is not totally consistent on this
@@ -3495,6 +3495,8 @@ If you use Emacs, add the following to one of one of your start-up files
(buffer-file-name))
(libguestfs-c-mode))))
+=head2 TESTING YOUR CHANGES
+
Enable warnings when compiling (and fix any problems this
finds):
@@ -3502,13 +3504,56 @@ finds):
Useful targets are:
- make syntax-check -j1 -k # checks for various syntax and
- # style problems
-
- make check # runs the test suite
-
- make extra-tests # in-depth testing using valgrind
- # and real guests
+=over 4
+
+=item C<make check>
+
+Runs the regular test suite.
+
+=item C<make syntax-check -j1 -k>
+
+Checks for various syntax and style problems in the code.
+
+=item C<make check-valgrind>
+
+Runs a subset of the test suite under valgrind.
+
+=item C<make check-valgrind-local-guests>
+
+Runs a subset of the test suite under valgrind
+using locally installed libvirt guests (read-only).
+
+=item C<make check-with-appliance>
+
+Runs all tests using default appliance back-end. This only
+has any effect if a non-default attach-method was selected
+using C<./configure --with-default-attach-method=...>
+
+=item C<make check-with-upstream-qemu>
+
+Runs all tests using a local qemu binary. It looks for the qemu
+binary in QEMUDIR (defaults to C<$HOME/d/qemu>), but you can set this
+to another directory on the command line, eg:
+
+ make check-with-upstream-qemu QEMUDIR=/usr/src/qemu
+
+=item C<make check-with-upstream-libvirt>
+
+Runs all tests using a local libvirt. This only has any effect if the
+libvirt attach-method was selected using
+C<./configure --with-default-attach-method=libvirt>
+
+It looks for libvirt in LIBVIRTDIR (defaults to C<$HOME/d/libvirt>),
+but you can set this to another directory on the command line, eg:
+
+ make check-with-upstream-libvirt LIBVIRTDIR=/usr/src/libvirt
+
+=item C<make extra-tests>
+
+Equivalent to running all C<make check-*> rules
+(but not C<make check>).
+
+=back
=head2 DAEMON CUSTOM PRINTF FORMATTERS
diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am
index 0e240117..a7479291 100644
--- a/sysprep/Makefile.am
+++ b/sysprep/Makefile.am
@@ -159,6 +159,14 @@ TESTS = \
test-virt-sysprep-script.sh
endif ENABLE_APPLIANCE
+check-valgrind:
+ $(MAKE) TESTS="test-virt-sysprep.sh" VG="$(top_builddir)/run @VG@" check
+
+check-valgrind-local-guests:
+ for g in $(GUESTS); do \
+ $(top_builddir)/run --test @VG@ ./virt-sysprep -n -c "$(libvirt_ro_uri)" -d "$$g" || exit $$?; \
+ done
+
# Dependencies.
depend: .depend
diff --git a/sysprep/test-virt-sysprep.sh b/sysprep/test-virt-sysprep.sh
index 2443ce23..8a375f6f 100755
--- a/sysprep/test-virt-sysprep.sh
+++ b/sysprep/test-virt-sysprep.sh
@@ -23,5 +23,11 @@ set -e
# to be able to sysprep any of our test guests.
for f in ../tests/guests/{debian,fedora,ubuntu,windows}.img; do
- ./virt-sysprep -q -n -a $f
+ $VG ./virt-sysprep -q -n -a $f
done
+
+# We could also test this image, but mdadm is problematic for
+# many users.
+# $VG ./virt-sysprep -q -n \
+# -a ../tests/guests/fedora-md1.img \
+# -a ../tests/guests/fedora-md2.img
diff --git a/test-tool/Makefile.am b/test-tool/Makefile.am
index 5e2757eb..50dc8b14 100644
--- a/test-tool/Makefile.am
+++ b/test-tool/Makefile.am
@@ -42,3 +42,6 @@ stamp-libguestfs-test-tool.pod: libguestfs-test-tool.pod
--license GPLv2+ \
$<
touch $@
+
+check-valgrind:
+ $(top_builddir)/run --test @VG@ ./libguestfs-test-tool
diff --git a/tests/c-api/Makefile.am b/tests/c-api/Makefile.am
index 7adedeb7..5f684f76 100644
--- a/tests/c-api/Makefile.am
+++ b/tests/c-api/Makefile.am
@@ -169,3 +169,6 @@ test_environment_LDADD = \
# $(top_builddir)/src/libguestfs.la $(LIBVIRT_LIBS) \
# $(LTLIBTHREAD) $(top_builddir)/gnulib/lib/libgnu.la
#endif
+
+check-valgrind:
+ $(MAKE) VG="$(top_builddir)/run @VG@" check
diff --git a/tests/extra/Makefile.am b/tests/extra/Makefile.am
deleted file mode 100644
index 41cc54c1..00000000
--- a/tests/extra/Makefile.am
+++ /dev/null
@@ -1,229 +0,0 @@
-# libguestfs
-# Copyright (C) 2009-2012 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.
-
-# Extra tests.
-#
-# Requires:
-# - some local libvirt guests are available
-# - the disks of these guests are accessible by the current user
-# (tip: add yourself to the 'disk' group)
-# - valgrind
-# - libtool
-# Optional:
-# - upstream qemu in $QEMUDIR
-# - upstream libvirt in $LIBVIRTDIR
-#
-# These tests may fail for reasons which aren't necessarily real problems.
-#
-# XXX Not tested:
-#
-# ../edit/virt-edit
-#
-# Perl bindings
-# ../edit/virt-edit -e
-# ../tools/virt-win-reg (Perl)
-# ../tools/virt-make-fs (Perl)
-# - hard because Perl doesn't cooperate by freeing memory
-#
-# Python bindings
-# - as for Perl
-#
-# Ruby bindings
-# - these look feasible to test using valgrind
-#
-# Java bindings
-#
-# ../fuse/guestmount
-# - hard to test because guestmount forks into the background, and
-# if valgrind reports errors it doesn't stop the test shell script
-
-# Old RHEL 5 autoconf doesn't have abs_srcdir.
-abs_srcdir ?= $(shell cd $(top_srcdir)/tests/extra && pwd)
-
-# Old RHEL 5 autoconf doesn't have abs_builddir.
-abs_builddir ?= $(shell pwd)
-
-EXTRA_DIST = \
- pick-guests.pl \
- test-with-launch-appliance.sh \
- test-with-upstream-libvirt.sh \
- test-with-upstream-qemu.sh
-
-VG = @VG@
-RUN_VG = $(abs_top_builddir)/run $(VG)
-
-# Choose guests at random on each run.
-random_guests := \
- $(shell \
- LIBVIRT_DEFAULT_URI="$(libvirt_ro_uri)" \
- $(abs_top_builddir)/run $(srcdir)/pick-guests.pl 5)
-
-extra-tests-non-recursive: \
- test-guests \
- test-prerequisites \
- test-c-api \
- test-tools-null \
- test-tools-internal \
- test-df-real \
- test-filesystems-real \
- test-inspector-real \
- test-sysprep-real \
- test-ocaml \
- test-resize \
- test-sparsify \
- test-mount-local
-
-extra-tests: \
- extra-tests-non-recursive \
- extra-tests-with-upstream-qemu \
- extra-tests-with-upstream-libvirt \
- extra-tests-with-launch-appliance
-
-test-guests:
- $(MAKE) -C ../guests check
-
-test-prerequisites:
- @libtool --help >/dev/null 2>&1 || { \
- echo "extra-tests: libtool is not installed"; \
- exit 1; \
- }
- @valgrind --help >/dev/null 2>&1 || { \
- echo "extra-tests: valgrind is not installed"; \
- exit 1; \
- }
-
-# Null invocations of the basic tools shouldn't leak memory.
-test-tools-null:
- $(RUN_VG) ../../fish/guestfish -N part exit
- $(RUN_VG) ../../align/virt-alignment-scan -a test1.img >/dev/null
- $(RUN_VG) ../../format/virt-format -a test1.img >/dev/null
- rm test1.img
- $(RUN_VG) ../../cat/virt-filesystems -a /dev/null >/dev/null
- $(RUN_VG) ../../cat/virt-filesystems -a /dev/null --all --long -h --uuid >/dev/null
- $(RUN_VG) ../../df/virt-df -a /dev/null >/dev/null
- $(RUN_VG) ../../fish/guestfish -a /dev/null run
- $(RUN_VG) ../../inspector/virt-inspector -a /dev/null >/dev/null
- $(RUN_VG) ../../test-tool/libguestfs-test-tool >/dev/null 2>&1
-
-# Invocations of tools on internal images shouldn't leak memory.
-test-tools-internal:
- $(RUN_VG) ../../cat/virt-cat -a ../guests/fedora.img /etc/fstab >/dev/null
- $(RUN_VG) ../../cat/virt-filesystems -a ../guests/fedora.img >/dev/null
- $(RUN_VG) ../../cat/virt-filesystems -a ../guests/fedora.img --all --long -h --uuid >/dev/null
- $(RUN_VG) ../../cat/virt-ls -a ../guests/fedora.img / >/dev/null
- $(RUN_VG) ../../cat/virt-ls -a ../guests/fedora.img -l / >/dev/null
- $(RUN_VG) ../../cat/virt-ls -a ../guests/fedora.img -R / >/dev/null
- $(RUN_VG) ../../cat/virt-ls -a ../guests/fedora.img -lR / >/dev/null
- $(RUN_VG) ../../df/virt-df -a ../guests/fedora.img >/dev/null
- $(RUN_VG) ../../df/virt-df -a ../guests/fedora.img -h >/dev/null
- $(RUN_VG) ../../fish/guestfish -a ../guests/fedora.img run
- $(RUN_VG) ../../fish/guestfish -a ../guests/fedora.img -i exit
- $(RUN_VG) ../../inspector/virt-inspector -a ../guests/debian.img >/dev/null
- $(RUN_VG) ../../inspector/virt-inspector -a ../guests/fedora.img >/dev/null
- $(RUN_VG) ../../inspector/virt-inspector -a ../guests/fedora-md1.img -a ../guests/fedora-md2.img >/dev/null
- $(RUN_VG) ../../inspector/virt-inspector -a ../guests/ubuntu.img >/dev/null
- $(RUN_VG) ../../inspector/virt-inspector -a ../guests/windows.img >/dev/null
- $(RUN_VG) ../../sysprep/virt-sysprep -n -a ../guests/debian.img
- $(RUN_VG) ../../sysprep/virt-sysprep -n -a ../guests/fedora.img
- $(RUN_VG) ../../sysprep/virt-sysprep -n -a ../guests/fedora-md1.img -a ../guests/fedora-md2.img
- $(RUN_VG) ../../sysprep/virt-sysprep -n -a ../guests/ubuntu.img
- $(RUN_VG) ../../sysprep/virt-sysprep -n -a ../guests/windows.img
-
-# Invocations of tools on real images shouldn't leak memory.
-test-df-real:
- $(RUN_VG) ../../df/virt-df -c "$(libvirt_ro_uri)" >/dev/null
- $(RUN_VG) ../../df/virt-df -c "$(libvirt_ro_uri)" -h >/dev/null
-
-test-filesystems-real:
- @for g in $(random_guests); do \
- echo $(RUN_VG) ../../cat/virt-filesystems -c "$(libvirt_ro_uri)" -d $$g --all --long -h --uuid; \
- $(RUN_VG) ../../cat/virt-filesystems -c "$(libvirt_ro_uri)" -d $$g --all --long -h --uuid > /dev/null; \
- r=$$?; \
- if [ $$r -ne 0 ]; then exit $$r; fi; \
- done
-
-test-inspector-real:
- @for g in $(random_guests); do \
- echo $(RUN_VG) ../../inspector/virt-inspector -c "$(libvirt_ro_uri)" -d $$g; \
- $(RUN_VG) ../../inspector/virt-inspector -c "$(libvirt_ro_uri)" -d $$g > /dev/null; \
- r=$$?; \
- if [ $$r -ne 0 ]; then exit $$r; fi; \
- done
-
-test-sysprep-real:
- @for g in $(random_guests); do \
- echo $(RUN_VG) ../../sysprep/virt-sysprep -n -c "$(libvirt_ro_uri)" -d $$g; \
- $(RUN_VG) ../../sysprep/virt-sysprep -n -c "$(libvirt_ro_uri)" -d $$g > /dev/null; \
- r=$$?; \
- if [ $$r -ne 0 ]; then exit $$r; fi; \
- done
-
-# Run virt-resize tests under valgrind.
-test-resize:
- $(MAKE) -C ../../resize VG="$(VG)" check
-
-# Run virt-sparsify tests under valgrind.
-test-sparsify:
- $(MAKE) -C ../../sparsify VG="$(VG)" check
-
-# Run c-api tests under valgrind.
-test-c-api:
- $(MAKE) -C ../c-api VG="$(RUN_VG)" check
-
-# Run parallel mount-local test under valgrind.
-test-mount-local:
- $(MAKE) -C ../mount-local VG="$(VG)" check
-
-# Test OCaml bindings under valgrind.
-test-ocaml:
- $(MAKE) -C ../../ocaml VG="$(VG)" check
-
-# When running the extra tests, if directory $QEMUDIR exists then we
-# will rerun all the extra-tests using the version of qemu from that
-# directory. eg. That might be qemu from git.
-#
-# The directory name can be overridden using:
-# make extra-tests QEMUDIR=/path/to/other/qemu
-
-QEMUDIR = $(HOME)/d/qemu
-export QEMUDIR
-export abs_srcdir
-export MAKE
-
-extra-tests-with-upstream-qemu:
- ./test-with-upstream-qemu.sh
-
-# When running the extra tests and ./configure
-# --with-default-attach-method=libvirt, if directory $LIBVIRTDIR
-# exists, we will rerun all the extra-tests using the version of
-# libvirt in that directory. eg. That might be upstream libvirt from
-# git.
-#
-# The directory name can be overridden using:
-# make extra-tests LIBVIRTDIR=/path/to/other/libvirt
-
-LIBVIRTDIR = $(HOME)/d/libvirt
-export LIBVIRTDIR
-
-extra-tests-with-upstream-libvirt:
- ./test-with-upstream-libvirt.sh
-
-# If libvirt is being used as the backend, rerun all the extra-tests
-# again using the regular appliance backend.
-
-extra-tests-with-launch-appliance:
- ./test-with-launch-appliance.sh
diff --git a/tests/extra/test-with-launch-appliance.sh b/tests/extra/test-with-launch-appliance.sh
deleted file mode 100755
index 0a4f51b7..00000000
--- a/tests/extra/test-with-launch-appliance.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/sh -
-# Copyright (C) 2012 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.
-
-set -e
-#set -x
-
-method="$(../../fish/guestfish get-attach-method)"
-if [ "$method" = "appliance" ]; then
- echo "$0: test skipped because attach-method is already 'appliance'"
- exit 77
-fi
-
-exec $MAKE extra-tests-non-recursive LIBGUESTFS_ATTACH_METHOD=appliance
diff --git a/tests/extra/test-with-upstream-libvirt.sh b/tests/extra/test-with-upstream-libvirt.sh
deleted file mode 100755
index 31b50e8f..00000000
--- a/tests/extra/test-with-upstream-libvirt.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/sh -
-# Copyright (C) 2012 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.
-
-set -e
-#set -x
-
-method="$(../../fish/guestfish get-attach-method)"
-if [ "$method" != "libvirt" ]; then
- echo "$0: test skipped because attach-method is not 'libvirt'"
- exit 77
-fi
-
-if [ ! -d "$LIBVIRTDIR" ]; then
- echo "$0: \$LIBVIRTDIR not a directory, tests against upstream libvirt skipped"
- exit 77
-fi
-
-libvirt_run="$LIBVIRTDIR/run"
-if [ ! -x "$libvirt_run" ]; then
- echo "$0: $libvirt_run not executable, tests against upstream libvirt skipped"
- exit 77
-fi
-
-exec "$libvirt_run" $MAKE extra-tests-non-recursive
diff --git a/tests/extra/test-with-upstream-qemu.sh b/tests/extra/test-with-upstream-qemu.sh
deleted file mode 100755
index 7c883288..00000000
--- a/tests/extra/test-with-upstream-qemu.sh
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/bin/sh -
-# Copyright (C) 2012 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.
-
-set -e
-#set -x
-
-if [ ! -d "$QEMUDIR" ]; then
- echo "$0: \$QEMUDIR not a directory, tests against upstream qemu skipped"
- exit 77
-fi
-
-upstream_qemu="$QEMUDIR/x86_64-softmmu/qemu-system-x86_64"
-if ! "$upstream_qemu" --help >/dev/null 2>&1; then
- echo "$0: $upstream_qemu not executable, tests against upstream qemu skipped"
- exit 77
-fi
-
-"$upstream_qemu" --version
-
-# Write a custom wrapper script for this invocation. (Since multiple
-# parallel 'make extra-tests' should not be running in the same
-# libguestfs directory, this should be safe).
-LIBGUESTFS_QEMU="$abs_srcdir/qemu-wrapper.sh"
-rm -f "$LIBGUESTFS_QEMU" "$LIBGUESTFS_QEMU"-t
-cat > "$LIBGUESTFS_QEMU"-t <<EOF
-#!/bin/sh -
-# Wrapper generated by '$0'.
-# Do not edit this file directly.
-exec "$upstream_qemu" -L "$QEMUDIR/pc-bios" "\$@"
-EOF
-chmod +x "$LIBGUESTFS_QEMU"-t
-mv "$LIBGUESTFS_QEMU"-t "$LIBGUESTFS_QEMU"
-
-export LIBGUESTFS_QEMU
-
-exec $MAKE extra-tests-non-recursive
diff --git a/tests/mount-local/Makefile.am b/tests/mount-local/Makefile.am
index ec892213..aa910140 100644
--- a/tests/mount-local/Makefile.am
+++ b/tests/mount-local/Makefile.am
@@ -38,4 +38,7 @@ test_parallel_mount_local_LDADD = \
$(top_builddir)/src/libguestfs.la \
$(top_builddir)/gnulib/lib/libgnu.la
+check-valgrind:
+ $(MAKE) VG="$(top_builddir)/run @VG@" check
+
endif