From dd67d5e21fc06d489f3b5a0a3e3cdd2742ee2c7a Mon Sep 17 00:00:00 2001 From: Tyler Mayoff Date: Thu, 19 Oct 2023 08:48:21 -0400 Subject: [PATCH 01/24] added char_literals test to cmake --- CMakeLists.txt | 1 + .../Compiler/char_literals/CMakeLists.txt | 43 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 tests/DCPS/Compiler/char_literals/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 7fe8242e752..5077ccc3fa7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -143,6 +143,7 @@ if(OPENDDS_BUILD_TESTS) endif() add_subdirectory(tests/cmake/idl_compiler_tests) add_subdirectory(tests/cmake/include_subdir) + add_subdirectory(tests/DCPS/Compiler/char_literals) # TODO: This test always builds shared libraries and linker complains about # ACE/TAO libs lacking -fPIC when ACE is static. if(OPENDDS_OWNERSHIP_PROFILE AND NOT OPENDDS_STATIC) diff --git a/tests/DCPS/Compiler/char_literals/CMakeLists.txt b/tests/DCPS/Compiler/char_literals/CMakeLists.txt new file mode 100644 index 00000000000..2c3b01d912b --- /dev/null +++ b/tests/DCPS/Compiler/char_literals/CMakeLists.txt @@ -0,0 +1,43 @@ +cmake_minimum_required(VERSION 3.8...3.27) +project(compiler_char_literals CXX) +enable_testing() + +find_package(OpenDDS REQUIRED) +include(opendds_testing) + +set(target_prefix "${PROJECT_NAME}_") +set(src "${CMAKE_CURRENT_SOURCE_DIR}") +set(dst ${CMAKE_CURRENT_BINARY_DIR}) +set(opendds_libs + OpenDDS::Dcps + gtest +) + +# IDL Library +set(idl "${target_prefix}idl") +add_library(${idl}) +opendds_target_sources(${idl} PUBLIC "${src}/test.idl" OPENDDS_IDL_OPTIONS "-Lc++11") +target_link_libraries(${idl} PUBLIC OpenDDS::Dcps) +set(idl_dir "${dst}") +set_target_properties(${idl} PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${idl_dir}" + LIBRARY_OUTPUT_DIRECTORY "${idl_dir}" +) + +# Assert the mapping used was C++11 +get_property(mappings TARGET ${idl} PROPERTY OPENDDS_LANGUAGE_MAPPINGS) +if(NOT ("C++11" IN_LIST mappings)) + message(FATAL_ERROR "${idl}: C++11 NOT in mapping list: ${mappings}") +endif() + +set(char_literals_test "${target_prefix}test") +add_executable(char_literals_exe + "${src}/main.cpp" +) +set_target_properties(char_literals_exe PROPERTIES + # OUTPUT_NAME ${maps_test} + RUNTIME_OUTPUT_DIRECTORY "${dst}" +) +target_link_libraries(char_literals_exe ${opendds_libs} ${idl}) + +add_test(char_literals_test char_literals_exe) From 4eb9d81e6dbeeb3b047c155633c7870d97396486 Mon Sep 17 00:00:00 2001 From: Tyler Mayoff Date: Thu, 19 Oct 2023 10:34:46 -0400 Subject: [PATCH 02/24] Added gtest --- CMakeLists.txt | 6 ++++++ tests/DCPS/Compiler/char_literals/CMakeLists.txt | 13 +++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5077ccc3fa7..8b347cd283c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -137,6 +137,12 @@ if(OPENDDS_BUILD_EXAMPLES OR OPENDDS_BUILD_TESTS) add_subdirectory(DevGuideExamples/DCPS/Messenger) endif() if(OPENDDS_BUILD_TESTS) + find_package(GTest QUIET) + if (NOT GTest_FOUND) + message("GTest not found, falling back to local copy") + add_subdirectory(tests/googletest) + endif() + add_subdirectory(tests/cmake/ace_tao_only) if(OPENDDS_OWNERSHIP_PROFILE) add_subdirectory(tests/cmake/Messenger) diff --git a/tests/DCPS/Compiler/char_literals/CMakeLists.txt b/tests/DCPS/Compiler/char_literals/CMakeLists.txt index 2c3b01d912b..c8eae06e1eb 100644 --- a/tests/DCPS/Compiler/char_literals/CMakeLists.txt +++ b/tests/DCPS/Compiler/char_literals/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.8...3.27) -project(compiler_char_literals CXX) +project(opendds_compiler_char_literals CXX) enable_testing() find_package(OpenDDS REQUIRED) @@ -10,7 +10,6 @@ set(src "${CMAKE_CURRENT_SOURCE_DIR}") set(dst ${CMAKE_CURRENT_BINARY_DIR}) set(opendds_libs OpenDDS::Dcps - gtest ) # IDL Library @@ -30,14 +29,12 @@ if(NOT ("C++11" IN_LIST mappings)) message(FATAL_ERROR "${idl}: C++11 NOT in mapping list: ${mappings}") endif() -set(char_literals_test "${target_prefix}test") -add_executable(char_literals_exe +add_executable(opendds_compiler_char_literals_exe "${src}/main.cpp" ) -set_target_properties(char_literals_exe PROPERTIES - # OUTPUT_NAME ${maps_test} +set_target_properties(opendds_compiler_char_literals_exe PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${dst}" ) -target_link_libraries(char_literals_exe ${opendds_libs} ${idl}) +target_link_libraries(opendds_compiler_char_literals_exe ${opendds_libs} ${idl} gtest) -add_test(char_literals_test char_literals_exe) +add_test(opendds_compiler_char_literals_test opendds_compiler_char_literals_exe) From 22228718232bf1e0e0c64d6a1be5785eb26233bf Mon Sep 17 00:00:00 2001 From: Tyler Mayoff Date: Thu, 19 Oct 2023 10:36:47 -0400 Subject: [PATCH 03/24] fixed lint --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b347cd283c..cf333ccebcd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,7 +138,7 @@ if(OPENDDS_BUILD_EXAMPLES OR OPENDDS_BUILD_TESTS) endif() if(OPENDDS_BUILD_TESTS) find_package(GTest QUIET) - if (NOT GTest_FOUND) + if(NOT GTest_FOUND) message("GTest not found, falling back to local copy") add_subdirectory(tests/googletest) endif() From 1f78f6db8ff874bab7ef1ab2aa2f981de9638630 Mon Sep 17 00:00:00 2001 From: Tyler Mayoff Date: Thu, 19 Oct 2023 15:29:07 -0400 Subject: [PATCH 04/24] print test output on failure --- .github/workflows/build_and_test.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index d90270efce9..d5535f1f6fc 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -12712,7 +12712,7 @@ jobs: - name: Run Tests run: | cd OpenDDS/build - ctest + ctets --output-on-failure build_cmake_u22_stat: @@ -12753,7 +12753,7 @@ jobs: - name: Run Tests run: | cd OpenDDS/build - ctest + ctets --output-on-failure build_cmake_u22_no_features: @@ -12802,7 +12802,7 @@ jobs: - name: Run Tests run: | cd OpenDDS/build - ctest + ctets --output-on-failure build_cmake_u22_android29: @@ -12924,7 +12924,7 @@ jobs: shell: cmd run: | cd OpenDDS\build - ctest -C Debug + ctets --output-on-failure -C Debug build_cmake_w22_stat: @@ -12970,4 +12970,4 @@ jobs: shell: cmd run: | cd OpenDDS\build - ctest -C Debug + ctets --output-on-failure -C Debug From 90b55d771eda4c7c0b824e829e553e30a02bde42 Mon Sep 17 00:00:00 2001 From: Tyler Mayoff Date: Thu, 19 Oct 2023 15:50:18 -0400 Subject: [PATCH 05/24] fixed typo --- .github/workflows/build_and_test.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index d5535f1f6fc..6926cbf17b3 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -12712,7 +12712,7 @@ jobs: - name: Run Tests run: | cd OpenDDS/build - ctets --output-on-failure + ctest --output-on-failure build_cmake_u22_stat: @@ -12753,7 +12753,7 @@ jobs: - name: Run Tests run: | cd OpenDDS/build - ctets --output-on-failure + ctest --output-on-failure build_cmake_u22_no_features: @@ -12802,7 +12802,7 @@ jobs: - name: Run Tests run: | cd OpenDDS/build - ctets --output-on-failure + ctest --output-on-failure build_cmake_u22_android29: @@ -12924,7 +12924,7 @@ jobs: shell: cmd run: | cd OpenDDS\build - ctets --output-on-failure -C Debug + ctest --output-on-failure -C Debug build_cmake_w22_stat: @@ -12970,4 +12970,4 @@ jobs: shell: cmd run: | cd OpenDDS\build - ctets --output-on-failure -C Debug + ctest --output-on-failure -C Debug From 23ac6430d71f39fe2fa921e52eb3fcb0e977d867 Mon Sep 17 00:00:00 2001 From: Tyler Mayoff Date: Thu, 19 Oct 2023 16:56:07 -0400 Subject: [PATCH 06/24] explicitly link to TAO? --- tests/DCPS/Compiler/char_literals/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/DCPS/Compiler/char_literals/CMakeLists.txt b/tests/DCPS/Compiler/char_literals/CMakeLists.txt index c8eae06e1eb..ec55a301fdc 100644 --- a/tests/DCPS/Compiler/char_literals/CMakeLists.txt +++ b/tests/DCPS/Compiler/char_literals/CMakeLists.txt @@ -10,6 +10,7 @@ set(src "${CMAKE_CURRENT_SOURCE_DIR}") set(dst ${CMAKE_CURRENT_BINARY_DIR}) set(opendds_libs OpenDDS::Dcps + TAO::TAO ) # IDL Library From cbf3c87c7b33b5e5789aeabbd244021a73515d78 Mon Sep 17 00:00:00 2001 From: Tyler Mayoff Date: Thu, 19 Oct 2023 20:57:35 -0400 Subject: [PATCH 07/24] link with TAO_AnyTypeCode? --- tests/DCPS/Compiler/char_literals/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/DCPS/Compiler/char_literals/CMakeLists.txt b/tests/DCPS/Compiler/char_literals/CMakeLists.txt index ec55a301fdc..053d26997ab 100644 --- a/tests/DCPS/Compiler/char_literals/CMakeLists.txt +++ b/tests/DCPS/Compiler/char_literals/CMakeLists.txt @@ -10,7 +10,7 @@ set(src "${CMAKE_CURRENT_SOURCE_DIR}") set(dst ${CMAKE_CURRENT_BINARY_DIR}) set(opendds_libs OpenDDS::Dcps - TAO::TAO + TAO::AnyTypeCode ) # IDL Library From a202d9174963372fb6cdf918f5b3ff4f8f1e9ce6 Mon Sep 17 00:00:00 2001 From: Tyler Mayoff Date: Thu, 19 Oct 2023 21:26:46 -0400 Subject: [PATCH 08/24] removed AnyTypeCode --- tests/DCPS/Compiler/char_literals/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/DCPS/Compiler/char_literals/CMakeLists.txt b/tests/DCPS/Compiler/char_literals/CMakeLists.txt index 053d26997ab..c8eae06e1eb 100644 --- a/tests/DCPS/Compiler/char_literals/CMakeLists.txt +++ b/tests/DCPS/Compiler/char_literals/CMakeLists.txt @@ -10,7 +10,6 @@ set(src "${CMAKE_CURRENT_SOURCE_DIR}") set(dst ${CMAKE_CURRENT_BINARY_DIR}) set(opendds_libs OpenDDS::Dcps - TAO::AnyTypeCode ) # IDL Library From 099fdf76d8caf607bc0d4434a649c5c3762163f7 Mon Sep 17 00:00:00 2001 From: Tyler Mayoff Date: Sat, 21 Oct 2023 12:46:44 -0400 Subject: [PATCH 09/24] Add HelloWorld test --- CMakeLists.txt | 1 + tests/DCPS/HelloWorld/CMakeLists.txt | 41 ++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 tests/DCPS/HelloWorld/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index cf333ccebcd..ad5d1cfc45e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,6 +150,7 @@ if(OPENDDS_BUILD_TESTS) add_subdirectory(tests/cmake/idl_compiler_tests) add_subdirectory(tests/cmake/include_subdir) add_subdirectory(tests/DCPS/Compiler/char_literals) + add_subdirectory(tests/DCPS/HelloWorld) # TODO: This test always builds shared libraries and linker complains about # ACE/TAO libs lacking -fPIC when ACE is static. if(OPENDDS_OWNERSHIP_PROFILE AND NOT OPENDDS_STATIC) diff --git a/tests/DCPS/HelloWorld/CMakeLists.txt b/tests/DCPS/HelloWorld/CMakeLists.txt new file mode 100644 index 00000000000..2729ed8e65a --- /dev/null +++ b/tests/DCPS/HelloWorld/CMakeLists.txt @@ -0,0 +1,41 @@ +cmake_minimum_required(VERSION 3.3...3.27) +project(opendds_hello_world CXX) +enable_testing() + +find_package(OpenDDS REQUIRED) +include(opendds_testing) + +set(target_prefix "${PROJECT_NAME}_") + +# IDL TypeSupport Library +set(idl "${target_prefix}idl") +add_library(${idl}) +opendds_target_sources(${idl} PUBLIC "HelloWorld.idl") +target_link_libraries(${idl} PUBLIC OpenDDS::Dcps) + +set(opendds_libs + OpenDDS::Dcps # Core OpenDDS Library + OpenDDS::InfoRepoDiscovery OpenDDS::Tcp # For run_test.pl + OpenDDS::Rtps OpenDDS::Rtps_Udp # For run_test.pl --rtps + ${idl} +) + +# Publisher +set(publisher "${target_prefix}publisher") +add_executable(${publisher} + publisher.cpp +) +target_link_libraries(${publisher} ${opendds_libs}) + +# Subscriber +set(subscriber "${target_prefix}subscriber") +add_executable(${subscriber} + subscriber.cpp +) +target_link_libraries(${subscriber} ${opendds_libs}) + +# Testing +configure_file(run_test.pl . COPYONLY) +configure_file(rtps.ini . COPYONLY) +opendds_add_test(NAME info_repo COMMAND perl run_test.pl) +opendds_add_test(NAME rtps COMMAND perl run_test.pl --rtps) From b7124d542956ed89bcc1afe044745a1bce8f4b6e Mon Sep 17 00:00:00 2001 From: Tyler Mayoff Date: Tue, 24 Oct 2023 17:20:18 -0400 Subject: [PATCH 10/24] fixed char_literals test --- .../Compiler/char_literals/CMakeLists.txt | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/tests/DCPS/Compiler/char_literals/CMakeLists.txt b/tests/DCPS/Compiler/char_literals/CMakeLists.txt index c8eae06e1eb..2b68973cb3b 100644 --- a/tests/DCPS/Compiler/char_literals/CMakeLists.txt +++ b/tests/DCPS/Compiler/char_literals/CMakeLists.txt @@ -6,7 +6,6 @@ find_package(OpenDDS REQUIRED) include(opendds_testing) set(target_prefix "${PROJECT_NAME}_") -set(src "${CMAKE_CURRENT_SOURCE_DIR}") set(dst ${CMAKE_CURRENT_BINARY_DIR}) set(opendds_libs OpenDDS::Dcps @@ -15,26 +14,22 @@ set(opendds_libs # IDL Library set(idl "${target_prefix}idl") add_library(${idl}) -opendds_target_sources(${idl} PUBLIC "${src}/test.idl" OPENDDS_IDL_OPTIONS "-Lc++11") +opendds_target_sources(${idl} PUBLIC "test.idl" OPENDDS_IDL_OPTIONS "-Lc++11") target_link_libraries(${idl} PUBLIC OpenDDS::Dcps) -set(idl_dir "${dst}") +set(idl_dir "${dst}/cpp11") set_target_properties(${idl} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${idl_dir}" LIBRARY_OUTPUT_DIRECTORY "${idl_dir}" ) -# Assert the mapping used was C++11 -get_property(mappings TARGET ${idl} PROPERTY OPENDDS_LANGUAGE_MAPPINGS) -if(NOT ("C++11" IN_LIST mappings)) - message(FATAL_ERROR "${idl}: C++11 NOT in mapping list: ${mappings}") -endif() - add_executable(opendds_compiler_char_literals_exe - "${src}/main.cpp" + "main.cpp" ) set_target_properties(opendds_compiler_char_literals_exe PROPERTIES - RUNTIME_OUTPUT_DIRECTORY "${dst}" + OUTPUT_NAME char-literals-cpp11 + RUNTIME_OUTPUT_DIRECTORY "${dst}/cpp11" ) target_link_libraries(opendds_compiler_char_literals_exe ${opendds_libs} ${idl} gtest) -add_test(opendds_compiler_char_literals_test opendds_compiler_char_literals_exe) +configure_file(run_test.pl . COPYONLY) +opendds_add_test(COMMAND perl run_test.pl cpp11 EXTRA_LIB_DIRS "${idl_dir}") From 1790220faf6949615ee1e9990a4eda496de2944d Mon Sep 17 00:00:00 2001 From: Tyler Mayoff Date: Tue, 24 Oct 2023 20:10:23 -0400 Subject: [PATCH 11/24] fixed hello world test --- tests/DCPS/HelloWorld/CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/DCPS/HelloWorld/CMakeLists.txt b/tests/DCPS/HelloWorld/CMakeLists.txt index 2729ed8e65a..64c6f0de8ed 100644 --- a/tests/DCPS/HelloWorld/CMakeLists.txt +++ b/tests/DCPS/HelloWorld/CMakeLists.txt @@ -26,6 +26,9 @@ add_executable(${publisher} publisher.cpp ) target_link_libraries(${publisher} ${opendds_libs}) +set_target_properties(${publisher} PROPERTIES + OUTPUT_NAME publisher +) # Subscriber set(subscriber "${target_prefix}subscriber") @@ -33,9 +36,12 @@ add_executable(${subscriber} subscriber.cpp ) target_link_libraries(${subscriber} ${opendds_libs}) +set_target_properties(${subscriber} PROPERTIES + OUTPUT_NAME subscriber +) # Testing configure_file(run_test.pl . COPYONLY) configure_file(rtps.ini . COPYONLY) opendds_add_test(NAME info_repo COMMAND perl run_test.pl) -opendds_add_test(NAME rtps COMMAND perl run_test.pl --rtps) +opendds_add_test(NAME rtps COMMAND perl run_test.pl init=rtps.ini) From cd262f068419546922ed7d4fafd1722cc305b60d Mon Sep 17 00:00:00 2001 From: Tyler Mayoff Date: Tue, 31 Oct 2023 10:12:13 -0400 Subject: [PATCH 12/24] Try adding DDS_ROOT to tests env --- cmake/opendds_testing.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/opendds_testing.cmake b/cmake/opendds_testing.cmake index c2b2fe61368..45a52a6b0a4 100644 --- a/cmake/opendds_testing.cmake +++ b/cmake/opendds_testing.cmake @@ -20,7 +20,7 @@ function(opendds_add_test) list(APPEND arg_COMMAND ${arg_ARGS}) add_test(NAME "${test_name}" ${arg_UNPARSED_ARGUMENTS} COMMAND ${arg_COMMAND}) - set(env "ACE_ROOT=${ACE_ROOT}" "TAO_ROOT=${TAO_ROOT}") + set(env "ACE_ROOT=${ACE_ROOT}" "TAO_ROOT=${TAO_ROOT}" "DDS_ROOT=${DDS_ROOT}") if(MSVC) set(env_var_name PATH) From f92dccd14b9fef294c0f6598da939aa0c64a3a8c Mon Sep 17 00:00:00 2001 From: Tyler Mayoff Date: Wed, 8 Nov 2023 20:00:09 -0500 Subject: [PATCH 13/24] Build gtest as shared lib --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ad5d1cfc45e..08532b72e8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -140,6 +140,7 @@ if(OPENDDS_BUILD_TESTS) find_package(GTest QUIET) if(NOT GTest_FOUND) message("GTest not found, falling back to local copy") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGTEST_CREATE_SHARED_LIBRARY") add_subdirectory(tests/googletest) endif() From 04f333756d1bde5a5de791b822338ff17ca01bac Mon Sep 17 00:00:00 2001 From: Tyler Mayoff Date: Wed, 8 Nov 2023 21:18:57 -0500 Subject: [PATCH 14/24] fix for windows... maybe --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 08532b72e8e..e7ec0029f83 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -140,7 +140,9 @@ if(OPENDDS_BUILD_TESTS) find_package(GTest QUIET) if(NOT GTest_FOUND) message("GTest not found, falling back to local copy") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGTEST_CREATE_SHARED_LIBRARY") + # Prevent overriding the parent project's compiler/linker + # settings on Windows + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) add_subdirectory(tests/googletest) endif() From f596c0744def0aa607ac906e14a56aaa5ef127da Mon Sep 17 00:00:00 2001 From: Tyler Mayoff Date: Sat, 18 Nov 2023 16:49:27 -0500 Subject: [PATCH 15/24] try out gtest_discover_tests --- tests/DCPS/Compiler/char_literals/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/DCPS/Compiler/char_literals/CMakeLists.txt b/tests/DCPS/Compiler/char_literals/CMakeLists.txt index 2b68973cb3b..6b0f0ea397e 100644 --- a/tests/DCPS/Compiler/char_literals/CMakeLists.txt +++ b/tests/DCPS/Compiler/char_literals/CMakeLists.txt @@ -32,4 +32,6 @@ set_target_properties(opendds_compiler_char_literals_exe PROPERTIES target_link_libraries(opendds_compiler_char_literals_exe ${opendds_libs} ${idl} gtest) configure_file(run_test.pl . COPYONLY) -opendds_add_test(COMMAND perl run_test.pl cpp11 EXTRA_LIB_DIRS "${idl_dir}") +# opendds_add_test(COMMAND perl run_test.pl cpp11 EXTRA_LIB_DIRS "${idl_dir}") + +gtest_discover_tests(opendds_compiler_char_literals_exe SOURCES "main.cpp") From 3a708a3735a50d7f9fd99930ce372dfa0332502e Mon Sep 17 00:00:00 2001 From: Tyler Mayoff Date: Sat, 18 Nov 2023 22:05:34 -0500 Subject: [PATCH 16/24] copied opendds_add_test for gtests --- cmake/opendds_testing.cmake | 58 +++++++++++++++++++ .../Compiler/char_literals/CMakeLists.txt | 2 +- 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/cmake/opendds_testing.cmake b/cmake/opendds_testing.cmake index 45a52a6b0a4..f598e9e1814 100644 --- a/cmake/opendds_testing.cmake +++ b/cmake/opendds_testing.cmake @@ -61,3 +61,61 @@ function(opendds_add_test) set_property(TEST "${test_name}" PROPERTY ENVIRONMENT "${env}") endif() endfunction() + +function(opendds_add_gtest TARGET SOURCES) + set(no_value_options) + set(single_value_options NAME) + set(multi_value_options COMMAND ARGS EXTRA_LIB_DIRS) + # cmake_parse_arguments(arg + # "${sources}" ${ARGN}) + + find_package(Perl REQUIRED) + + set(test_name "${PROJECT_NAME}_test") + gtest_discover_tests(${TARGET} SOURCES ${SOURCES} TEST_LIST ${tests}) + + foreach(test ${tests}) + set(env "ACE_ROOT=${ACE_ROOT}" "TAO_ROOT=${TAO_ROOT}" "DDS_ROOT=${DDS_ROOT}") + + if(MSVC) + set(env_var_name PATH) + else() + set(env_var_name LD_LIBRARY_PATH) + endif() + + _opendds_path_list(lib_dir_list "$ENV{${env_var_name}}" "${TAO_LIB_DIR}") + foreach(lib_dir "${OPENDDS_LIB_DIR}" ${arg_EXTRA_LIB_DIRS}) + _opendds_path_list(lib_dir_list APPEND "${lib_dir}") + if(CMAKE_CONFIGURATION_TYPES) + _opendds_path_list(lib_dir_list APPEND "${lib_dir}$<$>:/$>") + endif() + endforeach() + if(WIN32) + string(REPLACE "/" "\\" lib_dir_list "${lib_dir_list}") + string(REPLACE ";" "\;" lib_dir_list "${lib_dir_list}") + endif() + list(APPEND env "${env_var_name}=${lib_dir_list}") + + if(DEFINED OPENDDS_BUILD_DIR) + list(APPEND env "OPENDDS_BUILD_DIR=${OPENDDS_BUILD_DIR}") + endif() + + if(DEFINED OPENDDS_CONFIG_DIR) + list(APPEND env "OPENDDS_CONFIG_DIR=${OPENDDS_CONFIG_DIR}") + endif() + + if(DEFINED OPENDDS_SOURCE_DIR) + if(NOT DEFINED ACE_SOURCE_DIR) + set(ACE_SOURCE_DIR "${ACE_ROOT}") + endif() + _opendds_path_list(perl5lib "${OPENDDS_SOURCE_DIR}/bin" "${ACE_SOURCE_DIR}/bin") + list(APPEND env "PERL5LIB=${perl5lib}") + list(APPEND env "OPENDDS_SOURCE_DIR=${OPENDDS_SOURCE_DIR}") + endif() + + if(env) + set_property(TEST "${test_name}" PROPERTY ENVIRONMENT "${env}") + endif() + endforeach() +endfunction() + \ No newline at end of file diff --git a/tests/DCPS/Compiler/char_literals/CMakeLists.txt b/tests/DCPS/Compiler/char_literals/CMakeLists.txt index 6b0f0ea397e..ecc0aed951a 100644 --- a/tests/DCPS/Compiler/char_literals/CMakeLists.txt +++ b/tests/DCPS/Compiler/char_literals/CMakeLists.txt @@ -34,4 +34,4 @@ target_link_libraries(opendds_compiler_char_literals_exe ${opendds_libs} ${idl} configure_file(run_test.pl . COPYONLY) # opendds_add_test(COMMAND perl run_test.pl cpp11 EXTRA_LIB_DIRS "${idl_dir}") -gtest_discover_tests(opendds_compiler_char_literals_exe SOURCES "main.cpp") +opendds_add_gtest(opendds_compiler_char_literals_exe SOURCES "main.cpp") From ef4a5841f7cbed56906a44cf4541a8e8cd4a46c2 Mon Sep 17 00:00:00 2001 From: Tyler Mayoff Date: Sat, 18 Nov 2023 22:08:23 -0500 Subject: [PATCH 17/24] fixed whitespace --- cmake/opendds_testing.cmake | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/cmake/opendds_testing.cmake b/cmake/opendds_testing.cmake index f598e9e1814..cdb7a6809dd 100644 --- a/cmake/opendds_testing.cmake +++ b/cmake/opendds_testing.cmake @@ -76,13 +76,13 @@ function(opendds_add_gtest TARGET SOURCES) foreach(test ${tests}) set(env "ACE_ROOT=${ACE_ROOT}" "TAO_ROOT=${TAO_ROOT}" "DDS_ROOT=${DDS_ROOT}") - + if(MSVC) set(env_var_name PATH) else() set(env_var_name LD_LIBRARY_PATH) endif() - + _opendds_path_list(lib_dir_list "$ENV{${env_var_name}}" "${TAO_LIB_DIR}") foreach(lib_dir "${OPENDDS_LIB_DIR}" ${arg_EXTRA_LIB_DIRS}) _opendds_path_list(lib_dir_list APPEND "${lib_dir}") @@ -95,15 +95,15 @@ function(opendds_add_gtest TARGET SOURCES) string(REPLACE ";" "\;" lib_dir_list "${lib_dir_list}") endif() list(APPEND env "${env_var_name}=${lib_dir_list}") - + if(DEFINED OPENDDS_BUILD_DIR) list(APPEND env "OPENDDS_BUILD_DIR=${OPENDDS_BUILD_DIR}") endif() - + if(DEFINED OPENDDS_CONFIG_DIR) list(APPEND env "OPENDDS_CONFIG_DIR=${OPENDDS_CONFIG_DIR}") endif() - + if(DEFINED OPENDDS_SOURCE_DIR) if(NOT DEFINED ACE_SOURCE_DIR) set(ACE_SOURCE_DIR "${ACE_ROOT}") @@ -112,10 +112,9 @@ function(opendds_add_gtest TARGET SOURCES) list(APPEND env "PERL5LIB=${perl5lib}") list(APPEND env "OPENDDS_SOURCE_DIR=${OPENDDS_SOURCE_DIR}") endif() - + if(env) set_property(TEST "${test_name}" PROPERTY ENVIRONMENT "${env}") endif() endforeach() endfunction() - \ No newline at end of file From 6d807de50b1e7c9614b9c691375d0446b2657335 Mon Sep 17 00:00:00 2001 From: Tyler Mayoff Date: Sun, 19 Nov 2023 11:39:38 -0500 Subject: [PATCH 18/24] removed gtest integration, not sure I can setup it up myself --- cmake/opendds_testing.cmake | 57 ------------------- .../Compiler/char_literals/CMakeLists.txt | 4 +- 2 files changed, 1 insertion(+), 60 deletions(-) diff --git a/cmake/opendds_testing.cmake b/cmake/opendds_testing.cmake index cdb7a6809dd..45a52a6b0a4 100644 --- a/cmake/opendds_testing.cmake +++ b/cmake/opendds_testing.cmake @@ -61,60 +61,3 @@ function(opendds_add_test) set_property(TEST "${test_name}" PROPERTY ENVIRONMENT "${env}") endif() endfunction() - -function(opendds_add_gtest TARGET SOURCES) - set(no_value_options) - set(single_value_options NAME) - set(multi_value_options COMMAND ARGS EXTRA_LIB_DIRS) - # cmake_parse_arguments(arg - # "${sources}" ${ARGN}) - - find_package(Perl REQUIRED) - - set(test_name "${PROJECT_NAME}_test") - gtest_discover_tests(${TARGET} SOURCES ${SOURCES} TEST_LIST ${tests}) - - foreach(test ${tests}) - set(env "ACE_ROOT=${ACE_ROOT}" "TAO_ROOT=${TAO_ROOT}" "DDS_ROOT=${DDS_ROOT}") - - if(MSVC) - set(env_var_name PATH) - else() - set(env_var_name LD_LIBRARY_PATH) - endif() - - _opendds_path_list(lib_dir_list "$ENV{${env_var_name}}" "${TAO_LIB_DIR}") - foreach(lib_dir "${OPENDDS_LIB_DIR}" ${arg_EXTRA_LIB_DIRS}) - _opendds_path_list(lib_dir_list APPEND "${lib_dir}") - if(CMAKE_CONFIGURATION_TYPES) - _opendds_path_list(lib_dir_list APPEND "${lib_dir}$<$>:/$>") - endif() - endforeach() - if(WIN32) - string(REPLACE "/" "\\" lib_dir_list "${lib_dir_list}") - string(REPLACE ";" "\;" lib_dir_list "${lib_dir_list}") - endif() - list(APPEND env "${env_var_name}=${lib_dir_list}") - - if(DEFINED OPENDDS_BUILD_DIR) - list(APPEND env "OPENDDS_BUILD_DIR=${OPENDDS_BUILD_DIR}") - endif() - - if(DEFINED OPENDDS_CONFIG_DIR) - list(APPEND env "OPENDDS_CONFIG_DIR=${OPENDDS_CONFIG_DIR}") - endif() - - if(DEFINED OPENDDS_SOURCE_DIR) - if(NOT DEFINED ACE_SOURCE_DIR) - set(ACE_SOURCE_DIR "${ACE_ROOT}") - endif() - _opendds_path_list(perl5lib "${OPENDDS_SOURCE_DIR}/bin" "${ACE_SOURCE_DIR}/bin") - list(APPEND env "PERL5LIB=${perl5lib}") - list(APPEND env "OPENDDS_SOURCE_DIR=${OPENDDS_SOURCE_DIR}") - endif() - - if(env) - set_property(TEST "${test_name}" PROPERTY ENVIRONMENT "${env}") - endif() - endforeach() -endfunction() diff --git a/tests/DCPS/Compiler/char_literals/CMakeLists.txt b/tests/DCPS/Compiler/char_literals/CMakeLists.txt index ecc0aed951a..2b68973cb3b 100644 --- a/tests/DCPS/Compiler/char_literals/CMakeLists.txt +++ b/tests/DCPS/Compiler/char_literals/CMakeLists.txt @@ -32,6 +32,4 @@ set_target_properties(opendds_compiler_char_literals_exe PROPERTIES target_link_libraries(opendds_compiler_char_literals_exe ${opendds_libs} ${idl} gtest) configure_file(run_test.pl . COPYONLY) -# opendds_add_test(COMMAND perl run_test.pl cpp11 EXTRA_LIB_DIRS "${idl_dir}") - -opendds_add_gtest(opendds_compiler_char_literals_exe SOURCES "main.cpp") +opendds_add_test(COMMAND perl run_test.pl cpp11 EXTRA_LIB_DIRS "${idl_dir}") From 2b2a9c12a3477b623dabaec1b8894435eb2172b0 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Tue, 21 Nov 2023 07:36:23 -0600 Subject: [PATCH 19/24] Fixes for CMake Google Test on Windows Also make use of fetch content --- CMakeLists.txt | 27 ++++++++++++++++++++++++--- cmake/opendds_testing.cmake | 7 +++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e7ec0029f83..fd382754b24 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -137,13 +137,34 @@ if(OPENDDS_BUILD_EXAMPLES OR OPENDDS_BUILD_TESTS) add_subdirectory(DevGuideExamples/DCPS/Messenger) endif() if(OPENDDS_BUILD_TESTS) - find_package(GTest QUIET) + find_package(GTest QUIET PATHS "${OPENDDS_GTEST}") if(NOT GTest_FOUND) - message("GTest not found, falling back to local copy") + set(gtestsm "${OPENDDS_SOURCE_DIR}/tests/googletest") + if(EXISTS "${gtestsm}/CMakeLists.txt") + message("GTest not found, using submodule") + set(fetch_args SOURCE_DIR "${gtestsm}") + else() + message("GTest not found, using clone") + set(fetch_args + GIT_REPOSITORY "https://github.com/OpenDDS/googletest" + GIT_TAG "v1.8.x" + GIT_SHALLOW TRUE + GIT_PROGRESS TRUE + USES_TERMINAL_DOWNLOAD TRUE + ) + endif() + FetchContent_Declare(googletest ${fetch_args}) # Prevent overriding the parent project's compiler/linker # settings on Windows set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) - add_subdirectory(tests/googletest) + FetchContent_MakeAvailable(googletest) + endif() + if(TARGET GTest::gtest) + get_target_property(google_test_bin_dir GTest::gtest BINARY_DIR) + set(_OPENDDS_GOOGLE_TEST_DIR "${google_test_bin_dir}" CACHE INTERNAL "") + elseif(TARGET gtest) + get_target_property(google_test_bin_dir gtest BINARY_DIR) + set(_OPENDDS_GOOGLE_TEST_DIR "${google_test_bin_dir}" CACHE INTERNAL "") endif() add_subdirectory(tests/cmake/ace_tao_only) diff --git a/cmake/opendds_testing.cmake b/cmake/opendds_testing.cmake index 45a52a6b0a4..457435cbeeb 100644 --- a/cmake/opendds_testing.cmake +++ b/cmake/opendds_testing.cmake @@ -27,6 +27,13 @@ function(opendds_add_test) else() set(env_var_name LD_LIBRARY_PATH) endif() + if(DEFINED _OPENDDS_GOOGLE_TEST_DIR) + _opendds_path_list(lib_dir_list APPEND "${_OPENDDS_GOOGLE_TEST_DIR}") + if(CMAKE_CONFIGURATION_TYPES) + _opendds_path_list(lib_dir_list APPEND + "${_OPENDDS_GOOGLE_TEST_DIR}$<$>:/$>") + endif() + endif() _opendds_path_list(lib_dir_list "$ENV{${env_var_name}}" "${TAO_LIB_DIR}") foreach(lib_dir "${OPENDDS_LIB_DIR}" ${arg_EXTRA_LIB_DIRS}) _opendds_path_list(lib_dir_list APPEND "${lib_dir}") From 8c6c2a9cb6f867afeb88fa2447d2ad98aea08a48 Mon Sep 17 00:00:00 2001 From: Tyler Mayoff Date: Tue, 21 Nov 2023 09:29:35 -0500 Subject: [PATCH 20/24] removed ctest arg that's covered by env var --- .github/workflows/build_and_test.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 10aca4c06fb..51bbca2d24c 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -12713,7 +12713,7 @@ jobs: - name: Run Tests run: | cd OpenDDS/build - ctest --output-on-failure + ctest build_cmake_u22_stat: @@ -12754,7 +12754,7 @@ jobs: - name: Run Tests run: | cd OpenDDS/build - ctest --output-on-failure + ctest build_cmake_u22_no_features: @@ -12803,7 +12803,7 @@ jobs: - name: Run Tests run: | cd OpenDDS/build - ctest --output-on-failure + ctest build_cmake_u22_android29: @@ -12925,7 +12925,7 @@ jobs: shell: cmd run: | cd OpenDDS\build - ctest --output-on-failure -C Debug + ctest -C Debug build_cmake_w22_stat: @@ -12971,4 +12971,4 @@ jobs: shell: cmd run: | cd OpenDDS\build - ctest --output-on-failure -C Debug + ctest -C Debug From c523c8473449f4ed279f6e8605d395133a139e11 Mon Sep 17 00:00:00 2001 From: Tyler Date: Tue, 21 Nov 2023 10:15:44 -0500 Subject: [PATCH 21/24] Update cmake/opendds_testing.cmake Co-authored-by: Fred Hornsey --- cmake/opendds_testing.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/opendds_testing.cmake b/cmake/opendds_testing.cmake index 457435cbeeb..e1434896b34 100644 --- a/cmake/opendds_testing.cmake +++ b/cmake/opendds_testing.cmake @@ -20,7 +20,7 @@ function(opendds_add_test) list(APPEND arg_COMMAND ${arg_ARGS}) add_test(NAME "${test_name}" ${arg_UNPARSED_ARGUMENTS} COMMAND ${arg_COMMAND}) - set(env "ACE_ROOT=${ACE_ROOT}" "TAO_ROOT=${TAO_ROOT}" "DDS_ROOT=${DDS_ROOT}") + set(env "ACE_ROOT=${ACE_ROOT}" "TAO_ROOT=${TAO_ROOT}") if(MSVC) set(env_var_name PATH) From 576637c7f337a5c0e0ceae1e573b2ec603fb49e1 Mon Sep 17 00:00:00 2001 From: Tyler Date: Tue, 21 Nov 2023 14:12:41 -0500 Subject: [PATCH 22/24] Update cmake/opendds_testing.cmake Co-authored-by: Fred Hornsey --- cmake/opendds_testing.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/opendds_testing.cmake b/cmake/opendds_testing.cmake index e1434896b34..c874318b537 100644 --- a/cmake/opendds_testing.cmake +++ b/cmake/opendds_testing.cmake @@ -27,6 +27,7 @@ function(opendds_add_test) else() set(env_var_name LD_LIBRARY_PATH) endif() + _opendds_path_list(lib_dir_list "$ENV{${env_var_name}}" "${TAO_LIB_DIR}") if(DEFINED _OPENDDS_GOOGLE_TEST_DIR) _opendds_path_list(lib_dir_list APPEND "${_OPENDDS_GOOGLE_TEST_DIR}") if(CMAKE_CONFIGURATION_TYPES) @@ -34,7 +35,6 @@ function(opendds_add_test) "${_OPENDDS_GOOGLE_TEST_DIR}$<$>:/$>") endif() endif() - _opendds_path_list(lib_dir_list "$ENV{${env_var_name}}" "${TAO_LIB_DIR}") foreach(lib_dir "${OPENDDS_LIB_DIR}" ${arg_EXTRA_LIB_DIRS}) _opendds_path_list(lib_dir_list APPEND "${lib_dir}") if(CMAKE_CONFIGURATION_TYPES) From c75335921617697e589150a93cc8d24b13e85ab4 Mon Sep 17 00:00:00 2001 From: Tyler Date: Tue, 21 Nov 2023 14:12:49 -0500 Subject: [PATCH 23/24] Update tests/DCPS/HelloWorld/CMakeLists.txt Co-authored-by: Fred Hornsey --- tests/DCPS/HelloWorld/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/DCPS/HelloWorld/CMakeLists.txt b/tests/DCPS/HelloWorld/CMakeLists.txt index 64c6f0de8ed..9310bd09111 100644 --- a/tests/DCPS/HelloWorld/CMakeLists.txt +++ b/tests/DCPS/HelloWorld/CMakeLists.txt @@ -44,4 +44,4 @@ set_target_properties(${subscriber} PROPERTIES configure_file(run_test.pl . COPYONLY) configure_file(rtps.ini . COPYONLY) opendds_add_test(NAME info_repo COMMAND perl run_test.pl) -opendds_add_test(NAME rtps COMMAND perl run_test.pl init=rtps.ini) +opendds_add_test(NAME rtps COMMAND perl run_test.pl ini=rtps.ini) From 6af80356a3a7879ab0fbe676a7b3c66a9043980e Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Tue, 21 Nov 2023 17:40:14 -0600 Subject: [PATCH 24/24] Try 60s Timeout in HelloWorld --- tests/DCPS/HelloWorld/run_test.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/DCPS/HelloWorld/run_test.pl b/tests/DCPS/HelloWorld/run_test.pl index 27c730a9b51..75ab4aa2193 100755 --- a/tests/DCPS/HelloWorld/run_test.pl +++ b/tests/DCPS/HelloWorld/run_test.pl @@ -18,9 +18,9 @@ $test->process('subscriber', 'subscriber'); $test->process('publisher', 'publisher'); -rmtree './DCS'; +rmtree('./DCS'); $test->start_process('publisher'); $test->start_process('subscriber'); -exit $test->finish(30); +exit($test->finish(60));