From: Michael Tremer Date: Wed, 8 Oct 2025 16:23:14 +0000 (+0000) Subject: configure: Add option to enable tests X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8219bf87e1d294c74f23c89e9182dca4f3121cbb;p=telemetry.git configure: Add option to enable tests Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index 5ad4d4c..ec242a0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -70,6 +70,7 @@ po/POTFILES.in: Makefile grep -E "\.(c|h)$$" | sed -e "s@$(abs_srcdir)/@@g" | sort > $@ DISTCHECK_CONFIGURE_FLAGS = \ + --enable-tests \ --with-dbuspolicydir=$$dc_install_base/$(dbuspolicydir) \ --with-dbussystemservicedir=$$dc_install_base/$(dbussystemservicedir) diff --git a/configure.ac b/configure.ac index 03e291c..be3c1d4 100644 --- a/configure.ac +++ b/configure.ac @@ -170,6 +170,22 @@ AM_CONDITIONAL(ENABLE_MANPAGES, [test "x$have_manpages" = "xyes"]) # ------------------------------------------------------------------------------ +AC_ARG_ENABLE([tests], + [AS_HELP_STRING([--enable-tests], + [enable tests (disabled by default)])], + [enable_tests=$enableval], + [enable_tests=no]) + +if test "x$enable_tests" = "xyes"; then + AC_DEFINE([ENABLE_TESTS], [1], [Define if tests should be built]) +else + AC_DEFINE([ENABLE_TESTS], [0], [Define if tests should be built]) +fi + +AM_CONDITIONAL([BUILD_TESTS], [test "x$enable_tests" = "xyes"]) + +# ------------------------------------------------------------------------------ + AC_ARG_WITH([dbuspolicydir], AS_HELP_STRING([--with-dbuspolicydir=DIR], [D-Bus policy directory]), [], diff --git a/src/daemon/sources.c b/src/daemon/sources.c index 0e21018..5a0d115 100644 --- a/src/daemon/sources.c +++ b/src/daemon/sources.c @@ -44,9 +44,11 @@ #include "sources/uptime.h" // Load test sources +#if ENABLE_TESTS #include "sources/test-error.h" #include "sources/test-flapping.h" #include "sources/test-stall.h" +#endif /* ENABLE_TESTS */ // Register all sources static const collecty_source_impl* source_impls[] = { @@ -64,10 +66,12 @@ static const collecty_source_impl* source_impls[] = { &unbound_source, &uptime_source, +#if ENABLE_TESTS // Tests &test_error_source, &test_flapping_source, &test_stall_source, +#endif /* ENABLE_TESTS */ NULL, };