cmake: mark testkdb_allplugins as "memleak" if ENABLE_DEBUG=OFF
The memcheck test for allplugins fails on Ubuntu Bionic, Debian Buster and Debian Bullseye if ENABLE_DEBUG="OFF". Therefore testkdb_allplugins gets marked "memleak" if ENABLE_DEBUG="OFF"
@@ -61,6 +61,7 @@ function (check_xcode)
endfunction (check_xcode)
function (add_kdb_test suffix)
+ set (options "MEMLEAK")
set (multiValueArgs "REQUIRED_PLUGINS;LINK_ELEKTRA")
cmake_parse_arguments (ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
@@ -72,7 +73,10 @@ function (add_kdb_test suffix)
endforeach (plugin ${ARG_REQUIRED_PLUGINS})
set (name testkdb_${suffix})
- add_gtest (${name} KDBTESTS LINK_TOOLS LINK_ELEKTRA ${ARG_LINK_ELEKTRA})
+ if (ARG_MEMLEAK)
+ set (GTEST_OPTIONS "MEMLEAK")
+ endif (ARG_MEMLEAK)
+ add_gtest (${name} ${GTEST_OPTIONS} KDBTESTS LINK_TOOLS LINK_ELEKTRA ${ARG_LINK_ELEKTRA})
endfunction (add_kdb_test suffix)
if (CMAKE_SYSTEM_NAME MATCHES FreeBSD)
@@ -89,7 +93,16 @@ if (FEDORA AND ENABLE_ASAN)
# - https://issues.libelektra.org/3572
message (STATUS "Exclude KDB plugin test because it fails when ASAN is enabled")
else (FEDORA AND ENABLE_ASAN)
- add_kdb_test (allplugins)
+ if (NOT ENABLE_DEBUG)
+ # The memcheck test for allplugins fails on Ubuntu Bionic, Debian Buster and Debian Bullseye if ENABLE_DEBUG="OFF".
+ #
+ # See also:
+ #
+ # - https://github.com/ElektraInitiative/libelektra/pull/3855
+ # - https://github.com/ElektraInitiative/libelektra/pull/3530
+ set (KDB_TEST_ARGS "MEMLEAK")
+ endif (ENABLE_DEBUG)
+ add_kdb_test (allplugins ${KDB_TEST_ARGS})
endif (FEDORA AND ENABLE_ASAN)
add_kdb_test (conflict REQUIRED_PLUGINS error)
