diff options
| author | Jonas Devlieghere <jonas@devlieghere.com> | 2019-07-03 00:45:53 +0000 |
|---|---|---|
| committer | Jonas Devlieghere <jonas@devlieghere.com> | 2019-07-03 00:45:53 +0000 |
| commit | efe21088d76c091a29bc7990ef9cf502e1f1bf62 (patch) | |
| tree | ef4a788cc7fcf1e2f90c5315a23ab7e55279dc78 /llvm/unittests/Support | |
| parent | b88ebe8cc9a8585647fdbff14b92841582be50a9 (diff) | |
| download | bcm5719-llvm-efe21088d76c091a29bc7990ef9cf502e1f1bf62.tar.gz bcm5719-llvm-efe21088d76c091a29bc7990ef9cf502e1f1bf62.zip | |
[VFS] Add reverse iterator to OverlayFileSystem
Add a reverse iterator to the overlay file system. This makes it
possible to take overlays from one OverlayFileSystem, and add them to
another.
Differential revision: https://reviews.llvm.org/D64113
llvm-svn: 364986
Diffstat (limited to 'llvm/unittests/Support')
| -rw-r--r-- | llvm/unittests/Support/VirtualFileSystemTest.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/llvm/unittests/Support/VirtualFileSystemTest.cpp b/llvm/unittests/Support/VirtualFileSystemTest.cpp index 55cb597cc43..a867bc57e94 100644 --- a/llvm/unittests/Support/VirtualFileSystemTest.cpp +++ b/llvm/unittests/Support/VirtualFileSystemTest.cpp @@ -342,6 +342,57 @@ TEST(VirtualFileSystemTest, MergedDirPermissions) { EXPECT_EQ(0200, Status->getPermissions()); } +TEST(VirtualFileSystemTest, OverlayIterator) { + IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem()); + Lower->addRegularFile("/foo"); + IntrusiveRefCntPtr<DummyFileSystem> Upper(new DummyFileSystem()); + + IntrusiveRefCntPtr<vfs::OverlayFileSystem> O( + new vfs::OverlayFileSystem(Lower)); + O->pushOverlay(Upper); + + ErrorOr<vfs::Status> Status((std::error_code())); + { + auto it = O->overlays_begin(); + auto end = O->overlays_end(); + + EXPECT_NE(it, end); + + Status = (*it)->status("/foo"); + ASSERT_TRUE(Status.getError()); + + it++; + EXPECT_NE(it, end); + + Status = (*it)->status("/foo"); + ASSERT_FALSE(Status.getError()); + EXPECT_TRUE(Status->exists()); + + it++; + EXPECT_EQ(it, end); + } + + { + auto it = O->overlays_rbegin(); + auto end = O->overlays_rend(); + + EXPECT_NE(it, end); + + Status = (*it)->status("/foo"); + ASSERT_FALSE(Status.getError()); + EXPECT_TRUE(Status->exists()); + + it++; + EXPECT_NE(it, end); + + Status = (*it)->status("/foo"); + ASSERT_TRUE(Status.getError()); + + it++; + EXPECT_EQ(it, end); + } +} + namespace { struct ScopedDir { SmallString<128> Path; |

