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.
This commit is contained in:
Richard W.M. Jones
2012-06-26 22:47:35 +01:00
parent bbb7d75c91
commit 05d4e07918
31 changed files with 64 additions and 38 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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 \

View File

@@ -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

View File

@@ -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.

View File

@@ -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 $@

View File

@@ -82,7 +82,7 @@ endif
TESTS_ENVIRONMENT = \
CAML_LD_LIBRARY_PATH=. \
$(top_builddir)/run \
$(top_builddir)/run --test \
$(VG)
test_progs = \

View File

@@ -57,7 +57,7 @@ endif
$(TESTS): $(test_prereq)
TESTS_ENVIRONMENT = \
$(top_builddir)/run
$(top_builddir)/run --test
INSTALLDIRS = site

View File

@@ -47,7 +47,7 @@ libguestfsmod_la_LDFLAGS = -avoid-version -shared
TESTS_ENVIRONMENT = \
PYTHON=$(PYTHON) \
$(top_builddir)/run
$(top_builddir)/run --test
TESTS = run-bindtests

View File

@@ -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

View File

@@ -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
run.in Executable file → Normal file
View File

@@ -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

View File

@@ -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

View File

@@ -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 = \

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)
$(TESTS)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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 \

View File

@@ -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 \

View File

@@ -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

View File

@@ -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 \