| 47 | }; |
| 48 | |
| 49 | TEST_F(TraceUtilTest, traceDir) { |
| 50 | const auto outputDir = TempDirectoryPath::create(); |
| 51 | const auto rootDir = outputDir->getPath(); |
| 52 | const auto fs = filesystems::getFileSystem(rootDir, nullptr); |
| 53 | auto dir1 = fmt::format("{}/{}", outputDir->getPath(), "t1"); |
| 54 | trace::createTraceDirectory(dir1); |
| 55 | ASSERT_TRUE(fs->exists(dir1)); |
| 56 | |
| 57 | auto dir2 = fmt::format("{}/{}", dir1, "t1_1"); |
| 58 | trace::createTraceDirectory(dir2); |
| 59 | ASSERT_TRUE(fs->exists(dir2)); |
| 60 | |
| 61 | // It will remove the old dir1 along with its subdir when created the dir1 |
| 62 | // again. |
| 63 | trace::createTraceDirectory(dir1); |
| 64 | ASSERT_TRUE(fs->exists(dir1)); |
| 65 | ASSERT_FALSE(fs->exists(dir2)); |
| 66 | |
| 67 | const auto parentDir = fmt::format("{}/{}", outputDir->getPath(), "p"); |
| 68 | fs->mkdir(parentDir); |
| 69 | |
| 70 | constexpr auto numThreads = 5; |
| 71 | std::vector<std::thread> traceThreads; |
| 72 | traceThreads.reserve(numThreads); |
| 73 | std::mutex mutex; |
| 74 | std::set<std::string> expectedDirs; |
| 75 | for (int i = 0; i < numThreads; ++i) { |
| 76 | traceThreads.emplace_back([&, i]() { |
| 77 | const auto dir = fmt::format("{}/s{}", parentDir, i); |
| 78 | trace::createTraceDirectory(dir); |
| 79 | std::lock_guard<std::mutex> l(mutex); |
| 80 | expectedDirs.insert(dir); |
| 81 | }); |
| 82 | } |
| 83 | |
| 84 | for (auto& traceThread : traceThreads) { |
| 85 | traceThread.join(); |
| 86 | } |
| 87 | |
| 88 | const auto actualDirs = fs->list(parentDir); |
| 89 | ASSERT_EQ(actualDirs.size(), numThreads); |
| 90 | ASSERT_EQ(actualDirs.size(), expectedDirs.size()); |
| 91 | for (const auto& dir : actualDirs) { |
| 92 | ASSERT_EQ(expectedDirs.count(dir), 1); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | TEST_F(TraceUtilTest, OperatorTraceSummary) { |
| 97 | exec::trace::OperatorTraceSummary summary; |
nothing calls this directly
no test coverage detected