]> git.ipfire.org Git - telemetry.git/commitdiff
configure: Add option to enable tests
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 8 Oct 2025 16:23:14 +0000 (16:23 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 8 Oct 2025 16:23:14 +0000 (16:23 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
configure.ac
src/daemon/sources.c

index 5ad4d4c30d65ee1806c424d82f9507d58bcfe0cd..ec242a01bc4575ce79d1944a26c31a620d06ec17 100644 (file)
@@ -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)
 
index 03e291c17190dad160964722375d44bfbe3cb6c1..be3c1d4a6da87a13f3bc9ab6da4915516aaca043 100644 (file)
@@ -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]),
        [],
index 0e2101807cd6803e1382583b8108bf72f6dad161..5a0d115f631f5ecb03d85bbed5a64b868b8195a2 100644 (file)
 #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,
 };