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 <miguelcompany@eprosima.com>

* Refs #20652. Correctly combine blackbox filters.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20652. Fix filter on participant test.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

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

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20652. Fix typo.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20652. Fix filter in LocatorTests.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20652. Filter with grep in mac.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20652. Improve status messages.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

---------

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
(cherry picked from commit 7a77988)

# Conflicts:
#	cmake/common/gtest.cmake
#	test/CMakeLists.txt
#	test/blackbox/CMakeLists.txt
#	test/unittest/dds/participant/CMakeLists.txt
#	test/unittest/utils/CMakeLists.txt
  • Loading branch information
MiguelCompany authored and mergify[bot] committed Apr 7, 2024
1 parent 4e3e0eb commit 4f4fb28
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 1 deletion.
11 changes: 11 additions & 0 deletions cmake/common/gtest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,18 @@ macro(add_gtest)
endforeach()
endforeach()
else()
<<<<<<< HEAD
add_test(NAME ${test} COMMAND ${command})
=======

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

add_test(NAME ${test} COMMAND ${command} ${gtest_filter})
>>>>>>> 7a77988a3 (Fix test filtering in CMake files (#4650))

# Add environment
set(GTEST_ENVIRONMENT "")
Expand Down
18 changes: 18 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ endif()
file(TO_CMAKE_PATH "${PROJECT_SOURCE_DIR}/valgrind.supp" MEMORYCHECK_SUPPRESSIONS_FILE_TMP)
set(MEMORYCHECK_SUPPRESSIONS_FILE ${MEMORYCHECK_SUPPRESSIONS_FILE_TMP} CACHE FILEPATH "Valgrind suppresions file")

<<<<<<< HEAD
=======
# Check if /etc/hosts file has been modified to add dummy host test subjects
if(WIN32)
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)
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()
message(STATUS "EPROSIMA_TEST_DNS_NOT_SET_UP: '${EPROSIMA_TEST_DNS_NOT_SET_UP}'")

>>>>>>> 7a77988a3 (Fix test filtering in CMake files (#4650))
###############################################################################
# Testing
###############################################################################
Expand Down
20 changes: 19 additions & 1 deletion test/blackbox/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,12 @@ macro(add_blackbox_gtest)

# add filtering statement if required
if(GTEST_IGNORE)
<<<<<<< HEAD
set(command "${command} --gtest_filter=${GTEST_IGNORE}")
=======
list(JOIN GTEST_IGNORE ":" gtest_filter)
string(PREPEND gtest_filter "--gtest_filter=-")
>>>>>>> 7a77988a3 (Fix test filtering in CMake files (#4650))
endif()

add_test(NAME ${test} COMMAND ${command})
Expand Down Expand Up @@ -230,10 +235,23 @@ 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

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

>>>>>>> 7a77988a3 (Fix test filtering in CMake files (#4650))
if(SECURITY)
configure_file(${PROJECT_SOURCE_DIR}/test/certs/maincacert.pem
${CMAKE_CURRENT_BINARY_DIR}/maincacert.pem COPYONLY)
Expand Down
16 changes: 16 additions & 0 deletions test/unittest/dds/participant/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,20 @@ target_include_directories(ParticipantTests PRIVATE
target_link_libraries(ParticipantTests fastrtps fastcdr foonathan_memory
GTest::gmock
${CMAKE_DL_LIBS})
<<<<<<< HEAD
add_gtest(ParticipantTests SOURCES ${PARTICIPANTTESTS_SOURCE})
=======

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

add_gtest(ParticipantTests SOURCES ${PARTICIPANTTESTS_SOURCE} IGNORE ${dns_filter})

unset(dns_filter)

if(ANDROID)
set_property(TARGET ParticipantTests PROPERTY CROSSCOMPILING_EMULATOR "adb;shell;cd;${CMAKE_CURRENT_BINARY_DIR};&&")
endif()
>>>>>>> 7a77988a3 (Fix test filtering in CMake files (#4650))
12 changes: 12 additions & 0 deletions test/unittest/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ target_compile_definitions(LocatorTests PRIVATE
target_include_directories(LocatorTests PRIVATE
${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${Asio_INCLUDE_DIR})
target_link_libraries(LocatorTests GTest::gtest ${MOCKS})
<<<<<<< HEAD
add_gtest(LocatorTests SOURCES ${LOCATORTESTS_SOURCE})
# Skip DNS related tests when not running on our CI
if(NOT(EPROSIMA_BUILD))
Expand All @@ -116,6 +117,17 @@ if(NOT(EPROSIMA_BUILD))
LocatorDNSTests
)
endif()
=======
if(QNX)
target_link_libraries(LocatorTests socket)
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)
>>>>>>> 7a77988a3 (Fix test filtering in CMake files (#4650))


add_executable(FixedSizeQueueTests ${FIXEDSIZEQUEUETESTS_SOURCE})
Expand Down

0 comments on commit 4f4fb28

Please sign in to comment.