From: Tom Hromatka Date: Tue, 8 Apr 2025 23:19:40 +0000 (-0600) Subject: github: dist: Rework the unit tests X-Git-Tag: v3.2.0^0 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=565c13c49e4511daefa75fb00a6b8695e903019b;p=thirdparty%2Flibcgroup.git github: dist: Rework the unit tests 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 Signed-off-by: Kamalesh Babulal --- diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index c93960a4..42c8eab5 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -104,14 +104,13 @@ jobs: 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 diff --git a/configure.ac b/configure.ac index 91efade8..849c0da9 100644 --- a/configure.ac +++ b/configure.ac @@ -170,6 +170,18 @@ AC_ARG_ENABLE([samples], [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 diff --git a/tests/gunit/Makefile.am b/tests/gunit/Makefile.am index 18c634d0..ef24feed 100644 --- a/tests/gunit/Makefile.am +++ b/tests/gunit/Makefile.am @@ -2,10 +2,12 @@ # # 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 # +if WITH_UNITTESTS + AM_CPPFLAGS = -I$(top_srcdir)/include \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/tools \ @@ -51,3 +53,5 @@ gtest_LDFLAGS = -L$(top_srcdir)/googletest/build/lib -l:libgtest.a \ clean-local: ${RM} test-procpidcgroup + +endif