Skip to content

Commit a2a9cf4

Browse files
drakenclimberkamalesh-babulal
authored andcommitted
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 <tom.hromatka@oracle.com> Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
1 parent 1ef551e commit a2a9cf4

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,13 @@ jobs:
104104
submodules: false
105105
- name: Initialize the directory
106106
uses: ./.github/actions/setup-libcgroup
107+
- name: Reconfigure libcgroup with unit tests enabled
108+
run: CFLAGS="$CFLAGS -Werror" ./configure --sysconfdir=/etc --localstatedir=/var --enable-code-coverage --enable-opaque-hierarchy="name=systemd" --enable-python --enable-unittests
107109
- name: Run unit tests
108110
run: |
109111
pushd tests/gunit
110112
make check
111113
popd
112-
- name: Display test logs
113-
if: ${{ always() }}
114-
run: cat tests/gunit/test-suite.log
115114
- name: Collate code coverage results
116115
uses: ./.github/actions/code-coverage
117116
- name: Upload code coverage results

configure.ac

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,18 @@ AC_ARG_ENABLE([samples],
170170
[with_samples=false])
171171
AM_CONDITIONAL([WITH_SAMPLES], [test x$with_samples = xtrue])
172172

173+
AC_ARG_ENABLE([unittests],
174+
[AS_HELP_STRING([--enable-unittests],[compile libcgroup unit tests [default=no]])],
175+
[
176+
if test "x$enableval" = xno; then
177+
with_unittests=false
178+
else
179+
with_unittests=true
180+
fi
181+
],
182+
[with_unittests=false])
183+
AM_CONDITIONAL([WITH_UNITTESTS], [test x$with_unittests = xtrue])
184+
173185
# Checks for programs.
174186
AC_PROG_CXX
175187
AC_PROG_CC

tests/gunit/Makefile.am

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
#
33
# libcgroup googletests Makefile.am
44
#
5-
# Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
5+
# Copyright (c) 2019-2025 Oracle and/or its affiliates.
66
# Author: Tom Hromatka <tom.hromatka@oracle.com>
77
#
88

9+
if WITH_UNITTESTS
10+
911
AM_CPPFLAGS = -I$(top_srcdir)/include \
1012
-I$(top_srcdir)/src \
1113
-I$(top_srcdir)/src/tools \
@@ -51,3 +53,5 @@ gtest_LDFLAGS = -L$(top_srcdir)/googletest/build/lib -l:libgtest.a \
5153

5254
clean-local:
5355
${RM} test-procpidcgroup
56+
57+
endif

0 commit comments

Comments
 (0)