Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ambiguous segfault for test requiring MORPHEUS_ROOT #514

Merged
11 commits merged into from
Dec 8, 2022
5 changes: 3 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ RUN apt-get update &&\
SHELL ["/bin/bash", "-c"]

# All code will be under /workspace
WORKDIR /workspace
ENV MORPHEUS_ROOT=/workspace
WORKDIR ${MORPHEUS_ROOT}

# Install mamba to speed the solve up
RUN conda config --set ssl_verify false &&\
Expand Down Expand Up @@ -125,7 +126,7 @@ RUN --mount=type=cache,id=workspace_cache,target=/workspace/.cache,sharing=locke
source activate base &&\
# Need to get around recent versions of git locking paths until they are deemed safe
git config --global --add safe.directory "*" &&\
MORPHEUS_ROOT=/workspace MORPHEUS_BUILD_PYTHON_STUBS=OFF CONDA_BLD_PATH=/opt/conda/conda-bld CONDA_ARGS="--no-test" ./ci/conda/recipes/run_conda_build.sh morpheus
MORPHEUS_BUILD_PYTHON_STUBS=OFF CONDA_BLD_PATH=/opt/conda/conda-bld CONDA_ARGS="--no-test" ./ci/conda/recipes/run_conda_build.sh morpheus

# sid_visualization is a submodule we need to init
RUN git submodule update --init --recursive
Expand Down
1 change: 1 addition & 0 deletions morpheus/_lib/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ add_executable(test_libmorpheus
# test_cuda.cu
test_main.cpp
test_matx_util.cpp
test_morpheus.cpp
test_multi_slices.cpp
test_tensor.cpp
test_type_util_detail.cpp
Expand Down
3 changes: 1 addition & 2 deletions morpheus/_lib/tests/test_matx_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@

#include <cstdint> // for int64_t, int32_t, uint8_t
#include <cstdlib> // for std::getenv
#include <filesystem>
#include <memory> // for shared_ptr, make_shared, unique_ptr
#include <string>
#include <vector>
Expand Down Expand Up @@ -133,7 +132,7 @@ TEST_F(TestMatxUtil, ReduceMax2dRowMajor)

TEST_F(TestMatxUtil, ReduceMax2dColMajor)
{
std::filesystem::path morpheus_root{std::getenv("MORPHEUS_ROOT")};
auto morpheus_root = test::get_morpheus_root();
auto input_file = morpheus_root / "tests/tests_data/filter_probs.csv";

auto table_m = morpheus::load_table_from_file(input_file);
Expand Down
35 changes: 35 additions & 0 deletions morpheus/_lib/tests/test_morpheus.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* SPDX-FileCopyrightText: Copyright (c) 2018-2022, 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 <filesystem>
#include <stdexcept>

namespace morpheus::test {

std::filesystem::path get_morpheus_root()
{
auto root = std::getenv("MORPHEUS_ROOT");

if (root == nullptr)
{
throw std::runtime_error("MORPHEUS_ROOT env variable is not set");
}

return std::filesystem::path{root};
}

} // namespace morpheus::test
11 changes: 11 additions & 0 deletions morpheus/_lib/tests/test_morpheus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@
#include <glog/logging.h> // IWYU pragma: keep
#include <gtest/gtest.h> // IWYU pragma: keep

#include <filesystem>

#define TEST_CLASS(name) \
class Test##name : public ::testing::Test \
{}

namespace morpheus::test {

/**
* @brief Gets the `MORPHEUS_ROOT` env variable or throws a runtime_error.
* @return std::filesystem::path
*/
std::filesystem::path get_morpheus_root();
cwharris marked this conversation as resolved.
Show resolved Hide resolved
}