Add 'make extra-tests' rule and run extra tests.
authorRichard W.M. Jones <rjones@redhat.com>
Thu, 24 Nov 2011 14:08:09 +0000 (14:08 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Thu, 24 Nov 2011 15:51:16 +0000 (15:51 +0000)
These tests are optional, and require a special environment and
tools to run.

.gitignore
Makefile.am
README
configure.ac
extratests/Makefile.am [new file with mode: 0644]
src/guestfs.pod

index b3b5a2e..ab5b841 100644 (file)
@@ -94,6 +94,8 @@ examples/stamp-guestfs-examples.pod
 examples/stamp-guestfs-recipes.pod
 examples/stamp-guestfs-testing.pod
 examples/virt-dhcp-address
+extratests/suppressions
+extratests/valgrind.log
 fish/cmds.c
 fish/cmds_gperf.c
 fish/cmds_gperf.gperf
index 8394ac4..5c90004 100644 (file)
@@ -30,7 +30,7 @@ SUBDIRS += appliance
 endif
 
 # Tests and the test-tool.
-SUBDIRS += gnulib/tests capitests caution regressions test-tool
+SUBDIRS += gnulib/tests capitests caution regressions extratests test-tool
 
 # Guestfish.
 SUBDIRS += fish
@@ -250,6 +250,11 @@ CLEANFILES = \
 quickcheck:
        ./run test-tool/libguestfs-test-tool $(QUICKCHECK_TEST_TOOL_ARGS)
 
+# Run extra-tests in extratests/ subdirectory.
+
+extra-tests:
+       make -C extratests $@
+
 # Make binary distribution.
 
 BINTMPDIR = /tmp/libguestfs-bin
diff --git a/README b/README
index 2af85cf..bf978ca 100644 (file)
--- a/README
+++ b/README
@@ -147,6 +147,14 @@ 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:
+
+  make extra-tests
+
 If everything works, you can install the library and tools by running
 this command as root:
 
index 472bd98..c298eb8 100644 (file)
@@ -1019,6 +1019,7 @@ AC_CONFIG_FILES([Makefile
                  erlang/Makefile
                  erlang/examples/Makefile
                  examples/Makefile
+                 extratests/Makefile
                  fish/Makefile
                  fuse/Makefile
                  generator/Makefile
diff --git a/extratests/Makefile.am b/extratests/Makefile.am
new file mode 100644 (file)
index 0000000..c91591a
--- /dev/null
@@ -0,0 +1,102 @@
+# libguestfs
+# Copyright (C) 2009-2011 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
+#
+# These tests may fail for reasons which aren't necessarily real problems.
+
+VG = ../run \
+       valgrind \
+       --log-file=valgrind.log \
+       --leak-check=full \
+       --error-exitcode=119 \
+       --suppressions=suppressions
+
+export LIBVIRT_DEFAULT_URI = \
+       qemu+unix:///system?socket=/var/run/libvirt/libvirt-sock-ro
+
+GUESTS = $(shell virsh -c $(LIBVIRT_DEFAULT_URI) list --all | \
+                head -n -1 | \
+                tail -n +3 | \
+                awk '{print $$2}')
+
+extra-tests: test-tools-null test-tools-internal test-tools-real
+
+# Null invocations of the basic tools shouldn't leak memory.
+test-tools-null:
+       $(VG) ../fish/guestfish -N part exit
+       $(VG) ../align/virt-alignment-scan -a test1.img >/dev/null
+       rm test1.img
+       $(VG) ../cat/virt-filesystems -a /dev/null >/dev/null
+       $(VG) ../cat/virt-filesystems -a /dev/null --all --long -h --uuid >/dev/null
+       $(VG) ../df/virt-df -a /dev/null >/dev/null
+       $(VG) ../fish/guestfish -a /dev/null run
+       $(VG) ../inspector/virt-inspector -a /dev/null >/dev/null
+       $(VG) ../test-tool/libguestfs-test-tool >/dev/null 2>&1
+
+# Invocations of tools on internal images shouldn't leak memory.
+test-tools-internal:
+       $(VG) ../cat/virt-cat -a ../images/fedora.img /etc/fstab >/dev/null
+       $(VG) ../cat/virt-filesystems -a ../images/fedora.img >/dev/null
+       $(VG) ../cat/virt-filesystems -a ../images/fedora.img --all --long -h --uuid >/dev/null
+       $(VG) ../cat/virt-ls -a ../images/fedora.img / >/dev/null
+       $(VG) ../cat/virt-ls -a ../images/fedora.img -l / >/dev/null
+       $(VG) ../cat/virt-ls -a ../images/fedora.img -R / >/dev/null
+       $(VG) ../cat/virt-ls -a ../images/fedora.img -lR / >/dev/null
+       $(VG) ../df/virt-df -a ../images/fedora.img >/dev/null
+       $(VG) ../df/virt-df -a ../images/fedora.img -h >/dev/null
+       $(VG) ../fish/guestfish -a ../images/fedora.img run
+       $(VG) ../fish/guestfish -a ../images/fedora.img -i exit
+       $(VG) ../inspector/virt-inspector -a ../images/debian.img >/dev/null
+       $(VG) ../inspector/virt-inspector -a ../images/fedora.img >/dev/null
+       $(VG) ../inspector/virt-inspector -a ../images/fedora-md1.img -a ../images/fedora-md2.img >/dev/null
+       $(VG) ../inspector/virt-inspector -a ../images/ubuntu.img >/dev/null
+       $(VG) ../inspector/virt-inspector -a ../images/windows.img >/dev/null
+
+# Invocations of tools on real images shouldn't leak memory.
+test-tools-real:
+       $(VG) virt-df >/dev/null
+       $(VG) virt-df -h >/dev/null
+       @for g in $(GUESTS); do \
+         echo $(VG) ../inspector/virt-inspector -d $$g; \
+         $(VG) ../inspector/virt-inspector -d $$g > /dev/null; \
+         r=$$?; \
+         if [ $$r -ne 0 ]; then exit $$r; fi; \
+       done
+       @for g in $(GUESTS); do \
+         echo $(VG) ../cat/virt-filesystems -d $$g --all --long -h --uuid; \
+         $(VG) ../cat/virt-filesystems -d $$g --all --long -h --uuid > /dev/null; \
+         r=$$?; \
+         if [ $$r -ne 0 ]; then exit $$r; fi; \
+       done
+
+
+# XXX Not tested:
+# ../clone/virt-sysprep
+# ../edit/virt-edit
+# ../edit/virt-edit -e
+# ../fuse/guestmount
+# ../resize/virt-resize (OCaml)
+# ../sparsify/virt-sparsify (OCaml)
+# ../tools/virt-win-reg (Perl)
+# ../tools/virt-make-fs (Perl)
index 0358d8a..41e84ac 100644 (file)
@@ -2957,6 +2957,11 @@ L<virt-edit(1)> command and documentation.
 
 C API example code.
 
+=item C<extratests>
+
+Extra tests.  These are not run by default because they require
+special tools or configuration.
+
 =item C<fish>
 
 L<guestfish(1)>, the command-line shell, and various shell scripts