Skip to content

Commit

Permalink
Fix Tests broken by Test Reorganization (nv-morpheus#1118)
Browse files Browse the repository at this point in the history
The test reorganization resulted in a couple of problems. First, not all tests were being run due to a mistake I made in handling cmake function arguments. Second, the `test_cuda` test was producing a segfault inside of triton client while initializing curl, but only in debug builds. The fix was to the segfault was not obvious, but apparently only occured when the test utilities were compiled as a separate library. Interestingly, the other tests were not affected. Perhaps there is some global state that needs to be managed that is not managed in the simple `test_cuda` test, which only calls a Matx function (also important, the Matx function result is not inspected, so the test itself is not comprehensive, as Matx does not produce an error if the kernel is not available for the given architecture).

Depends on nv-morpheus#1110

Authors:
  - Christopher Harris (https://github.com/cwharris)

Approvers:
  - Michael Demoret (https://github.com/mdemoret-nv)

URL: nv-morpheus#1118
  • Loading branch information
cwharris authored Aug 22, 2023
1 parent c92e212 commit 7cbbb7e
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 47 deletions.
137 changes: 94 additions & 43 deletions morpheus/_lib/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,74 @@ find_package(pybind11 REQUIRED)

include(GoogleTest)

# Cuda Test

add_executable(test_cuda
test_cuda.cu
)

target_link_libraries(test_cuda
PRIVATE
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
)

install(
TARGETS
test_cuda
RUNTIME DESTINATION
"${MORPHEUS_LIB_INSTALL_DIR}/tests"
COMPONENT Wheel
)

# Morpheus Test Utilities

add_library(
morpheus_test_utilities
test_utils/common.cpp
morpheus_test_utilities
test_utils/common.cpp
)

target_link_libraries(
morpheus_test_utilities
PRIVATE
PUBLIC
GTest::gtest
morpheus
)

function (add_morpheus_test TEST_NAME TEST_FILES)
# Morpheus Tests

add_executable(
test_${TEST_NAME}
${TEST_FILES}
function (add_morpheus_test)
set(options)
set(oneValueArgs NAME)
set(multiValueArgs FILES)
cmake_parse_arguments(
MORPHEUS_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}
)

target_link_libraries(
test_${TEST_NAME}
add_executable(test_${MORPHEUS_TEST_NAME}
${MORPHEUS_TEST_FILES}
)

target_link_libraries(test_${MORPHEUS_TEST_NAME}
PRIVATE
GTest::gtest
GTest::gtest_main
matx::matx
morpheus
morpheus_test_utilities
pybind11::embed
)

gtest_discover_tests(test_${TEST_NAME})
gtest_discover_tests(test_${MORPHEUS_TEST_NAME})

set_target_properties(test_${TEST_NAME}
set_target_properties(test_${MORPHEUS_TEST_NAME}
PROPERTIES
INSTALL_RPATH "$ORIGIN/.."
CUDA_STANDARD 17
Expand All @@ -60,60 +95,76 @@ function (add_morpheus_test TEST_NAME TEST_FILES)

install(
TARGETS
test_${TEST_NAME}
test_${MORPHEUS_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(
NAME io
FILES
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(
NAME messages
FILES
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(
NAME modules
FILES
modules/test_data_loader_module.cpp
)

add_morpheus_test(deserializers
test_deserializers.cpp
add_morpheus_test(
NAME deserializers
FILES
test_deserializers.cpp
)

add_morpheus_test(dev_mem_info
test_dev_mem_info.cpp
add_morpheus_test(
NAME dev_mem_info
FILES
test_dev_mem_info.cpp
)

add_morpheus_test(file_io
test_file_in_out.cpp
add_morpheus_test(
NAME file_in_out
FILES
test_file_in_out.cpp
)

add_morpheus_test(matx
test_matx_util.cpp
add_morpheus_test(
NAME matx_util
FILES
test_matx_util.cpp
)

add_morpheus_test(multi_slices
test_multi_slices.cpp
add_morpheus_test(
NAME multi_slices
FILES
test_multi_slices.cpp
)

add_morpheus_test(tensor
test_tensor.cpp
add_morpheus_test(
NAME tensor
FILES
test_tensor.cpp
)

add_morpheus_test(type_util
test_type_util.cpp
add_morpheus_test(
NAME type_util
FILES
test_type_util.cpp
)

list(POP_BACK CMAKE_MESSAGE_CONTEXT)
8 changes: 4 additions & 4 deletions morpheus/_lib/tests/io/test_io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

namespace morpheus::test {

TEST_CLASS(DataLoaderRegistry);
TEST_CLASS(Loader);
using TestLoader = TestWithPythonInterpreter; // NOLINT
using TestDataLoader = TestWithPythonInterpreter; // NOLINT
using TestDataLoaderRegistry = TestWithPythonInterpreter; // NOLINT

using TestDataLoader = TestWithPythonInterpreter; // NOLINT
} // namespace morpheus::test
} // namespace morpheus::test

0 comments on commit 7cbbb7e

Please sign in to comment.