summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support/FileCollectorTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests/Support/FileCollectorTest.cpp')
-rw-r--r--llvm/unittests/Support/FileCollectorTest.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/llvm/unittests/Support/FileCollectorTest.cpp b/llvm/unittests/Support/FileCollectorTest.cpp
index 07e745ce8f2..5505e884aa1 100644
--- a/llvm/unittests/Support/FileCollectorTest.cpp
+++ b/llvm/unittests/Support/FileCollectorTest.cpp
@@ -179,6 +179,44 @@ TEST(FileCollectorTest, recordAndConstructDirectory) {
ASSERT_TRUE(IsDirectory);
}
+TEST(FileCollectorTest, recordVFSAccesses) {
+ ScopedDir file_root("dir_root", true);
+ ScopedDir subdir(file_root + "/subdir");
+ ScopedDir subdir2(file_root + "/subdir2");
+ ScopedFile a(subdir2 + "/a");
+ ScopedFile b(file_root + "/b");
+ ScopedDir subdir3(file_root + "/subdir3");
+ ScopedFile subdir3a(subdir3 + "/aa");
+ ScopedDir subdir3b(subdir3 + "/subdirb");
+ {
+ ScopedFile subdir3fileremoved(subdir3 + "/removed");
+ }
+
+ // Create file collector and add files.
+ ScopedDir root("copy_files_root", true);
+ std::string root_fs = root.Path.str();
+ auto Collector = std::make_shared<TestingFileCollector>(root_fs, root_fs);
+ auto VFS =
+ FileCollector::createCollectorVFS(vfs::getRealFileSystem(), Collector);
+ VFS->status(a.Path);
+ EXPECT_TRUE(Collector->hasSeen(a.Path));
+
+ VFS->openFileForRead(b.Path);
+ EXPECT_TRUE(Collector->hasSeen(b.Path));
+
+ VFS->status(subdir.Path);
+ EXPECT_TRUE(Collector->hasSeen(subdir.Path));
+
+ std::error_code EC;
+ auto It = VFS->dir_begin(subdir3.Path, EC);
+ EXPECT_FALSE(EC);
+ EXPECT_TRUE(Collector->hasSeen(subdir3.Path));
+ EXPECT_TRUE(Collector->hasSeen(subdir3a.Path));
+ EXPECT_TRUE(Collector->hasSeen(subdir3b.Path));
+ std::string RemovedFileName = (Twine(subdir3.Path) + "/removed").str();
+ EXPECT_FALSE(Collector->hasSeen(RemovedFileName));
+}
+
#ifndef _WIN32
TEST(FileCollectorTest, Symlinks) {
// Root where the original files live.
@@ -239,4 +277,21 @@ TEST(FileCollectorTest, Symlinks) {
EXPECT_THAT(mapping, testing::Contains(vfs::YAMLVFSEntry(vpath, rpath)));
}
}
+
+TEST(FileCollectorTest, recordVFSSymlinkAccesses) {
+ ScopedDir file_root("dir_root", true);
+ ScopedFile a(file_root + "/a");
+ ScopedLink symlink(file_root + "/a", file_root + "/b");
+
+ // Create file collector and add files.
+ ScopedDir root("copy_files_root", true);
+ std::string root_fs = root.Path.str();
+ auto Collector = std::make_shared<TestingFileCollector>(root_fs, root_fs);
+ auto VFS =
+ FileCollector::createCollectorVFS(vfs::getRealFileSystem(), Collector);
+ SmallString<256> Output;
+ VFS->getRealPath(symlink.Path, Output);
+ EXPECT_TRUE(Collector->hasSeen(a.Path));
+ EXPECT_TRUE(Collector->hasSeen(symlink.Path));
+}
#endif
OpenPOWER on IntegriCloud