diff --git a/morpheus/_lib/tests/CMakeLists.txt b/morpheus/_lib/tests/CMakeLists.txt index f38ada32e6..792c564442 100644 --- a/morpheus/_lib/tests/CMakeLists.txt +++ b/morpheus/_lib/tests/CMakeLists.txt @@ -17,53 +17,103 @@ list(APPEND CMAKE_MESSAGE_CONTEXT "tests") find_package(pybind11 REQUIRED) -# Keep all source files sorted -add_executable(test_libmorpheus +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 io/test_data_loader_registry.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_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_morpheus.cpp - test_multi_slices.cpp - test_tensor.cpp - test_type_util.cpp ) -target_link_libraries(test_libmorpheus - PRIVATE - GTest::gtest - matx::matx - morpheus - pybind11::embed +add_morpheus_test(matx + test_matx_util.cpp ) -add_test( - NAME test_libmorpheus - COMMAND $ +add_morpheus_test(multi_slices + test_multi_slices.cpp ) -set_target_properties(test_libmorpheus - PROPERTIES - INSTALL_RPATH "$ORIGIN/.." - CUDA_STANDARD 17 - CUDA_STANDARD_REQUIRED ON +add_morpheus_test(tensor + test_tensor.cpp ) -install( - TARGETS - test_libmorpheus - RUNTIME DESTINATION - "${MORPHEUS_LIB_INSTALL_DIR}/tests" - COMPONENT Wheel +add_morpheus_test(type_util + test_type_util.cpp ) list(POP_BACK CMAKE_MESSAGE_CONTEXT) diff --git a/morpheus/_lib/tests/io/test_data_loader.cpp b/morpheus/_lib/tests/io/test_data_loader.cpp index 24fc00df15..c81d5186b5 100644 --- a/morpheus/_lib/tests/io/test_data_loader.cpp +++ b/morpheus/_lib/tests/io/test_data_loader.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "../test_morpheus.hpp" // IWYU pragma: associated +#include "../test_utils/common.hpp" // IWYU pragma: associated #include "test_io.hpp" #include "morpheus/io/data_loader.hpp" diff --git a/morpheus/_lib/tests/io/test_data_loader_registry.cpp b/morpheus/_lib/tests/io/test_data_loader_registry.cpp index 4021305776..bd0c85c92d 100644 --- a/morpheus/_lib/tests/io/test_data_loader_registry.cpp +++ b/morpheus/_lib/tests/io/test_data_loader_registry.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "../test_morpheus.hpp" // IWYU pragma: associated +#include "../test_utils/common.hpp" // IWYU pragma: associated #include "test_io.hpp" #include "morpheus/io/data_loader_registry.hpp" diff --git a/morpheus/_lib/tests/io/test_io.hpp b/morpheus/_lib/tests/io/test_io.hpp index 9089a6244b..5a05e6a80c 100644 --- a/morpheus/_lib/tests/io/test_io.hpp +++ b/morpheus/_lib/tests/io/test_io.hpp @@ -17,7 +17,7 @@ #pragma once -#include "../test_morpheus.hpp" // IWYU pragma: associated +#include "../test_utils/common.hpp" // IWYU pragma: associated namespace morpheus::test { diff --git a/morpheus/_lib/tests/io/test_loaders.cpp b/morpheus/_lib/tests/io/test_loaders.cpp index b4fa67ff67..880468a732 100644 --- a/morpheus/_lib/tests/io/test_loaders.cpp +++ b/morpheus/_lib/tests/io/test_loaders.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "../test_morpheus.hpp" // IWYU pragma: associated +#include "../test_utils/common.hpp" // IWYU pragma: associated #include "test_io.hpp" #include "morpheus/io/loaders/file.hpp" diff --git a/morpheus/_lib/tests/messages/test_control_message.cpp b/morpheus/_lib/tests/messages/test_control_message.cpp index 5d225615a7..734707f1fb 100644 --- a/morpheus/_lib/tests/messages/test_control_message.cpp +++ b/morpheus/_lib/tests/messages/test_control_message.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "../test_morpheus.hpp" // IWYU pragma: associated +#include "../test_utils/common.hpp" // IWYU pragma: associated #include "test_messages.hpp" #include "morpheus/messages/control.hpp" diff --git a/morpheus/_lib/tests/messages/test_dev_doc_ex3.cpp b/morpheus/_lib/tests/messages/test_dev_doc_ex3.cpp index 9e09e0a1c9..e73ea55570 100644 --- a/morpheus/_lib/tests/messages/test_dev_doc_ex3.cpp +++ b/morpheus/_lib/tests/messages/test_dev_doc_ex3.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "../test_morpheus.hpp" // IWYU pragma: associated +#include "../test_utils/common.hpp" // IWYU pragma: associated #include "morpheus/messages/meta.hpp" // for MessageMeta #include "morpheus/messages/multi.hpp" // for MultiMessage diff --git a/morpheus/_lib/tests/messages/test_messages.hpp b/morpheus/_lib/tests/messages/test_messages.hpp index 8181b3ccaa..47706202e2 100644 --- a/morpheus/_lib/tests/messages/test_messages.hpp +++ b/morpheus/_lib/tests/messages/test_messages.hpp @@ -17,7 +17,7 @@ #pragma once -#include "../test_morpheus.hpp" // IWYU pragma: associated +#include "../test_utils/common.hpp" // IWYU pragma: associated namespace morpheus::test { diff --git a/morpheus/_lib/tests/messages/test_sliced_message_meta.cpp b/morpheus/_lib/tests/messages/test_sliced_message_meta.cpp index 08a723b274..12fc351e27 100644 --- a/morpheus/_lib/tests/messages/test_sliced_message_meta.cpp +++ b/morpheus/_lib/tests/messages/test_sliced_message_meta.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "../test_morpheus.hpp" // IWYU pragma: associated +#include "../test_utils/common.hpp" // IWYU pragma: associated #include "morpheus/io/deserializers.hpp" // for load_table_from_file, prepare_df_index #include "morpheus/messages/meta.hpp" // for MessageMeta and SlicedMessageMeta diff --git a/morpheus/_lib/tests/modules/test_data_loader_module.cpp b/morpheus/_lib/tests/modules/test_data_loader_module.cpp index a291252bdb..0f0c0618ad 100644 --- a/morpheus/_lib/tests/modules/test_data_loader_module.cpp +++ b/morpheus/_lib/tests/modules/test_data_loader_module.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "../test_morpheus.hpp" // IWYU pragma: associated +#include "../test_utils/common.hpp" // IWYU pragma: associated #include "mrc/runnable/types.hpp" #include "test_modules.hpp" diff --git a/morpheus/_lib/tests/modules/test_modules.hpp b/morpheus/_lib/tests/modules/test_modules.hpp index a542f6e43c..94a9f3934d 100644 --- a/morpheus/_lib/tests/modules/test_modules.hpp +++ b/morpheus/_lib/tests/modules/test_modules.hpp @@ -17,7 +17,7 @@ #pragma once -#include "../test_morpheus.hpp" // IWYU pragma: associated +#include "../test_utils/common.hpp" // IWYU pragma: associated namespace morpheus::test { diff --git a/morpheus/_lib/tests/test_cuda.cu b/morpheus/_lib/tests/test_cuda.cu index 6d6980bb8c..5ec0114454 100644 --- a/morpheus/_lib/tests/test_cuda.cu +++ b/morpheus/_lib/tests/test_cuda.cu @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "test_morpheus.hpp" +#include "./test_utils/common.hpp" #include diff --git a/morpheus/_lib/tests/test_deserializers.cpp b/morpheus/_lib/tests/test_deserializers.cpp index de31328a5e..9829f297d8 100644 --- a/morpheus/_lib/tests/test_deserializers.cpp +++ b/morpheus/_lib/tests/test_deserializers.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "./test_morpheus.hpp" // IWYU pragma: associated +#include "./test_utils/common.hpp" // IWYU pragma: associated #include "morpheus/io/deserializers.hpp" diff --git a/morpheus/_lib/tests/test_dev_mem_info.cpp b/morpheus/_lib/tests/test_dev_mem_info.cpp index 69e3c02c3b..a9ef0c5d31 100644 --- a/morpheus/_lib/tests/test_dev_mem_info.cpp +++ b/morpheus/_lib/tests/test_dev_mem_info.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "./test_morpheus.hpp" // IWYU pragma: associated +#include "./test_utils/common.hpp" // IWYU pragma: associated #include "morpheus/objects/dev_mem_info.hpp" #include "morpheus/objects/dtype.hpp" // for DType diff --git a/morpheus/_lib/tests/test_file_in_out.cpp b/morpheus/_lib/tests/test_file_in_out.cpp index 677157443c..612d074330 100644 --- a/morpheus/_lib/tests/test_file_in_out.cpp +++ b/morpheus/_lib/tests/test_file_in_out.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "./test_morpheus.hpp" // IWYU pragma: associated +#include "./test_utils/common.hpp" // IWYU pragma: associated #include "morpheus/io/deserializers.hpp" #include "morpheus/io/serializers.hpp" 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(); -} diff --git a/morpheus/_lib/tests/test_matx_util.cpp b/morpheus/_lib/tests/test_matx_util.cpp index ddef030127..11dce22fad 100644 --- a/morpheus/_lib/tests/test_matx_util.cpp +++ b/morpheus/_lib/tests/test_matx_util.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "./test_morpheus.hpp" // IWYU pragma: associated +#include "./test_utils/common.hpp" // IWYU pragma: associated #include "morpheus/io/deserializers.hpp" #include "morpheus/objects/dev_mem_info.hpp" diff --git a/morpheus/_lib/tests/test_multi_slices.cpp b/morpheus/_lib/tests/test_multi_slices.cpp index 98e97d8303..3752b5d039 100644 --- a/morpheus/_lib/tests/test_multi_slices.cpp +++ b/morpheus/_lib/tests/test_multi_slices.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "./test_morpheus.hpp" // IWYU pragma: associated +#include "./test_utils/common.hpp" // IWYU pragma: associated #include "morpheus/io/deserializers.hpp" diff --git a/morpheus/_lib/tests/test_tensor.cpp b/morpheus/_lib/tests/test_tensor.cpp index 88edf87414..16db893ccc 100644 --- a/morpheus/_lib/tests/test_tensor.cpp +++ b/morpheus/_lib/tests/test_tensor.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "./test_morpheus.hpp" // IWYU pragma: associated +#include "./test_utils/common.hpp" // IWYU pragma: associated #include "morpheus/objects/dtype.hpp" // for DType #include "morpheus/objects/memory_descriptor.hpp" // for MemoryDescriptor diff --git a/morpheus/_lib/tests/test_type_util.cpp b/morpheus/_lib/tests/test_type_util.cpp index 3f2a4e37f2..5da4afa93a 100644 --- a/morpheus/_lib/tests/test_type_util.cpp +++ b/morpheus/_lib/tests/test_type_util.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "./test_morpheus.hpp" // IWYU pragma: associated +#include "./test_utils/common.hpp" // IWYU pragma: associated #include "morpheus/objects/dtype.hpp" diff --git a/morpheus/_lib/tests/test_morpheus.cpp b/morpheus/_lib/tests/test_utils/common.cpp similarity index 99% rename from morpheus/_lib/tests/test_morpheus.cpp rename to morpheus/_lib/tests/test_utils/common.cpp index c4526c6e7e..4518924958 100644 --- a/morpheus/_lib/tests/test_morpheus.cpp +++ b/morpheus/_lib/tests/test_utils/common.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "test_morpheus.hpp" +#include "./common.hpp" #include "morpheus/io/data_loader_registry.hpp" #include "morpheus/io/loaders/file.hpp" diff --git a/morpheus/_lib/tests/test_morpheus.hpp b/morpheus/_lib/tests/test_utils/common.hpp similarity index 100% rename from morpheus/_lib/tests/test_morpheus.hpp rename to morpheus/_lib/tests/test_utils/common.hpp diff --git a/scripts/compile.sh b/scripts/compile.sh index 7e4514c8b1..7bf7fe6108 100755 --- a/scripts/compile.sh +++ b/scripts/compile.sh @@ -25,7 +25,7 @@ echo "Runing CMake configure..." # Use some standard default values plus CMAKE_ARGS and CMAKE_CONFIGURE_EXTRA_ARGS # CMAKE_ARGS is supplied by the conda environment # CMAKE_CONFIGURE_EXTRA_ARGS is supplied by the user -cmake -B ${BUILD_DIR} -GNinja \ +cmake -S . -B ${BUILD_DIR} -GNinja \ -DCMAKE_MESSAGE_CONTEXT_SHOW=ON \ -DMORPHEUS_USE_CLANG_TIDY=OFF \ -DMORPHEUS_PYTHON_INPLACE_BUILD=ON \ @@ -34,7 +34,7 @@ cmake -B ${BUILD_DIR} -GNinja \ -DMORPHEUS_SUPPORT_DOCA=${MORPHEUS_SUPPORT_DOCA:-OFF} \ ${INSTALL_PREFIX:+-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX}} \ ${CMAKE_ARGS:+${CMAKE_ARGS}} \ - ${CMAKE_CONFIGURE_EXTRA_ARGS:+${CMAKE_CONFIGURE_EXTRA_ARGS}} . + ${CMAKE_CONFIGURE_EXTRA_ARGS:+${CMAKE_CONFIGURE_EXTRA_ARGS}} echo "Running CMake build..." cmake --build ${BUILD_DIR} -j ${INSTALL_PREFIX:+--target install} "$@"