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

GTEST/UCT: Add ability to filter by resource or md name #10205

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion test/gtest/uct/test_md.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,14 @@ void test_md::test_reg_mem(unsigned access_mask,
std::vector<test_md_param> test_md::enum_mds(const std::string& cmpt_name) {

std::vector<md_resource> md_resources = enum_md_resources();
static const char *str = getenv("GTEST_UCT_MD_NAME");
std::string md_name = (str != NULL) ? str : "";

std::vector<test_md_param> result;
for (std::vector<md_resource>::iterator iter = md_resources.begin();
iter != md_resources.end(); ++iter) {
if (iter->cmpt_attr.name == cmpt_name) {
if ((iter->cmpt_attr.name == cmpt_name) &&
(md_name.empty() || (md_name == iter->rsc_desc.md_name))) {
result.push_back(test_md_param());
result.back().component = iter->cmpt;
result.back().md_name = iter->rsc_desc.md_name;
Expand Down
11 changes: 11 additions & 0 deletions test/gtest/uct/uct_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,8 @@ void uct_test::set_cm_resources(std::vector<resource>& all_resources)
std::vector<const resource*> uct_test::enum_resources(const std::string& tl_name)
{
static bool tcp_fastest_dev = (getenv("GTEST_UCT_TCP_FASTEST_DEV") != NULL);
static const char *str = getenv("GTEST_UCT_RSC_NAME");
brminich marked this conversation as resolved.
Show resolved Hide resolved
std::string dev_name = (str != NULL) ? str : "";
static std::vector<resource> all_resources;

if (all_resources.empty()) {
Expand Down Expand Up @@ -429,6 +431,11 @@ std::vector<const resource*> uct_test::enum_resources(const std::string& tl_name
resource_speed tcp_fastest_rsc;

for (unsigned j = 0; j < num_tl_resources; ++j) {
if (!dev_name.empty() &&
(tl_resources[j].dev_name != dev_name)) {
continue;
}

if (tcp_fastest_dev && (std::string("tcp") ==
tl_resources[j].tl_name)) {
resource_speed rsc(iter->cmpt, iter->cmpt_attr, worker, md,
Expand Down Expand Up @@ -461,6 +468,10 @@ std::vector<const resource*> uct_test::enum_resources(const std::string& tl_name
ucs_async_context_destroy(async);
}

if (all_resources.empty()) {
UCS_TEST_ABORT("Could not add any resource");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why needed? do we want to force failure when some resources not found?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after adding that filtering, I want to make sure we have at least one interface, to in usability as we cannot run test without any resource, and we get crash otherwise.

}

return filter_resources(all_resources, resource::is_equal_tl_name, tl_name);
}

Expand Down
Loading