]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
configure: introduce --enable-tests/--disable-tests
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Mon, 23 May 2022 19:49:50 +0000 (13:49 -0600)
committerTom Hromatka <tom.hromatka@oracle.com>
Mon, 23 May 2022 19:49:57 +0000 (13:49 -0600)
There are scenarios where running tests as part of the make check is
not desirable, like rpmbuild.  The build systems might not have the
environment to run the tests and might fail to build the packages.

This patch introduces, --enable-tests as a configure option, which
is set by default and can be disabled using the --disable-tests flag.
When disabled, the configure will skip creating the Makefiles for the
tests/* directories and in the top-level Makefile the SUBDIRS omits
tests. For example, consider the rpmbuild case to build rpm with
--disable-tests passed:
1. ./bootstrap.sh
2. ./configure ./configure --enable-opaque-hierarchy="name=systemd"
   --disable-tests
3. make check
4. make dist
5. cp libcgroup-3.0.0.tar.gz ~/rpmbuild/SOURCES
6. append --disable-tests to configure in libcgroup.spec
7. rpmbuild -ba libcgroup.spec

this will skip running the test/*, during the build, avoiding unexpected
failures

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Makefile.am
configure.ac

index 5117543dae1a3bb5bb71e48558de4e137c8134db..2ab44f35bbb9d4f3b49d0d3f25991266c5becd8f 100644 (file)
@@ -1,6 +1,9 @@
 AUTOMAKE_OPTIONS = foreign
 ACLOCAL_AMFLAGS= -I m4
-SUBDIRS = dist doc include scripts src tests samples
+SUBDIRS = dist doc include samples scripts src
+if WITH_TESTS
+SUBDIRS += tests
+endif
 
 EXTRA_DIST = README_daemon libcgroup.doxyfile README_systemd CONTRIBUTING.md
 
index 522168070dc0f933218e76d8a161106f33463eb8..b68c655e84e2538fb7cedb282197e5f1d6f986ab 100644 (file)
@@ -134,6 +134,18 @@ AC_ARG_ENABLE([opaque-hierarchy],
                fi
        ], [])
 
+AC_ARG_ENABLE([tests],
+      [AS_HELP_STRING([--enable-tests],[compile libcgroup tests [default=yes]])],
+      [
+               if test "x$enableval" == xno; then
+                       with_tests=false
+               else
+                       with_tests=true
+               fi
+       ],
+       [with_tests=true])
+AM_CONDITIONAL([WITH_TESTS], [test x$with_tests = xtrue])
+
 # Checks for programs.
 AC_PROG_CXX
 AC_PROG_CC
@@ -198,9 +210,6 @@ fi
 AX_CODE_COVERAGE
 
 AC_CONFIG_FILES([Makefile
-       tests/Makefile
-       tests/ftests/Makefile
-       tests/gunit/Makefile
        src/Makefile
        src/daemon/Makefile
        src/tools/Makefile
@@ -218,6 +227,10 @@ AC_CONFIG_FILES([Makefile
        doc/man/Makefile
        dist/Makefile
        libcgroup.pc])
+AM_COND_IF([WITH_TESTS],
+       [AC_CONFIG_FILES([tests/Makefile
+               tests/ftests/Makefile
+               tests/gunit/Makefile])])
 AC_CONFIG_FILES([dist/libcgroup.spec:dist/libcgroup.spec.in])
 CFLAGS="$CFLAGS -Wall"
 AC_OUTPUT