Add a configure option to enable/disable the unit tests. Because of their
dependency upon googletest, they're very difficult to run for distros.
This allows them to packaged with libcgroup, but they are disabled by
default. They can be enabled via the config option `--enable-unittests`.
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
submodules: false
- name: Initialize the directory
uses: ./.github/actions/setup-libcgroup
+ - name: Reconfigure libcgroup with unit tests enabled
+ run: CFLAGS="$CFLAGS -Werror" ./configure --sysconfdir=/etc --localstatedir=/var --enable-code-coverage --enable-opaque-hierarchy="name=systemd" --enable-python --enable-unittests
- name: Run unit tests
run: |
pushd tests/gunit
make check
popd
- - name: Display test logs
- if: ${{ always() }}
- run: cat tests/gunit/test-suite.log
- name: Collate code coverage results
uses: ./.github/actions/code-coverage
- name: Upload code coverage results
[with_samples=false])
AM_CONDITIONAL([WITH_SAMPLES], [test x$with_samples = xtrue])
+AC_ARG_ENABLE([unittests],
+ [AS_HELP_STRING([--enable-unittests],[compile libcgroup unit tests [default=no]])],
+ [
+ if test "x$enableval" = xno; then
+ with_unittests=false
+ else
+ with_unittests=true
+ fi
+ ],
+ [with_unittests=false])
+AM_CONDITIONAL([WITH_UNITTESTS], [test x$with_unittests = xtrue])
+
# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
#
# libcgroup googletests Makefile.am
#
-# Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2019-2025 Oracle and/or its affiliates.
# Author: Tom Hromatka <tom.hromatka@oracle.com>
#
+if WITH_UNITTESTS
+
AM_CPPFLAGS = -I$(top_srcdir)/include \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/tools \
clean-local:
${RM} test-procpidcgroup
+
+endif