Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[20652] Fix test filtering in CMake files #4650

Merged
merged 8 commits into from
Apr 7, 2024
3 changes: 2 additions & 1 deletion cmake/common/gtest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ macro(add_gtest)

# add filtering statement if required
if(GTEST_IGNORE)
set(gtest_filter "--gtest_filter=${GTEST_IGNORE}")
list(JOIN GTEST_IGNORE ":" gtest_filter)
string(PREPEND gtest_filter "--gtest_filter=-")
endif()

add_test(NAME ${test} COMMAND ${command} ${gtest_filter})
Expand Down
12 changes: 9 additions & 3 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,18 @@ set(MEMORYCHECK_SUPPRESSIONS_FILE ${MEMORYCHECK_SUPPRESSIONS_FILE_TMP} CACHE FIL

# Check if /etc/hosts file has been modified to add dummy host test subjects
if(WIN32)
execute_process(COMMAND powershell -C Resolve-DNSName www.acme.com.test
execute_process(COMMAND powershell -C Resolve-DNSName -Name www.acme.com.test -CacheOnly
RESULT_VARIABLE EPROSIMA_TEST_DNS_NOT_SET_UP OUTPUT_QUIET ERROR_QUIET)
else(WIN32)
elseif(APPLE)
execute_process(
COMMAND dscacheutil -q host -a name www.acme.com.test
COMMAND grep www.acme.com.test
RESULT_VARIABLE EPROSIMA_TEST_DNS_NOT_SET_UP OUTPUT_QUIET ERROR_QUIET)
else()
execute_process(COMMAND getent hosts www.acme.com.test
RESULT_VARIABLE EPROSIMA_TEST_DNS_NOT_SET_UP OUTPUT_QUIET ERROR_QUIET)
endif(WIN32)
endif()
message(STATUS "EPROSIMA_TEST_DNS_NOT_SET_UP: '${EPROSIMA_TEST_DNS_NOT_SET_UP}'")

###############################################################################
# Testing
Expand Down
13 changes: 10 additions & 3 deletions test/blackbox/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ macro(add_blackbox_gtest)

# add filtering statement if required
if(GTEST_IGNORE)
set(gtest_filter "--gtest_filter=${GTEST_IGNORE}")
list(JOIN GTEST_IGNORE ":" gtest_filter)
string(PREPEND gtest_filter "--gtest_filter=-")
endif()

add_test(NAME ${test} COMMAND ${command} ${gtest_filter})
Expand Down Expand Up @@ -232,12 +233,18 @@ if(NOT LibP11_FOUND)
if(GTEST_INDIVIDUAL)
set(pkcs_filter "[Pp][Kk][Cc][Ss]")
else()
set(pkcs_filter "-*pkcs*")
set(pkcs_filter "*pkcs*")
endif() # GTEST_INDIVIDUAL
message(STATUS "Ignoring tests: '${pkcs_filter}'")
endif() # LibP11_FOUND

if(EPROSIMA_TEST_DNS_NOT_SET_UP)
set(dns_filter "-*ServerClientEnvironmentSetUpDNS*")
if(GTEST_INDIVIDUAL)
set(dns_filter "ServerClientEnvironmentSetUpDNS")
else()
set(dns_filter "*ServerClientEnvironmentSetUpDNS*")
endif() # GTEST_INDIVIDUAL
message(STATUS "Ignoring tests: '${dns_filter}'")
endif()

if(SECURITY)
Expand Down
3 changes: 2 additions & 1 deletion test/unittest/dds/participant/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ target_link_libraries(ParticipantTests fastrtps fastcdr foonathan_memory
${CMAKE_DL_LIBS})

if(EPROSIMA_TEST_DNS_NOT_SET_UP)
set(dns_filter "-ParticipantTests.SimpleParticipantRemoteServerListConfigurationDNS")
set(dns_filter "ParticipantTests.SimpleParticipantRemoteServerListConfigurationDNS")
message(STATUS "Ignoring tests: '${dns_filter}'")
endif()

add_gtest(ParticipantTests SOURCES ${PARTICIPANTTESTS_SOURCE} IGNORE ${dns_filter})
Expand Down
9 changes: 1 addition & 8 deletions test/unittest/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,10 @@ if(QNX)
endif()
if(EPROSIMA_TEST_DNS_NOT_SET_UP)
set(IGNORE_COMMAND LocatorDNSTests)
message(STATUS "Ignoring tests: '${IGNORE_COMMAND}'")
endif()
add_gtest(LocatorTests SOURCES ${LOCATORTESTS_SOURCE} IGNORE ${IGNORE_COMMAND})
unset(IGNORE_COMMAND)
# Skip DNS related tests when not running on our CI
if(NOT(EPROSIMA_BUILD))
message(STATUS "Ignoring DNS tests")
set(CTEST_CUSTOM_TESTS_IGNORE
${CTEST_CUSTOM_TESTS_IGNORE}
LocatorDNSTests
)
endif()

add_executable(FixedSizeQueueTests ${FIXEDSIZEQUEUETESTS_SOURCE})
target_include_directories(FixedSizeQueueTests PRIVATE
Expand Down
Loading