diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2012-06-26 22:47:35 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-06-26 23:34:30 +0100 |
commit | 05d4e07918bfa9907a1fa66391e8e2e2370c64d4 (patch) | |
tree | 7e18079fefdf927b56715f24e0080c2a65a70840 | |
parent | bbb7d75c91450ab029edb794b0486eeb8220e4fd (diff) | |
download | libguestfs-05d4e07918bfa9907a1fa66391e8e2e2370c64d4.tar.gz libguestfs-05d4e07918bfa9907a1fa66391e8e2e2370c64d4.tar.xz libguestfs-05d4e07918bfa9907a1fa66391e8e2e2370c64d4.zip |
tests: Add ./run --test option.
This option, when added via
TESTS_ENVIRONMENT = [...] $(top_builddir)/run --test
allows us to run the tests and only print the full output (including
debugging etc) when the test fails.
31 files changed, 64 insertions, 38 deletions
diff --git a/align/Makefile.am b/align/Makefile.am index eccb05c0..ab78e839 100644 --- a/align/Makefile.am +++ b/align/Makefile.am @@ -74,6 +74,6 @@ stamp-virt-alignment-scan.pod: virt-alignment-scan.pod # TESTS_ENVIRONMENT = \ # MALLOC_PERTURB_=$(random_val) \ -# $(top_builddir)/run +# $(top_builddir)/run --test # TESTS = test-virt-alignment-scan.sh diff --git a/cat/Makefile.am b/cat/Makefile.am index f883d108..f2c3ac86 100644 --- a/cat/Makefile.am +++ b/cat/Makefile.am @@ -132,7 +132,7 @@ random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null) TESTS_ENVIRONMENT = \ MALLOC_PERTURB_=$(random_val) \ - $(top_builddir)/run + $(top_builddir)/run --test if ENABLE_APPLIANCE TESTS = test-virt-cat.sh test-virt-filesystems.sh test-virt-ls.sh diff --git a/df/Makefile.am b/df/Makefile.am index 83409da1..95da813c 100644 --- a/df/Makefile.am +++ b/df/Makefile.am @@ -78,7 +78,7 @@ random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null) TESTS_ENVIRONMENT = \ MALLOC_PERTURB_=$(random_val) \ - $(top_builddir)/run + $(top_builddir)/run --test if ENABLE_APPLIANCE TESTS = test-virt-df.sh diff --git a/edit/Makefile.am b/edit/Makefile.am index e89136a8..e3f80b25 100644 --- a/edit/Makefile.am +++ b/edit/Makefile.am @@ -70,7 +70,7 @@ random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null) TESTS_ENVIRONMENT = \ MALLOC_PERTURB_=$(random_val) \ - $(top_builddir)/run + $(top_builddir)/run --test if ENABLE_APPLIANCE TESTS = test-virt-edit.sh diff --git a/fish/Makefile.am b/fish/Makefile.am index 6b52820b..1d8f4d3f 100644 --- a/fish/Makefile.am +++ b/fish/Makefile.am @@ -233,7 +233,7 @@ random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null) TESTS_ENVIRONMENT = \ MALLOC_PERTURB_=$(random_val) \ - $(top_builddir)/run + $(top_builddir)/run --test TESTS = \ test-a.sh \ diff --git a/format/Makefile.am b/format/Makefile.am index d9ae7e29..cc839288 100644 --- a/format/Makefile.am +++ b/format/Makefile.am @@ -71,7 +71,7 @@ random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null) TESTS_ENVIRONMENT = \ MALLOC_PERTURB_=$(random_val) \ - $(top_builddir)/run + $(top_builddir)/run --test if ENABLE_APPLIANCE TESTS = test-virt-format.sh diff --git a/haskell/Makefile.am b/haskell/Makefile.am index 6cc75bd6..866b85e5 100644 --- a/haskell/Makefile.am +++ b/haskell/Makefile.am @@ -28,7 +28,7 @@ EXTRA_DIST = $(generator_built) *.hs run-bindtests if HAVE_HASKELL TESTS_ENVIRONMENT = \ - $(top_builddir)/run \ + $(top_builddir)/run --test \ $(VG) # Don't run the bindtests: they don't build since the addition of optargs. diff --git a/inspector/Makefile.am b/inspector/Makefile.am index 00300a09..df870c8b 100644 --- a/inspector/Makefile.am +++ b/inspector/Makefile.am @@ -104,18 +104,22 @@ endif example-debian.xml: rm -f $@ $@-t - ../run $(builddir)/virt-inspector ../tests/guests/debian.img > $@-t + ../run --test \ + $(builddir)/virt-inspector ../tests/guests/debian.img > $@-t mv $@-t $@ example-fedora.xml: rm -f $@ $@-t - ../run $(builddir)/virt-inspector ../tests/guests/fedora.img > $@-t + ../run --test \ + $(builddir)/virt-inspector ../tests/guests/fedora.img > $@-t mv $@-t $@ example-ubuntu.xml: rm -f $@ $@-t - ../run $(builddir)/virt-inspector ../tests/guests/ubuntu.img > $@-t + ../run --test \ + $(builddir)/virt-inspector ../tests/guests/ubuntu.img > $@-t mv $@-t $@ example-windows.xml: rm -f $@ $@-t - ../run $(builddir)/virt-inspector ../tests/guests/windows.img | \ + ../run --test \ + $(builddir)/virt-inspector ../tests/guests/windows.img | \ fgrep -v '<uuid>' > $@-t mv $@-t $@ diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index f22f3f4c..232edb7f 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -82,7 +82,7 @@ endif TESTS_ENVIRONMENT = \ CAML_LD_LIBRARY_PATH=. \ - $(top_builddir)/run \ + $(top_builddir)/run --test \ $(VG) test_progs = \ diff --git a/perl/Makefile.am b/perl/Makefile.am index 404a4e91..bca7b0bf 100644 --- a/perl/Makefile.am +++ b/perl/Makefile.am @@ -57,7 +57,7 @@ endif $(TESTS): $(test_prereq) TESTS_ENVIRONMENT = \ - $(top_builddir)/run + $(top_builddir)/run --test INSTALLDIRS = site diff --git a/python/Makefile.am b/python/Makefile.am index c6c1b1df..6ffb0d8d 100644 --- a/python/Makefile.am +++ b/python/Makefile.am @@ -47,7 +47,7 @@ libguestfsmod_la_LDFLAGS = -avoid-version -shared TESTS_ENVIRONMENT = \ PYTHON=$(PYTHON) \ - $(top_builddir)/run + $(top_builddir)/run --test TESTS = run-bindtests diff --git a/resize/Makefile.am b/resize/Makefile.am index 8d87ab97..b613bb77 100644 --- a/resize/Makefile.am +++ b/resize/Makefile.am @@ -112,7 +112,7 @@ random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null) TESTS_ENVIRONMENT = \ MALLOC_PERTURB_=$(random_val) \ - $(top_builddir)/run + $(top_builddir)/run --test TESTS = utils_tests if ENABLE_APPLIANCE diff --git a/ruby/Makefile.am b/ruby/Makefile.am index 9073ad7d..35599c30 100644 --- a/ruby/Makefile.am +++ b/ruby/Makefile.am @@ -51,7 +51,7 @@ TESTS = run-bindtests run-ruby-tests TESTS_ENVIRONMENT = \ RUBY=$(RUBY) \ - $(top_builddir)/run + $(top_builddir)/run --test all: $(generator_built) $(RAKE) build @@ -26,9 +26,17 @@ # This works for any C, OCaml or Perl virt tools in the libguestfs # distribution. Also you can make a symbolic link to this 'run' # script from anywhere (eg. $HOME/bin/run) if you wish. +# +# The script can also be used to make the output of tests shorter: +# TESTS_ENVIRONMENT = ... $(top_builddir)/run --test #---------------------------------------------------------------------- +if [ "$1" = "--test" ]; then + test_mode=1 + shift +fi + # Find this script. b=@abs_builddir@ @@ -75,4 +83,20 @@ if libtool --help >/dev/null 2>&1; then fi # Run the program. -exec $libtool "$@" +if [ -z "$test_mode" ]; then + exec $libtool "$@" +else + # For tests (./run --test), redirect all output to a file, and + # only print the file if the test fails. + fail=0 + pid=$$ + rm -f run.$pid + $libtool "$@" > $b/run.$pid 2>&1 || { + fail=$? + echo "$b/run --test" "$@" + cat $b/run.$pid + echo "$b/run: command failed with exit code $fail" + } + rm -f run.$pid + exit $fail +fi diff --git a/sparsify/Makefile.am b/sparsify/Makefile.am index f4002e3e..5df30a80 100644 --- a/sparsify/Makefile.am +++ b/sparsify/Makefile.am @@ -105,7 +105,7 @@ random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null) TESTS_ENVIRONMENT = \ MALLOC_PERTURB_=$(random_val) \ - $(top_builddir)/run + $(top_builddir)/run --test if ENABLE_APPLIANCE TESTS = test-virt-sparsify.sh diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am index be233a91..7d20e102 100644 --- a/sysprep/Makefile.am +++ b/sysprep/Makefile.am @@ -168,7 +168,7 @@ TESTS_ENVIRONMENT = \ MALLOC_PERTURB_=$(random_val) \ abs_builddir=$(abs_builddir) \ abs_srcdir=$(abs_srcdir) \ - $(top_builddir)/run + $(top_builddir)/run --test if ENABLE_APPLIANCE TESTS = \ diff --git a/tests/btrfs/Makefile.am b/tests/btrfs/Makefile.am index 6d789ba7..89f683c4 100644 --- a/tests/btrfs/Makefile.am +++ b/tests/btrfs/Makefile.am @@ -25,7 +25,7 @@ random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null) TESTS_ENVIRONMENT = \ MALLOC_PERTURB_=$(random_val) \ - $(top_builddir)/run + $(top_builddir)/run --test EXTRA_DIST = \ $(TESTS) diff --git a/tests/c-api/Makefile.am b/tests/c-api/Makefile.am index 8888b739..04cd52c1 100644 --- a/tests/c-api/Makefile.am +++ b/tests/c-api/Makefile.am @@ -61,8 +61,7 @@ EXTRA_DIST += test-add-libvirt-dom.c TESTS_ENVIRONMENT = \ SKIP_TEST_COMMAND=$(shell ldd test-command | grep -sq 'not a dynamic executable' || echo 1) \ SKIP_TEST_COMMAND_LINES=$(shell ldd test-command | grep -sq 'not a dynamic executable' || echo 1) \ - LIBGUESTFS_PATH=$(top_builddir)/appliance \ - TMPDIR=$(top_builddir) \ + $(top_builddir)/run --test \ $(VG) #SKIP_TEST_CHECKSUM_8=$(shell if test `find ../initramfs -name squashfs.ko | wc -l` -eq 0; then echo 1; fi) diff --git a/tests/charsets/Makefile.am b/tests/charsets/Makefile.am index d18cb61a..401f47f5 100644 --- a/tests/charsets/Makefile.am +++ b/tests/charsets/Makefile.am @@ -24,8 +24,7 @@ random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null) TESTS_ENVIRONMENT = \ MALLOC_PERTURB_=$(random_val) \ - LIBGUESTFS_PATH=$(top_builddir)/appliance \ - TMPDIR=$(top_builddir) \ + $(top_builddir)/run --test \ $(VG) check_PROGRAMS = $(TESTS) diff --git a/tests/disks/Makefile.am b/tests/disks/Makefile.am index da68fd50..d1b57349 100644 --- a/tests/disks/Makefile.am +++ b/tests/disks/Makefile.am @@ -24,7 +24,7 @@ random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null) TESTS_ENVIRONMENT = \ MALLOC_PERTURB_=$(random_val) \ - $(top_builddir)/run + $(top_builddir)/run --test EXTRA_DIST = \ $(TESTS) diff --git a/tests/guests/Makefile.am b/tests/guests/Makefile.am index 3e5aea03..77ce61ba 100644 --- a/tests/guests/Makefile.am +++ b/tests/guests/Makefile.am @@ -49,7 +49,7 @@ fedora.img: guest-aux/make-fedora-img.pl \ TMPDIR=$(top_builddir) \ SRCDIR=$(srcdir) \ LAYOUT=partitions \ - ../../run $< + ../../run --test $< # Make a (dummy) Fedora image using md devices fedora-md1.img fedora-md2.img: stamp-fedora-md.img @@ -61,7 +61,7 @@ stamp-fedora-md.img: guest-aux/make-fedora-img.pl \ TMPDIR=$(top_builddir) \ SRCDIR=$(srcdir) \ LAYOUT=partitions-md \ - ../../run $< + ../../run --test $< touch $@ guest-aux/fedora-name.db: guest-aux/fedora-name.db.txt diff --git a/tests/luks/Makefile.am b/tests/luks/Makefile.am index fdbbb1b6..cafef0ba 100644 --- a/tests/luks/Makefile.am +++ b/tests/luks/Makefile.am @@ -25,7 +25,7 @@ random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null) TESTS_ENVIRONMENT = \ MALLOC_PERTURB_=$(random_val) \ - $(top_builddir)/run + $(top_builddir)/run --test EXTRA_DIST = \ $(TESTS) diff --git a/tests/lvm/Makefile.am b/tests/lvm/Makefile.am index 7e89baba..3242e17c 100644 --- a/tests/lvm/Makefile.am +++ b/tests/lvm/Makefile.am @@ -25,7 +25,7 @@ random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null) TESTS_ENVIRONMENT = \ MALLOC_PERTURB_=$(random_val) \ - $(top_builddir)/run + $(top_builddir)/run --test EXTRA_DIST = \ $(TESTS) diff --git a/tests/md/Makefile.am b/tests/md/Makefile.am index 06352da6..2b4e7a10 100644 --- a/tests/md/Makefile.am +++ b/tests/md/Makefile.am @@ -28,7 +28,7 @@ random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null) TESTS_ENVIRONMENT = \ MALLOC_PERTURB_=$(random_val) \ - $(top_builddir)/run + $(top_builddir)/run --test EXTRA_DIST = \ - $(TESTS)
\ No newline at end of file + $(TESTS) diff --git a/tests/ntfsclone/Makefile.am b/tests/ntfsclone/Makefile.am index 637b247a..fcce8100 100644 --- a/tests/ntfsclone/Makefile.am +++ b/tests/ntfsclone/Makefile.am @@ -24,7 +24,7 @@ random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null) TESTS_ENVIRONMENT = \ MALLOC_PERTURB_=$(random_val) \ - $(top_builddir)/run + $(top_builddir)/run --test EXTRA_DIST = \ $(TESTS) diff --git a/tests/protocol/Makefile.am b/tests/protocol/Makefile.am index 6e0f03f4..671b2626 100644 --- a/tests/protocol/Makefile.am +++ b/tests/protocol/Makefile.am @@ -30,7 +30,7 @@ random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null) TESTS_ENVIRONMENT = \ MALLOC_PERTURB_=$(random_val) \ - $(top_builddir)/run + $(top_builddir)/run --test EXTRA_DIST = \ $(TESTS) diff --git a/tests/qemu/Makefile.am b/tests/qemu/Makefile.am index 128296d3..af2061dc 100644 --- a/tests/qemu/Makefile.am +++ b/tests/qemu/Makefile.am @@ -29,7 +29,7 @@ random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null) TESTS_ENVIRONMENT = \ MALLOC_PERTURB_=$(random_val) \ - $(top_builddir)/run + $(top_builddir)/run --test EXTRA_DIST = \ $(TESTS) diff --git a/tests/regressions/Makefile.am b/tests/regressions/Makefile.am index 3027cd8e..22a364cc 100644 --- a/tests/regressions/Makefile.am +++ b/tests/regressions/Makefile.am @@ -39,7 +39,7 @@ random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null) TESTS_ENVIRONMENT = \ MALLOC_PERTURB_=$(random_val) \ NOEXEC_CHECK="$(top_builddir)/src/.libs/libguestfs.so $(top_builddir)/daemon/guestfsd" \ - $(top_builddir)/run + $(top_builddir)/run --test check_PROGRAMS = \ rhbz501893 \ diff --git a/tests/selinux/Makefile.am b/tests/selinux/Makefile.am index 29ee7fdc..47fdde54 100644 --- a/tests/selinux/Makefile.am +++ b/tests/selinux/Makefile.am @@ -34,7 +34,7 @@ random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null) TESTS_ENVIRONMENT = \ MALLOC_PERTURB_=$(random_val) \ - $(top_builddir)/run + $(top_builddir)/run --test EXTRA_DIST = \ run-test.pl \ diff --git a/tests/xml/Makefile.am b/tests/xml/Makefile.am index f5638fcb..04f9e685 100644 --- a/tests/xml/Makefile.am +++ b/tests/xml/Makefile.am @@ -40,7 +40,7 @@ TESTS_ENVIRONMENT = \ MALLOC_PERTURB_=$(random_val) \ abs_srcdir=$(abs_srcdir) \ LD_PRELOAD=.libs/libfakevirtxml.so \ - $(top_builddir)/run + $(top_builddir)/run --test endif diff --git a/tools/Makefile.am b/tools/Makefile.am index 0a7cfaad..a5d9844c 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -59,7 +59,7 @@ random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null) TESTS_ENVIRONMENT = \ MALLOC_PERTURB_=$(random_val) \ - $(top_builddir)/run + $(top_builddir)/run --test if ENABLE_APPLIANCE TESTS = test-virt-list-filesystems.sh \ |