diff options
author | Eric Liu <ioeric@google.com> | 2018-05-24 11:17:00 +0000 |
---|---|---|
committer | Eric Liu <ioeric@google.com> | 2018-05-24 11:17:00 +0000 |
commit | 33dd619c804d65c40a07f769da06b7462bdb073a (patch) | |
tree | 6e60a95ec779a5516cae5f2f4d11f3adf46e3225 /clang/unittests/Basic/VirtualFileSystemTest.cpp | |
parent | 34391f097d9350d59d3050bf149c0f536dd460da (diff) | |
download | llvm-33dd619c804d65c40a07f769da06b7462bdb073a.zip llvm-33dd619c804d65c40a07f769da06b7462bdb073a.tar.gz llvm-33dd619c804d65c40a07f769da06b7462bdb073a.tar.bz2 |
[VFS] Implement getRealPath in InMemoryFileSystem.
Reviewers: bkramer
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D47262
llvm-svn: 333172
Diffstat (limited to 'clang/unittests/Basic/VirtualFileSystemTest.cpp')
-rw-r--r-- | clang/unittests/Basic/VirtualFileSystemTest.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/clang/unittests/Basic/VirtualFileSystemTest.cpp b/clang/unittests/Basic/VirtualFileSystemTest.cpp index 673eca8..e510c3e 100644 --- a/clang/unittests/Basic/VirtualFileSystemTest.cpp +++ b/clang/unittests/Basic/VirtualFileSystemTest.cpp @@ -813,6 +813,28 @@ TEST_F(InMemoryFileSystemTest, WorkingDirectory) { NormalizedFS.getCurrentWorkingDirectory().get())); } +TEST_F(InMemoryFileSystemTest, GetRealPath) { + SmallString<16> Path; + EXPECT_EQ(FS.getRealPath("b", Path), errc::operation_not_permitted); + + auto GetRealPath = [this](StringRef P) { + SmallString<16> Output; + auto EC = FS.getRealPath(P, Output); + EXPECT_FALSE(EC); + return Output.str().str(); + }; + + FS.setCurrentWorkingDirectory("a"); + EXPECT_EQ(GetRealPath("b"), "a/b"); + EXPECT_EQ(GetRealPath("../b"), "b"); + EXPECT_EQ(GetRealPath("b/./c"), "a/b/c"); + + FS.setCurrentWorkingDirectory("/a"); + EXPECT_EQ(GetRealPath("b"), "/a/b"); + EXPECT_EQ(GetRealPath("../b"), "/b"); + EXPECT_EQ(GetRealPath("b/./c"), "/a/b/c"); +} + TEST_F(InMemoryFileSystemTest, AddFileWithUser) { FS.addFile("/a/b/c", 0, MemoryBuffer::getMemBuffer("abc"), 0xFEEDFACE); auto Stat = FS.status("/a"); |