From: "Daniel P. Berrange" <berrange(a)redhat.com>
Add a new flag '--with-test-suite' to configure to control whether
the test suite binaries are built by default. ie built with a
plain 'make', as opposed to delayed until 'make check'
For builds from tar.gz tests will not be built by default. For
builds from GIT, tests with be on by default, to try and ensure
that patch developers don't accidentally break the test suites
without noticing.
* configure.ac: Add --with-test-suite
* tests/Makefile.am: Use noinst_PROGRAMS instead of check_PROGRAMS
if building tests by default. Consolidate setting of TESTS and
{noinst,check}_PROGRAMS to avoid duplication
---
configure.ac | 19 ++++++++
tests/Makefile.am | 119 +++++++++++++---------------------------------------
2 files changed, 49 insertions(+), 89 deletions(-)
diff --git a/configure.ac b/configure.ac
index c1f9f45..740129c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2162,6 +2162,25 @@ AM_CONDITIONAL([WITH_PYTHON], [test "$with_python" =
"yes"])
AC_SUBST([PYTHON_VERSION])
AC_SUBST([PYTHON_INCLUDES])
+AC_ARG_ENABLE([with-test-suite],
+ AC_HELP_STRING([--with-test-suite], [build test suite by default
@<:@default=check@:>@]),
+ [case "${withval}" in
+ yes|no|check) ;;
+ *) AC_MSG_ERROR([bad value ${withval} for tests option]) ;;
+ esac],
+ [withval=check])
+
+AC_MSG_CHECKING([Whether to build test suite by default])
+if test "$withval" = "check" ; then
+ if test -d $srcdir/.git ; then
+ withval=yes
+ else
+ withval=no
+ fi
+fi
+AC_MSG_RESULT([$withval])
+AM_CONDITIONAL([WITH_TESTS], [test "$withval" = "yes"])
+
AC_ARG_ENABLE([test-coverage],
AC_HELP_STRING([--enable-test-coverage], [turn on code coverage instrumentation
@<:@default=no@:>@]),
[case "${enableval}" in
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4a0686f..dd8bf4f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -92,69 +92,68 @@ EXTRA_DIST = \
xml2vmxdata \
.valgrind.supp
-check_PROGRAMS = virshtest conftest sockettest \
+test_helpers = commandhelper ssh conftest
+test_programs = virshtest sockettest \
nodeinfotest virbuftest \
- commandtest commandhelper seclabeltest \
- virhashtest virnetmessagetest virnetsockettest ssh \
+ commandtest seclabeltest \
+ virhashtest virnetmessagetest virnetsockettest \
utiltest virnettlscontexttest shunloadtest \
virtimetest viruritest virkeyfiletest \
virauthconfigtest
-check_LTLIBRARIES = libshunload.la
-
# This is a fake SSH we use from virnetsockettest
ssh_SOURCES = ssh.c
ssh_LDADD = $(COVERAGE_LDFLAGS)
if WITH_XEN
-check_PROGRAMS += xml2sexprtest sexpr2xmltest \
+test_programs += xml2sexprtest sexpr2xmltest \
xmconfigtest xencapstest statstest reconnect
endif
if WITH_QEMU
-check_PROGRAMS += qemuxml2argvtest qemuxml2xmltest qemuxmlnstest \
+test_programs += qemuxml2argvtest qemuxml2xmltest qemuxmlnstest \
qemuargv2xmltest qemuhelptest domainsnapshotxml2xmltest \
qemumonitortest
endif
if WITH_LXC
-check_PROGRAMS += lxcxml2xmltest
+test_programs += lxcxml2xmltest
endif
if WITH_OPENVZ
-check_PROGRAMS += openvzutilstest
+test_programs += openvzutilstest
endif
if WITH_ESX
-check_PROGRAMS += esxutilstest
+test_programs += esxutilstest
endif
if WITH_VMX
-check_PROGRAMS += vmx2xmltest xml2vmxtest
+test_programs += vmx2xmltest xml2vmxtest
endif
if WITH_CIL
-check_PROGRAMS += object-locking
+test_programs += object-locking
endif
if HAVE_YAJL
-check_PROGRAMS += jsontest
+test_programs += jsontest
endif
-check_PROGRAMS += networkxml2xmltest
+test_programs += networkxml2xmltest
if WITH_NETWORK
-check_PROGRAMS += networkxml2argvtest
+test_programs += networkxml2argvtest
endif
-check_PROGRAMS += nwfilterxml2xmltest
+test_programs += nwfilterxml2xmltest
-check_PROGRAMS += storagevolxml2xmltest storagepoolxml2xmltest
+test_programs += storagevolxml2xmltest storagepoolxml2xmltest
-check_PROGRAMS += nodedevxml2xmltest
+test_programs += nodedevxml2xmltest
-check_PROGRAMS += interfacexml2xmltest
+test_programs += interfacexml2xmltest
-check_PROGRAMS += cputest
+test_programs += cputest
test_scripts = \
capabilityschematest \
@@ -185,6 +184,8 @@ test_scripts += \
virsh-optparse \
virsh-schedinfo \
virsh-synopsis
+
+test_programs += eventtest
else
EXTRA_DIST += \
test_conf.sh \
@@ -213,77 +214,16 @@ endif
EXTRA_DIST += $(test_scripts)
-TESTS = virshtest \
- nodeinfotest \
- virbuftest \
- sockettest \
- commandtest \
- seclabeltest \
- virhashtest \
- virnetmessagetest \
- virnetsockettest \
- virnettlscontexttest \
- virtimetest \
- viruritest \
- virkeyfiletest \
- virauthconfigtest \
- shunloadtest \
- utiltest \
- $(test_scripts)
-
-if HAVE_YAJL
-TESTS += jsontest
-endif
-
-if WITH_XEN
-TESTS += xml2sexprtest \
- sexpr2xmltest \
- xmconfigtest \
- xencapstest \
- reconnect \
- statstest
-endif
-
-if WITH_QEMU
-TESTS += qemuxml2argvtest qemuxml2xmltest qemuxmlnstest qemuargv2xmltest \
- qemuhelptest domainsnapshotxml2xmltest nwfilterxml2xmltest \
- qemumonitortest
-endif
-
-if WITH_LXC
-TESTS += lxcxml2xmltest
-endif
-
-if WITH_OPENVZ
-TESTS += openvzutilstest
-endif
-
-if WITH_ESX
-TESTS += esxutilstest
-endif
-
-if WITH_VMX
-TESTS += vmx2xmltest xml2vmxtest
-endif
-
-if WITH_LIBVIRTD
-check_PROGRAMS += eventtest
-TESTS += eventtest
-endif
-
-TESTS += networkxml2xmltest
-
-if WITH_NETWORK
-TESTS += networkxml2argvtest
+if WITH_TESTS
+noinst_PROGRAMS = $(test_programs) $(test_helpers)
+noinst_LTLIBRARIES = libshunload.la
+else
+check_PROGRAMS = $(test_programs) $(test_helpers)
+check_LTLIBRARIES = libshunload.la
endif
-TESTS += storagevolxml2xmltest storagepoolxml2xmltest
-
-TESTS += nodedevxml2xmltest
-
-TESTS += interfacexml2xmltest
-
-TESTS += cputest
+TESTS = $(test_programs) \
+ $(test_scripts)
# NB, automake < 1.10 does not provide the real
# abs_top_{src/build}dir or builddir variables, so don't rely
@@ -306,6 +246,7 @@ TESTS_ENVIRONMENT = \
LC_ALL=C \
$(VG)
+
valgrind:
$(MAKE) check VG="valgrind --quiet --leak-check=full
--suppressions=$(srcdir)/.valgrind.supp"
--
1.7.7.6