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
Prev Previous commit
Next Next commit
move get_morpheus_root to its own file.
  • Loading branch information
cwharris committed Dec 7, 2022
commit e4eaa14ee4591bef040eb94bf6ec33f5a72cfaa7
1 change: 1 addition & 0 deletions morpheus/_lib/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ list(APPEND CMAKE_MESSAGE_CONTEXT "tests")
# Keep all source files sorted
add_executable(test_libmorpheus
# test_cuda.cu
test_morpheus.cpp
cwharris marked this conversation as resolved.
Show resolved Hide resolved
test_main.cpp
test_matx_util.cpp
test_multi_slices.cpp
Expand Down
2 changes: 1 addition & 1 deletion morpheus/_lib/tests/test_matx_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ TEST_F(TestMatxUtil, ReduceMax2dRowMajor)

TEST_F(TestMatxUtil, ReduceMax2dColMajor)
{
auto morpheus_root = get_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
36 changes: 36 additions & 0 deletions morpheus/_lib/tests/test_morpheus.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* 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};
}

}
12 changes: 2 additions & 10 deletions morpheus/_lib/tests/test_morpheus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,12 @@
#include <gtest/gtest.h> // IWYU pragma: keep

#include <filesystem>
#include <stdexcept>

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

std::filesystem::path get_morpheus_root()
namespace morpheus::test
{
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};
std::filesystem::path get_morpheus_root();
}