mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
tests: Fix 'make check-slow'.
Since we started to use the parallel tests framework in automake, 'make check-slow' has been broken. This is because parallel tests doesn't allow you to run 'make check TESTS=...' with a set of test scripts which do not also appear in the static list of tests in the Makefile.am. We would like to list and run only "fast" tests in the Makefile.am, and have other scripts for slow tests. The solution is to add the slow tests to Makefile.am, but condition those tests on an environment variable SLOW=1 being set. This commit fixes all the existing slow tests in this way, and updates the documentation (guestfs-hacking(1)) to document how slow tests should be written in future.
This commit is contained in:
@@ -284,7 +284,8 @@ yajl_tests_LINK = \
|
||||
|
||||
TESTS = \
|
||||
test-virt-builder-list.sh \
|
||||
test-virt-index-validate.sh
|
||||
test-virt-index-validate.sh \
|
||||
$(SLOW_TESTS)
|
||||
check_PROGRAMS =
|
||||
|
||||
TESTS += test-virt-builder-list-simplestreams.sh
|
||||
@@ -300,8 +301,10 @@ endif
|
||||
check-valgrind:
|
||||
$(MAKE) VG="$(top_builddir)/run @VG@" check
|
||||
|
||||
SLOW_TESTS = test-virt-builder-planner.sh
|
||||
|
||||
check-slow:
|
||||
$(MAKE) TESTS="test-virt-builder-planner.sh" check
|
||||
$(MAKE) check TESTS="$(SLOW_TESTS)" SLOW=1
|
||||
|
||||
# Dependencies.
|
||||
depend: .depend
|
||||
|
||||
@@ -24,6 +24,11 @@ abs_builddir=$(pwd)
|
||||
export XDG_CONFIG_HOME=
|
||||
export XDG_CONFIG_DIRS="$abs_builddir/test-config"
|
||||
|
||||
if [ -z "$SLOW" ]; then
|
||||
echo "$0: use 'make check-slow' to run this test"
|
||||
exit 77
|
||||
fi
|
||||
|
||||
if [ ! -f fedora.xz -o ! -f fedora.qcow2 -o ! -f fedora.qcow2.xz ]; then
|
||||
echo "$0: test skipped because there is no fedora.xz, fedora.qcow2 or fedora.qcow2.xz in the build directory"
|
||||
exit 77
|
||||
|
||||
@@ -330,8 +330,33 @@ but you can set this to another directory on the command line, eg:
|
||||
|
||||
Runs some slow/long-running tests which are not run by default.
|
||||
|
||||
Any F<Makefile.am> in the tree that has a C<check-slow:> target will
|
||||
be run by this rule.
|
||||
To mark a test as slow/long-running:
|
||||
|
||||
=over 4
|
||||
|
||||
=item *
|
||||
|
||||
Add it to the list of C<TESTS> in the F<Makefile.am>, just like a
|
||||
normal test.
|
||||
|
||||
=item *
|
||||
|
||||
Modify the test so it checks if the C<SLOW=1> environment variable is
|
||||
set, and if I<not> set it skips (ie. returns with exit code 77).
|
||||
|
||||
=item *
|
||||
|
||||
Add a variable C<SLOW_TESTS> to the F<Makefile.am> listing the slow
|
||||
tests.
|
||||
|
||||
=item *
|
||||
|
||||
Add a rule to the F<Makefile.am>:
|
||||
|
||||
check-slow:
|
||||
$(MAKE) check TESTS="$(SLOW_TESTS)" SLOW=1
|
||||
|
||||
=back
|
||||
|
||||
=item C<make check-all>
|
||||
|
||||
|
||||
@@ -166,7 +166,8 @@ TESTS = \
|
||||
|
||||
if ENABLE_APPLIANCE
|
||||
TESTS += \
|
||||
test-virt-p2v.sh
|
||||
test-virt-p2v.sh \
|
||||
$(SLOW_TESTS)
|
||||
endif ENABLE_APPLIANCE
|
||||
|
||||
SLOW_TESTS = \
|
||||
@@ -178,7 +179,7 @@ check-slow: test-virt-p2v-pxe.img \
|
||||
test-virt-p2v-pxe.ssh_host_rsa_key \
|
||||
test-virt-p2v-pxe.ssh_host_rsa_key.pub \
|
||||
test-virt-p2v-pxe.id_rsa test-virt-p2v-pxe.id_rsa.pub
|
||||
$(MAKE) check TESTS="$(SLOW_TESTS)"
|
||||
$(MAKE) check TESTS="$(SLOW_TESTS)" SLOW=1
|
||||
|
||||
test-virt-p2v-pxe.img: virt-p2v-make-disk \
|
||||
virt-p2v \
|
||||
|
||||
@@ -28,6 +28,11 @@ unset CDPATH
|
||||
export LANG=C
|
||||
set -e
|
||||
|
||||
if [ -z "$SLOW" ]; then
|
||||
echo "$0: use 'make check-slow' to run this test"
|
||||
exit 77
|
||||
fi
|
||||
|
||||
if [ -n "$SKIP_TEST_VIRT_P2V_PXE_SH" ]; then
|
||||
echo "$0: test skipped because environment variable is set"
|
||||
exit 77
|
||||
|
||||
@@ -17,14 +17,12 @@
|
||||
|
||||
include $(top_srcdir)/subdir-rules.mk
|
||||
|
||||
EXTRA_DIST = test-big-dirs.pl
|
||||
EXTRA_DIST = $(TESTS)
|
||||
|
||||
# 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 = $(SLOW_TESTS)
|
||||
TESTS_ENVIRONMENT = $(top_builddir)/run --test
|
||||
|
||||
SLOW_TESTS = test-big-dirs.pl
|
||||
|
||||
check-slow:
|
||||
$(MAKE) TESTS="test-big-dirs.pl" check
|
||||
$(MAKE) check TESTS="$(SLOW_TESTS)" SLOW=1
|
||||
|
||||
@@ -22,6 +22,11 @@ use warnings;
|
||||
|
||||
use Sys::Guestfs;
|
||||
|
||||
unless ($ENV{SLOW}) {
|
||||
print "$0: use 'make check-slow' to run this test\n";
|
||||
exit 77;
|
||||
}
|
||||
|
||||
my $g = Sys::Guestfs->new ();
|
||||
|
||||
# Create a 2 GB test file. Don't worry, it's sparse.
|
||||
|
||||
@@ -17,12 +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 = $(SLOW_TESTS)
|
||||
TESTS_ENVIRONMENT = $(top_builddir)/run --test
|
||||
|
||||
SLOW_TESTS = test-parallel
|
||||
|
||||
check_PROGRAMS = test-parallel
|
||||
|
||||
test_parallel_SOURCES = test-parallel.c
|
||||
@@ -43,4 +42,4 @@ test_parallel_LDADD = \
|
||||
# $(MAKE) VG="$(top_builddir)/run @VG@" TESTS="test-parallel" check
|
||||
|
||||
check-slow:
|
||||
$(MAKE) TESTS="test-parallel" check
|
||||
$(MAKE) check TESTS="$(SLOW_TESTS)" SLOW=1
|
||||
|
||||
@@ -67,7 +67,7 @@ catch_sigint (int signal)
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
char *skip;
|
||||
const char *skip, *slow;
|
||||
struct sigaction sa;
|
||||
int r;
|
||||
size_t i, errors = 0;
|
||||
@@ -75,6 +75,14 @@ main (int argc, char *argv[])
|
||||
|
||||
srandom (time (NULL));
|
||||
|
||||
/* Only run this test when invoked by check-slow. */
|
||||
slow = getenv ("SLOW");
|
||||
if (!slow || guestfs_int_is_true (slow) <= 0) {
|
||||
fprintf (stderr, "%s: use 'make check-slow' to run this test.\n",
|
||||
guestfs_int_program_name);
|
||||
exit (77);
|
||||
}
|
||||
|
||||
/* Allow the test to be skipped by setting an environment variable. */
|
||||
skip = getenv ("SKIP_TEST_PARALLEL");
|
||||
if (skip && guestfs_int_is_true (skip) > 0) {
|
||||
|
||||
@@ -78,15 +78,15 @@ TESTS = \
|
||||
rhbz1232192.sh \
|
||||
rhbz1285847.sh \
|
||||
test-big-heap \
|
||||
test-noexec-stack.pl
|
||||
test-noexec-stack.pl \
|
||||
$(SLOW_TESTS)
|
||||
|
||||
if HAVE_LIBVIRT
|
||||
TESTS += rhbz1044014.sh
|
||||
endif
|
||||
|
||||
tests_not_run = \
|
||||
rhbz727178.sh \
|
||||
rhbz909624.sh
|
||||
rhbz727178.sh
|
||||
|
||||
TESTS_ENVIRONMENT = \
|
||||
NOEXEC_CHECK="$(top_builddir)/src/.libs/libguestfs.so $(top_builddir)/daemon/guestfsd" \
|
||||
@@ -145,5 +145,8 @@ test_big_heap_CFLAGS = \
|
||||
test_big_heap_LDADD = \
|
||||
$(top_builddir)/src/libguestfs.la
|
||||
|
||||
SLOW_TESTS = \
|
||||
rhbz909624.sh
|
||||
|
||||
check-slow:
|
||||
$(MAKE) TESTS="rhbz909624.sh" check
|
||||
$(MAKE) check TESTS="$(CHECK_SLOW)" SLOW=1
|
||||
|
||||
@@ -26,6 +26,11 @@
|
||||
set -e
|
||||
export LANG=C
|
||||
|
||||
if [ -z "$SLOW" ]; then
|
||||
echo "$0: use 'make check-slow' to run this test"
|
||||
exit 77
|
||||
fi
|
||||
|
||||
guestfish <<EOF
|
||||
|
||||
add-ro /dev/null
|
||||
|
||||
@@ -21,7 +21,7 @@ EXTRA_DIST = \
|
||||
$(SOURCES_MLI) $(SOURCES_ML) $(SOURCES_C) \
|
||||
copy_to_local.ml \
|
||||
v2v_unit_tests.ml \
|
||||
$(TESTS) $(SLOW_TESTS) \
|
||||
$(TESTS) \
|
||||
test-v2v-cdrom.expected \
|
||||
test-v2v-cdrom.xml \
|
||||
test-v2v-i-ova.ovf \
|
||||
@@ -319,7 +319,8 @@ TESTS += \
|
||||
test-v2v-print-source.sh \
|
||||
test-v2v-sound.sh \
|
||||
test-v2v-virtio-win-iso.sh \
|
||||
test-v2v-windows-conversion.sh
|
||||
test-v2v-windows-conversion.sh \
|
||||
$(SLOW_TESTS)
|
||||
endif ENABLE_APPLIANCE
|
||||
|
||||
check-valgrind:
|
||||
@@ -329,7 +330,7 @@ SLOW_TESTS = \
|
||||
test-v2v-real-conversions.sh
|
||||
|
||||
check-slow: $(real_guests:%=%.img)
|
||||
$(MAKE) check TESTS="$(SLOW_TESTS)"
|
||||
$(MAKE) check TESTS="$(SLOW_TESTS)" SLOW=1
|
||||
|
||||
# A selection of real guests that test-v2v-real-conversions.sh will
|
||||
# try to convert. This is only used by 'make check-slow'.
|
||||
|
||||
@@ -26,6 +26,11 @@ unset CDPATH
|
||||
export LANG=C
|
||||
set -e
|
||||
|
||||
if [ -z "$SLOW" ]; then
|
||||
echo "$0: use 'make check-slow' to run this test"
|
||||
exit 77
|
||||
fi
|
||||
|
||||
if [ -n "$SKIP_TEST_V2V_REAL_CONVERSIONS_SH" ]; then
|
||||
echo "$0: test skipped because environment variable is set"
|
||||
exit 77
|
||||
|
||||
Reference in New Issue
Block a user