From 145c15e9c30708623d87c0623e56f120352f627b Mon Sep 17 00:00:00 2001 From: Christopher Harris Date: Thu, 3 Aug 2023 17:12:25 +0000 Subject: [PATCH 1/9] fix and run all tests --- morpheus/_lib/tests/CMakeLists.txt | 110 ++++++++--------------------- morpheus/_lib/tests/io/test_io.hpp | 3 +- morpheus/_lib/tests/test_main.cpp | 29 ++++++++ 3 files changed, 61 insertions(+), 81 deletions(-) create mode 100644 morpheus/_lib/tests/test_main.cpp diff --git a/morpheus/_lib/tests/CMakeLists.txt b/morpheus/_lib/tests/CMakeLists.txt index 792c564442..08a752f0e1 100644 --- a/morpheus/_lib/tests/CMakeLists.txt +++ b/morpheus/_lib/tests/CMakeLists.txt @@ -17,103 +17,53 @@ list(APPEND CMAKE_MESSAGE_CONTEXT "tests") find_package(pybind11 REQUIRED) -include(GoogleTest) -add_library( - morpheus_test_utilities - test_utils/common.cpp -) - -target_link_libraries( - morpheus_test_utilities - PRIVATE - GTest::gtest - morpheus -) - -function (add_morpheus_test TEST_NAME TEST_FILES) - - add_executable( - test_${TEST_NAME} - ${TEST_FILES} - ) - - target_link_libraries( - test_${TEST_NAME} - PRIVATE - GTest::gtest - GTest::gtest_main - matx::matx - morpheus - morpheus_test_utilities - pybind11::embed - ) - - gtest_discover_tests(test_${TEST_NAME}) - - set_target_properties(test_${TEST_NAME} - PROPERTIES - INSTALL_RPATH "$ORIGIN/.." - CUDA_STANDARD 17 - CUDA_STANDARD_REQUIRED ON - ) - - install( - TARGETS - test_${TEST_NAME} - RUNTIME DESTINATION - "${MORPHEUS_LIB_INSTALL_DIR}/tests" - COMPONENT Wheel - ) - -endfunction() - -add_morpheus_test(cuda - test_cuda.cu -) - -add_morpheus_test(data_loader - io/test_data_loader.cpp +add_executable(test_libmorpheus io/test_data_loader_registry.cpp + io/test_data_loader.cpp io/test_loaders.cpp -) - -add_morpheus_test(messages messages/test_control_message.cpp messages/test_dev_doc_ex3.cpp messages/test_sliced_message_meta.cpp -) - -add_morpheus_test(modules modules/test_data_loader_module.cpp -) - -add_morpheus_test(deserializers + test_cuda.cu test_deserializers.cpp -) - -add_morpheus_test(dev_mem_info test_dev_mem_info.cpp -) - -add_morpheus_test(file_io test_file_in_out.cpp + test_main.cpp + test_matx_util.cpp + test_multi_slices.cpp + test_tensor.cpp + test_type_util.cpp + test_utils/common.cpp ) -add_morpheus_test(matx - test_matx_util.cpp +target_link_libraries(test_libmorpheus + PRIVATE + GTest::gtest + matx::matx + morpheus + pybind11::embed ) -add_morpheus_test(multi_slices - test_multi_slices.cpp +add_test( + NAME test_libmorpheus + COMMAND $ ) -add_morpheus_test(tensor - test_tensor.cpp +set_target_properties(test_libmorpheus + PROPERTIES + INSTALL_RPATH "$ORIGIN/.." + CUDA_STANDARD 17 + CUDA_STANDARD_REQUIRED ON ) -add_morpheus_test(type_util - test_type_util.cpp +install( + TARGETS + test_libmorpheus + RUNTIME DESTINATION + "${MORPHEUS_LIB_INSTALL_DIR}/tests" + COMPONENT Wheel ) -list(POP_BACK CMAKE_MESSAGE_CONTEXT) +list(POP_BACK CMAKE_MESSAGE_CONTEXT) \ No newline at end of file diff --git a/morpheus/_lib/tests/io/test_io.hpp b/morpheus/_lib/tests/io/test_io.hpp index 5a05e6a80c..d922d47725 100644 --- a/morpheus/_lib/tests/io/test_io.hpp +++ b/morpheus/_lib/tests/io/test_io.hpp @@ -21,8 +21,9 @@ namespace morpheus::test { -TEST_CLASS(DataLoaderRegistry); +// TEST_CLASS(DataLoaderRegistry); TEST_CLASS(Loader); using TestDataLoader = TestWithPythonInterpreter; // NOLINT +using TestDataLoaderRegistry = TestWithPythonInterpreter; // NOLINT } // namespace morpheus::test \ No newline at end of file diff --git a/morpheus/_lib/tests/test_main.cpp b/morpheus/_lib/tests/test_main.cpp new file mode 100644 index 0000000000..31ebb2d318 --- /dev/null +++ b/morpheus/_lib/tests/test_main.cpp @@ -0,0 +1,29 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include // for ParseCommandLineFlags +#include +#include // IWYU pragma: keep + +int main(int argc, char** argv) +{ + FLAGS_alsologtostderr = true; // Log to console + ::google::InitGoogleLogging("morpheus::test_libmorpheus"); + ::testing::InitGoogleTest(&argc, argv); + ::google::ParseCommandLineFlags(&argc, &argv, true); + return RUN_ALL_TESTS(); +} \ No newline at end of file From 80ce75e8e17e3eba2827baec185b4cdac3305865 Mon Sep 17 00:00:00 2001 From: Christopher Harris Date: Thu, 3 Aug 2023 17:15:13 +0000 Subject: [PATCH 2/9] style --- morpheus/_lib/tests/io/test_io.hpp | 3 ++- morpheus/_lib/tests/test_main.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/morpheus/_lib/tests/io/test_io.hpp b/morpheus/_lib/tests/io/test_io.hpp index d922d47725..a185865f98 100644 --- a/morpheus/_lib/tests/io/test_io.hpp +++ b/morpheus/_lib/tests/io/test_io.hpp @@ -26,4 +26,5 @@ TEST_CLASS(Loader); using TestDataLoader = TestWithPythonInterpreter; // NOLINT using TestDataLoaderRegistry = TestWithPythonInterpreter; // NOLINT -} // namespace morpheus::test \ No newline at end of file + +} // namespace morpheus::test diff --git a/morpheus/_lib/tests/test_main.cpp b/morpheus/_lib/tests/test_main.cpp index 31ebb2d318..69c430859d 100644 --- a/morpheus/_lib/tests/test_main.cpp +++ b/morpheus/_lib/tests/test_main.cpp @@ -26,4 +26,4 @@ int main(int argc, char** argv) ::testing::InitGoogleTest(&argc, argv); ::google::ParseCommandLineFlags(&argc, &argv, true); return RUN_ALL_TESTS(); -} \ No newline at end of file +} From 21e72617aa69d70ce260639dbfa264c59a9d07ce Mon Sep 17 00:00:00 2001 From: Christopher Harris Date: Thu, 3 Aug 2023 17:16:03 +0000 Subject: [PATCH 3/9] use gtest_main --- morpheus/_lib/tests/CMakeLists.txt | 2 +- morpheus/_lib/tests/test_main.cpp | 29 ----------------------------- 2 files changed, 1 insertion(+), 30 deletions(-) delete mode 100644 morpheus/_lib/tests/test_main.cpp diff --git a/morpheus/_lib/tests/CMakeLists.txt b/morpheus/_lib/tests/CMakeLists.txt index 08a752f0e1..3e33767a63 100644 --- a/morpheus/_lib/tests/CMakeLists.txt +++ b/morpheus/_lib/tests/CMakeLists.txt @@ -30,7 +30,6 @@ add_executable(test_libmorpheus test_deserializers.cpp test_dev_mem_info.cpp test_file_in_out.cpp - test_main.cpp test_matx_util.cpp test_multi_slices.cpp test_tensor.cpp @@ -41,6 +40,7 @@ add_executable(test_libmorpheus target_link_libraries(test_libmorpheus PRIVATE GTest::gtest + GTest::gtest_main matx::matx morpheus pybind11::embed diff --git a/morpheus/_lib/tests/test_main.cpp b/morpheus/_lib/tests/test_main.cpp deleted file mode 100644 index 69c430859d..0000000000 --- a/morpheus/_lib/tests/test_main.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include // for ParseCommandLineFlags -#include -#include // IWYU pragma: keep - -int main(int argc, char** argv) -{ - FLAGS_alsologtostderr = true; // Log to console - ::google::InitGoogleLogging("morpheus::test_libmorpheus"); - ::testing::InitGoogleTest(&argc, argv); - ::google::ParseCommandLineFlags(&argc, &argv, true); - return RUN_ALL_TESTS(); -} From 1962ae9219c898d9e2398b7fb0afbf5454d0fc58 Mon Sep 17 00:00:00 2001 From: Christopher Harris Date: Thu, 3 Aug 2023 17:16:46 +0000 Subject: [PATCH 4/9] style --- morpheus/_lib/tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/morpheus/_lib/tests/CMakeLists.txt b/morpheus/_lib/tests/CMakeLists.txt index 3e33767a63..420af7e015 100644 --- a/morpheus/_lib/tests/CMakeLists.txt +++ b/morpheus/_lib/tests/CMakeLists.txt @@ -66,4 +66,4 @@ install( COMPONENT Wheel ) -list(POP_BACK CMAKE_MESSAGE_CONTEXT) \ No newline at end of file +list(POP_BACK CMAKE_MESSAGE_CONTEXT) From 17362032432bb93e0a39e18a1c7d27d5c5a09004 Mon Sep 17 00:00:00 2001 From: Christopher Harris Date: Thu, 3 Aug 2023 18:16:42 +0000 Subject: [PATCH 5/9] let TestCuda use its own executable that doesnt depend on morpheus --- morpheus/_lib/tests/CMakeLists.txt | 151 ++++++++++++++++++++++++----- morpheus/_lib/tests/io/test_io.hpp | 4 +- 2 files changed, 126 insertions(+), 29 deletions(-) diff --git a/morpheus/_lib/tests/CMakeLists.txt b/morpheus/_lib/tests/CMakeLists.txt index 420af7e015..43aa618820 100644 --- a/morpheus/_lib/tests/CMakeLists.txt +++ b/morpheus/_lib/tests/CMakeLists.txt @@ -17,53 +17,152 @@ list(APPEND CMAKE_MESSAGE_CONTEXT "tests") find_package(pybind11 REQUIRED) +include(GoogleTest) -add_executable(test_libmorpheus - io/test_data_loader_registry.cpp - io/test_data_loader.cpp - io/test_loaders.cpp - messages/test_control_message.cpp - messages/test_dev_doc_ex3.cpp - messages/test_sliced_message_meta.cpp - modules/test_data_loader_module.cpp +# Cuda Test + +add_executable(test_cuda test_cuda.cu - test_deserializers.cpp - test_dev_mem_info.cpp - test_file_in_out.cpp - test_matx_util.cpp - test_multi_slices.cpp - test_tensor.cpp - test_type_util.cpp - test_utils/common.cpp ) -target_link_libraries(test_libmorpheus +target_link_libraries(test_cuda PRIVATE GTest::gtest GTest::gtest_main matx::matx - morpheus - pybind11::embed + ) + +gtest_discover_tests(test_cuda) + +set_target_properties(test_cuda +PROPERTIES + INSTALL_RPATH "$ORIGIN/.." + CUDA_STANDARD 17 + CUDA_STANDARD_REQUIRED ON +) + +install( +TARGETS + test_cuda +RUNTIME DESTINATION + "${MORPHEUS_LIB_INSTALL_DIR}/tests" +COMPONENT Wheel +) + +# Morpheus Tests + +add_library( + morpheus_test_utilities + test_utils/common.cpp ) -add_test( - NAME test_libmorpheus - COMMAND $ +target_link_libraries( + morpheus_test_utilities + PUBLIC + GTest::gtest + morpheus ) -set_target_properties(test_libmorpheus +function (add_morpheus_test) + set(options) + set(oneValueArgs NAME) + set(multiValueArgs FILES) + cmake_parse_arguments(MORPHEUS_TEST "${options}" + "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + add_executable(test_${MORPHEUS_TEST_NAME} + ${MORPHEUS_TEST_FILES} + ) + + target_link_libraries(test_${MORPHEUS_TEST_NAME} + PRIVATE + GTest::gtest_main + matx::matx + morpheus_test_utilities + pybind11::embed + ) + + gtest_discover_tests(test_${MORPHEUS_TEST_NAME}) + + set_target_properties(test_${MORPHEUS_TEST_NAME} PROPERTIES INSTALL_RPATH "$ORIGIN/.." CUDA_STANDARD 17 CUDA_STANDARD_REQUIRED ON -) + ) -install( + install( TARGETS - test_libmorpheus + test_${MORPHEUS_TEST_NAME} RUNTIME DESTINATION "${MORPHEUS_LIB_INSTALL_DIR}/tests" COMPONENT Wheel + ) + +endfunction() + +add_morpheus_test( + NAME io + FILES + io/test_data_loader.cpp + io/test_data_loader_registry.cpp + io/test_loaders.cpp +) + +add_morpheus_test( + NAME messages + FILES + messages/test_control_message.cpp + messages/test_dev_doc_ex3.cpp + messages/test_sliced_message_meta.cpp +) + +add_morpheus_test( + NAME modules + FILES + modules/test_data_loader_module.cpp +) + +add_morpheus_test( + NAME deserializers + FILES + test_deserializers.cpp +) + +add_morpheus_test( + NAME dev_mem_info + FILES + test_dev_mem_info.cpp +) + +add_morpheus_test( + NAME file_in_out + FILES + test_file_in_out.cpp +) + +add_morpheus_test( + NAME matx_util + FILES + test_matx_util.cpp +) + +add_morpheus_test( + NAME multi_slices + FILES + test_multi_slices.cpp +) + +add_morpheus_test( + NAME tensor + FILES + test_tensor.cpp +) + +add_morpheus_test( + NAME type_util + FILES + test_type_util.cpp ) list(POP_BACK CMAKE_MESSAGE_CONTEXT) diff --git a/morpheus/_lib/tests/io/test_io.hpp b/morpheus/_lib/tests/io/test_io.hpp index a185865f98..4e6fd9c845 100644 --- a/morpheus/_lib/tests/io/test_io.hpp +++ b/morpheus/_lib/tests/io/test_io.hpp @@ -21,9 +21,7 @@ namespace morpheus::test { -// TEST_CLASS(DataLoaderRegistry); -TEST_CLASS(Loader); - +using TestLoader = TestWithPythonInterpreter; // NOLINT using TestDataLoader = TestWithPythonInterpreter; // NOLINT using TestDataLoaderRegistry = TestWithPythonInterpreter; // NOLINT From c0550f09aa8d8f13ac72cac070372f535f5789e4 Mon Sep 17 00:00:00 2001 From: Christopher Harris Date: Thu, 3 Aug 2023 18:19:29 +0000 Subject: [PATCH 6/9] styles --- morpheus/_lib/tests/CMakeLists.txt | 60 +++++++++++++++--------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/morpheus/_lib/tests/CMakeLists.txt b/morpheus/_lib/tests/CMakeLists.txt index 43aa618820..3b7745f662 100644 --- a/morpheus/_lib/tests/CMakeLists.txt +++ b/morpheus/_lib/tests/CMakeLists.txt @@ -30,30 +30,30 @@ target_link_libraries(test_cuda GTest::gtest GTest::gtest_main matx::matx - ) +) gtest_discover_tests(test_cuda) set_target_properties(test_cuda -PROPERTIES - INSTALL_RPATH "$ORIGIN/.." - CUDA_STANDARD 17 - CUDA_STANDARD_REQUIRED ON + PROPERTIES + INSTALL_RPATH "$ORIGIN/.." + CUDA_STANDARD 17 + CUDA_STANDARD_REQUIRED ON ) install( -TARGETS - test_cuda -RUNTIME DESTINATION - "${MORPHEUS_LIB_INSTALL_DIR}/tests" -COMPONENT Wheel + TARGETS + test_cuda + RUNTIME DESTINATION + "${MORPHEUS_LIB_INSTALL_DIR}/tests" + COMPONENT Wheel ) -# Morpheus Tests +# Morpheus Test Utilities add_library( - morpheus_test_utilities - test_utils/common.cpp + morpheus_test_utilities + test_utils/common.cpp ) target_link_libraries( @@ -63,40 +63,42 @@ target_link_libraries( morpheus ) +# Morpheus Tests + function (add_morpheus_test) set(options) set(oneValueArgs NAME) set(multiValueArgs FILES) - cmake_parse_arguments(MORPHEUS_TEST "${options}" - "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments( + MORPHEUS_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} + ) add_executable(test_${MORPHEUS_TEST_NAME} ${MORPHEUS_TEST_FILES} ) target_link_libraries(test_${MORPHEUS_TEST_NAME} - PRIVATE - GTest::gtest_main - matx::matx - morpheus_test_utilities - pybind11::embed + PRIVATE + GTest::gtest_main + morpheus_test_utilities + pybind11::embed ) gtest_discover_tests(test_${MORPHEUS_TEST_NAME}) set_target_properties(test_${MORPHEUS_TEST_NAME} - PROPERTIES - INSTALL_RPATH "$ORIGIN/.." - CUDA_STANDARD 17 - CUDA_STANDARD_REQUIRED ON + PROPERTIES + INSTALL_RPATH "$ORIGIN/.." + CUDA_STANDARD 17 + CUDA_STANDARD_REQUIRED ON ) install( - TARGETS - test_${MORPHEUS_TEST_NAME} - RUNTIME DESTINATION - "${MORPHEUS_LIB_INSTALL_DIR}/tests" - COMPONENT Wheel + TARGETS + test_${MORPHEUS_TEST_NAME} + RUNTIME DESTINATION + "${MORPHEUS_LIB_INSTALL_DIR}/tests" + COMPONENT Wheel ) endfunction() From 9e82809766b392cd063b73d36db9c0bfa749937e Mon Sep 17 00:00:00 2001 From: Christopher Harris Date: Thu, 3 Aug 2023 19:47:16 +0000 Subject: [PATCH 7/9] update external/utilities --- external/utilities | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/utilities b/external/utilities index b3af2a3501..b3d13be74c 160000 --- a/external/utilities +++ b/external/utilities @@ -1 +1 @@ -Subproject commit b3af2a3501b2357c3467b7abb295ae75151db186 +Subproject commit b3d13be74c1d5e187162c44b6676b6a9b26e91fb From 93594699e157cb7c7c7ebd7ea49273876bac636b Mon Sep 17 00:00:00 2001 From: Christopher Harris Date: Mon, 21 Aug 2023 20:15:25 -0500 Subject: [PATCH 8/9] revert utilities --- external/utilities | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/utilities b/external/utilities index b3d13be74c..08c2eb0c60 160000 --- a/external/utilities +++ b/external/utilities @@ -1 +1 @@ -Subproject commit b3d13be74c1d5e187162c44b6676b6a9b26e91fb +Subproject commit 08c2eb0c608a8062ff1810907851aca20a09826a From 38c0675c54a73a9f4164825e60fa7dd75451f603 Mon Sep 17 00:00:00 2001 From: Christopher Harris Date: Tue, 22 Aug 2023 01:36:27 +0000 Subject: [PATCH 9/9] styles --- morpheus/_lib/tests/io/test_io.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/morpheus/_lib/tests/io/test_io.hpp b/morpheus/_lib/tests/io/test_io.hpp index 4e6fd9c845..b849b42a0f 100644 --- a/morpheus/_lib/tests/io/test_io.hpp +++ b/morpheus/_lib/tests/io/test_io.hpp @@ -21,8 +21,8 @@ namespace morpheus::test { -using TestLoader = TestWithPythonInterpreter; // NOLINT -using TestDataLoader = TestWithPythonInterpreter; // NOLINT +using TestLoader = TestWithPythonInterpreter; // NOLINT +using TestDataLoader = TestWithPythonInterpreter; // NOLINT using TestDataLoaderRegistry = TestWithPythonInterpreter; // NOLINT } // namespace morpheus::test