Skip to content

Commit

Permalink
Add test for deprecated env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
facuMH committed Feb 22, 2023
1 parent 5604c07 commit 7b294ce
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,11 @@ namespace detail {
for(size_t i = 0; i < split_str.size(); ++i) {
devices.push_back(env::default_parser<size_t>{}(split_str[i]));
}
if(devices.size() < 2)
if(devices.size() < 2) {
throw env::validation_error{fmt::format(
"Found {} IDs.\nExpected the following format: CELERITY_DEVICES=\"<platform_id> <first device_id> <second device_id> ... <nth device_id>\"",
std::to_string(devices.size()))};
devices.size())};
}

if(static_cast<long>(m_host_cfg.local_rank) > static_cast<long>(devices.size()) - 2) {
throw env::validation_error{fmt::format(
Expand All @@ -103,12 +104,12 @@ namespace detail {
}

bool config::parse_validate_force_wg(const std::string_view str) {
throw env::validation_error{fmt::format("Support for CELERITY_FORCE_WG has been removed with Celerity 0.3.0.")};
throw env::validation_error{"Support for CELERITY_FORCE_WG has been removed with Celerity 0.3.0."};
return false;
}

bool config::parse_validate_profile_ocl(const std::string_view str) {
throw env::validation_error{fmt::format("CELERITY_PROFILE_OCL has been renamed to CELERITY_PROFILE_KERNEL with Celerity 0.3.0.")};
throw env::validation_error{"CELERITY_PROFILE_OCL has been renamed to CELERITY_PROFILE_KERNEL with Celerity 0.3.0."};
return false;
}

Expand Down
11 changes: 11 additions & 0 deletions test/runtime_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,17 @@ namespace detail {
const auto test_env = env::scoped_test_environment(invalid_test_env_var);
CHECK_THROWS_WITH((celerity::detail::config(nullptr, nullptr)), error_string);
}
{
std::unordered_map<std::string, std::string> invalid_test_env_var{{"CELERITY_FORCE_WG", "a"}};
const auto test_env = env::scoped_test_environment(invalid_test_env_var);
CHECK_THROWS_WITH((celerity::detail::config(nullptr, nullptr)), error_string);
}

{
std::unordered_map<std::string, std::string> invalid_test_env_var{{"CELERITY_PROFILE_OCL", "a"}};
const auto test_env = env::scoped_test_environment(invalid_test_env_var);
CHECK_THROWS_WITH((celerity::detail::config(nullptr, nullptr)), error_string);
}
}

} // namespace detail
Expand Down

0 comments on commit 7b294ce

Please sign in to comment.