From 92773e6852719354a136d31519948436f9adf7e9 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sat, 18 Dec 2021 20:31:10 +0000
Subject: [PATCH] tests: Add configure --disable-libguestfs-tests flag
This can be used to disable tests which need libguestfs*. We were
already doing that in a hackish way in the Fedora build on some
architectures. This makes it more supportable.
Note that you can use
./configure --enable-libguestfs --disable-libguestfs-tests
to enable the bindings but disable the tests.
The difference between without and with the new flag on an otherwise
fully configured Fedora machine:
# TOTAL: 286
# PASS: 273
# SKIP: 13
# TOTAL: 263
# PASS: 251
# SKIP: 12
* except for those which directly test for requirements using
expressions like:
requires guestfish --version
(cherry picked from commit c09ae98ff3b4b786565de4aa173274531a753d30)
---
configure.ac | 17 ++++++++++++++++-
tests/Makefile.am | 2 ++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 08c307e9..96d738d9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1146,7 +1146,8 @@ AS_IF([test "$with_libzstd" != "no"],[
])
AM_CONDITIONAL([HAVE_LIBZSTD],[test "x$LIBZSTD_LIBS" != "x"])
-dnl Check for libguestfs (only for the guestfs plugin and the test suite).
+dnl Check for libguestfs (only for the guestfs plugin and parts of
+dnl the test suite).
AC_ARG_WITH([libguestfs],
[AS_HELP_STRING([--without-libguestfs],
[disable guestfs plugin and tests @<:@default=check@:>@])],
@@ -1173,6 +1174,17 @@ AS_IF([test "$with_libguestfs" != "no"],[
])
AM_CONDITIONAL([HAVE_LIBGUESTFS],[test "x$LIBGUESTFS_LIBS" != "x"])
+dnl Disable tests which need libguestfs.
+AC_ARG_ENABLE([libguestfs-tests],
+ [AS_HELP_STRING([--disable-libguestfs-tests],
+ [disable tests which need libguestfs])],
+ [],
+ [enable_libguestfs_tests=check]
+)
+AM_CONDITIONAL([USE_LIBGUESTFS_FOR_TESTS],
+ [test "x$LIBGUESTFS_LIBS" != "x" && \
+ test "x$enable_libguestfs_tests" != "xno"])
+
dnl Check for ext2fs and com_err, for the ext2 filter.
AC_ARG_WITH([ext2],
[AS_HELP_STRING([--without-ext2],
@@ -1447,6 +1459,9 @@ echo "Other optional features:"
echo
feature "allocator=zstd ......................... " \
test "x$HAVE_LIBZSTD_TRUE" = "x"
+feature "tests using libguestfs ................. " \
+ test "x$HAVE_LIBGUESTFS_TRUE" = "x" -a \
+ "x$USE_LIBGUESTFS_FOR_TESTS_TRUE" = "x"
echo
echo "If any optional component is configured ‘no’ when you expected ‘yes’"
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 2b7ae9f3..43b60943 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1888,6 +1888,8 @@ TESTS += $(LIBNBD_TESTS)
endif HAVE_LIBNBD
if HAVE_LIBGUESTFS
+if USE_LIBGUESTFS_FOR_TESTS
check_PROGRAMS += $(LIBGUESTFS_TESTS)
TESTS += $(LIBGUESTFS_TESTS)
+endif USE_LIBGUESTFS_FOR_TESTS
endif HAVE_LIBGUESTFS
--
2.31.1