Skip to content

Commit

Permalink
Fix test filtering in CMake files (#4650)
Browse files Browse the repository at this point in the history
* Refs #20652. Fix windows command to check local DNS name.

Signed-off-by: Miguel Company <[email protected]>

* Refs #20652. Correctly combine blackbox filters.

Signed-off-by: Miguel Company <[email protected]>

* Refs #20652. Fix filter on participant test.

Signed-off-by: Miguel Company <[email protected]>

* Refs #20652. Use correct command on Apple to check local DNS name.

Signed-off-by: Miguel Company <[email protected]>

* Refs #20652. Fix typo.

Signed-off-by: Miguel Company <[email protected]>

* Refs #20652. Fix filter in LocatorTests.

Signed-off-by: Miguel Company <[email protected]>

* Refs #20652. Filter with grep in mac.

Signed-off-by: Miguel Company <[email protected]>

* Refs #20652. Improve status messages.

Signed-off-by: Miguel Company <[email protected]>

---------

Signed-off-by: Miguel Company <[email protected]>
  • Loading branch information
MiguelCompany authored Apr 7, 2024
1 parent b24a381 commit 7a77988
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
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

0 comments on commit 7a77988

Please sign in to comment.