xref: /aosp_15_r20/external/pytorch/test/cpp/c10d/ProcessGroupUCCTest.cpp (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1 #include <gtest/gtest.h>
2 #include <torch/csrc/distributed/c10d/UCCUtils.hpp>
3 
4 #include <utility>
5 #include <vector>
6 
7 using namespace c10d;
8 
TEST(ProcessGroupUCCTest,testTrim)9 TEST(ProcessGroupUCCTest, testTrim) {
10   std::vector<std::pair<std::string, std::string>> tests = {
11       {" allreduce ", "allreduce"},
12       {"\tallgather", "allgather"},
13       {"send\n", "send"},
14   };
15   for (auto entry : tests) {
16     ASSERT_EQ(trim(entry.first), entry.second);
17   }
18 }
19 
TEST(ProcessGroupUCCTest,testToLower)20 TEST(ProcessGroupUCCTest, testToLower) {
21   std::vector<std::pair<std::string, std::string>> tests = {
22       {"AllReduce", "allreduce"},
23       {"ALLGATHER", "allgather"},
24       {"send", "send"},
25   };
26   for (auto entry : tests) {
27     ASSERT_EQ(tolower(entry.first), entry.second);
28   }
29 }
30 
TEST(ProcessGroupUCCTest,testParseList)31 TEST(ProcessGroupUCCTest, testParseList) {
32   std::string input = "\tAllReduce, ALLGATHER, send\n";
33   std::vector<std::string> expect{"allreduce", "allgather", "send"};
34   ASSERT_EQ(parse_list(input), expect);
35 }
36