Allow building with unit tests for future upstream contributions

This commit is contained in:
Martin Osvald 2024-03-26 11:07:07 +01:00
parent 922b35932c
commit 9fcf15fc73
2 changed files with 51 additions and 6 deletions

30
kea-gtest.patch Normal file
View File

@ -0,0 +1,30 @@
diff --git a/m4macros/ax_gtest.m4 b/m4macros/ax_gtest.m4
index 2681b43..852fd2a 100644
--- a/m4macros/ax_gtest.m4
+++ b/m4macros/ax_gtest.m4
@@ -136,9 +136,9 @@ if test "x$enable_gtest" = "xyes" ; then
for dir in $GTEST_PATHS; do
if test -f "$dir/include/gtest/gtest.h"; then
if test -f "$dir/lib/libgtest.a" || \
- test -f "$dir/lib/libgtest.so"; then
+ test -f "$dir/lib64/libgtest.so"; then
GTEST_INCLUDES="-I$dir/include"
- GTEST_LDFLAGS="-L$dir/lib"
+ GTEST_LDFLAGS="-L$dir/lib64"
GTEST_LDADD="-lgtest"
GTEST_FOUND="true"
break
diff --git a/src/lib/util/tests/pid_file_unittest.cc b/src/lib/util/tests/pid_file_unittest.cc
index 5f00d72..583a35b 100644
--- a/src/lib/util/tests/pid_file_unittest.cc
+++ b/src/lib/util/tests/pid_file_unittest.cc
@@ -181,7 +181,8 @@ TEST_F(PIDFileTest, pidGarbage) {
}
/// @brief Test failing to write a file.
-TEST_F(PIDFileTest, pidWriteFail) {
+/// Fails to fail for root, it doesn't throw PIDFileError exception.
+TEST_F(PIDFileTest, DISABLED_pidWriteFail) {
PIDFile pid_file(absolutePath(TESTNAME));
// Create the test file and change it's permission bits

View File

@ -1,5 +1,6 @@
# TODO: no support for netconf/sysconf yet
%global sysrepo 0
%bcond_with sysrepo
%bcond_with gtest
#%%global prever P1
%global keama_version 4.5.0
@ -25,6 +26,7 @@ Source14: kea-ctrl-agent.service
Source15: kea-tmpfiles.d.conf
Patch1: kea-openssl-version.patch
Patch2: kea-gtest.patch
# autoreconf
BuildRequires: autoconf automake libtool
@ -45,7 +47,7 @@ BuildRequires: mariadb-devel
BuildRequires: postgresql-devel
%endif
BuildRequires: log4cplus-devel
%if %{sysrepo}
%if %{with sysrepo}
# %%configure --with-sysrepo
BuildRequires: sysrepo-devel
%endif
@ -55,6 +57,10 @@ BuildRequires: valgrind-devel
%endif
# src/lib/testutils/dhcp_test_lib.sh
BuildRequires: procps-ng
%if %{with gtest}
# %%configure --enable-gtest
BuildRequires: gtest-devel
%endif
# %%configure --enable-generate-parser
BuildRequires: bison
BuildRequires: flex
@ -136,6 +142,7 @@ ISC DHCP configurations to Kea.
%autosetup -T -b2 -N -n keama-%{keama_version}
%autosetup -p1 -n kea-%{version}%{?prever:-%{prever}}
rm -rf doc/sphinx/_build
# to be able to build on ppc64(le)
@ -157,11 +164,14 @@ autoreconf --verbose --force --install
--enable-generate-docs \
--enable-generate-messages \
--enable-perfdhcp \
%if %{with gtest}
--with-gtest \
%endif
--with-mysql \
--with-pgsql \
--with-gnu-ld \
--with-log4cplus \
%if %{sysrepo}
%if %{with sysrepo}
--with-sysrepo \
%endif
--with-openssl
@ -178,6 +188,12 @@ pushd ../keama-%{keama_version}
popd
%if %{with gtest}
%check
make check
%endif
%install
%make_install docdir=%{_pkgdocdir}
@ -194,7 +210,7 @@ rm -rf %{buildroot}%{_mandir}/man5/
# Get rid of .la files
find %{buildroot} -type f -name "*.la" -delete -print
%if !%{sysrepo}
%if %{without sysrepo}
# Remove netconf files
rm %{buildroot}%{_mandir}/man8/kea-netconf.8
%endif
@ -228,7 +244,6 @@ install -Dpm 0644 %{S:15} %{buildroot}%{_tmpfilesdir}/kea.conf
%postun
%systemd_postun_with_restart kea-dhcp4.service kea-dhcp6.service kea-dhcp-ddns.service kea-ctrl-agent.service
%ldconfig_scriptlets libs
@ -257,7 +272,7 @@ install -Dpm 0644 %{S:15} %{buildroot}%{_tmpfilesdir}/kea.conf
%{_mandir}/man8/kea-dhcp4.8*
%{_mandir}/man8/kea-dhcp6.8*
%{_mandir}/man8/kea-lfc.8*
%if %{sysrepo}
%if %{with sysrepo}
%{_mandir}/man8/kea-netconf.8*
%endif
%{_mandir}/man8/kea-shell.8*