diff options
author | dim <dim@FreeBSD.org> | 2014-11-24 09:15:30 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2014-11-24 09:15:30 +0000 |
commit | 173a4f43a911175643bda81ee675e8d9269056ea (patch) | |
tree | 47df2c12b57214af6c31e47404b005675b8b7ffc /unittests/Basic/FileManagerTest.cpp | |
parent | 88f7a7d5251a2d813460274c92decc143a11569b (diff) | |
download | FreeBSD-src-173a4f43a911175643bda81ee675e8d9269056ea.zip FreeBSD-src-173a4f43a911175643bda81ee675e8d9269056ea.tar.gz |
Vendor import of clang RELEASE_350/final tag r216957 (effectively, 3.5.0 release):
https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_350/final@216957
Diffstat (limited to 'unittests/Basic/FileManagerTest.cpp')
-rw-r--r-- | unittests/Basic/FileManagerTest.cpp | 57 |
1 files changed, 31 insertions, 26 deletions
diff --git a/unittests/Basic/FileManagerTest.cpp b/unittests/Basic/FileManagerTest.cpp index f8ce50d..b3bc767 100644 --- a/unittests/Basic/FileManagerTest.cpp +++ b/unittests/Basic/FileManagerTest.cpp @@ -11,6 +11,7 @@ #include "clang/Basic/FileSystemOptions.h" #include "clang/Basic/FileSystemStatCache.h" #include "gtest/gtest.h" +#include "llvm/Config/llvm-config.h" using namespace llvm; using namespace clang; @@ -28,10 +29,13 @@ private: void InjectFileOrDirectory(const char *Path, ino_t INode, bool IsFile) { FileData Data; - memset(&Data, 0, sizeof(FileData)); - llvm::sys::fs::UniqueID ID(1, INode); - Data.UniqueID = ID; + Data.Name = Path; + Data.Size = 0; + Data.ModTime = 0; + Data.UniqueID = llvm::sys::fs::UniqueID(1, INode); Data.IsDirectory = !IsFile; + Data.IsNamedPipe = false; + Data.InPCH = false; StatCalls[Path] = Data; } @@ -47,8 +51,9 @@ public: } // Implement FileSystemStatCache::getStat(). - virtual LookupResult getStat(const char *Path, FileData &Data, bool isFile, - int *FileDescriptor) { + LookupResult getStat(const char *Path, FileData &Data, bool isFile, + std::unique_ptr<vfs::File> *F, + vfs::FileSystem &FS) override { if (StatCalls.count(Path) != 0) { Data = StatCalls[Path]; return CacheExists; @@ -72,17 +77,17 @@ class FileManagerTest : public ::testing::Test { // (not NULL, correct name). TEST_F(FileManagerTest, getVirtualFileSetsTheDirFieldCorrectly) { const FileEntry *file = manager.getVirtualFile("foo.cpp", 42, 0); - ASSERT_TRUE(file != NULL); + ASSERT_TRUE(file != nullptr); const DirectoryEntry *dir = file->getDir(); - ASSERT_TRUE(dir != NULL); + ASSERT_TRUE(dir != nullptr); EXPECT_STREQ(".", dir->getName()); file = manager.getVirtualFile("x/y/z.cpp", 42, 0); - ASSERT_TRUE(file != NULL); + ASSERT_TRUE(file != nullptr); dir = file->getDir(); - ASSERT_TRUE(dir != NULL); + ASSERT_TRUE(dir != nullptr); EXPECT_STREQ("x/y", dir->getName()); } @@ -94,9 +99,9 @@ TEST_F(FileManagerTest, NoVirtualDirectoryExistsBeforeAVirtualFileIsAdded) { // by what's in the real file system. manager.addStatCache(new FakeStatCache); - EXPECT_EQ(NULL, manager.getDirectory("virtual/dir/foo")); - EXPECT_EQ(NULL, manager.getDirectory("virtual/dir")); - EXPECT_EQ(NULL, manager.getDirectory("virtual")); + EXPECT_EQ(nullptr, manager.getDirectory("virtual/dir/foo")); + EXPECT_EQ(nullptr, manager.getDirectory("virtual/dir")); + EXPECT_EQ(nullptr, manager.getDirectory("virtual")); } // When a virtual file is added, all of its ancestors should be created. @@ -105,14 +110,14 @@ TEST_F(FileManagerTest, getVirtualFileCreatesDirectoryEntriesForAncestors) { manager.addStatCache(new FakeStatCache); manager.getVirtualFile("virtual/dir/bar.h", 100, 0); - EXPECT_EQ(NULL, manager.getDirectory("virtual/dir/foo")); + EXPECT_EQ(nullptr, manager.getDirectory("virtual/dir/foo")); const DirectoryEntry *dir = manager.getDirectory("virtual/dir"); - ASSERT_TRUE(dir != NULL); + ASSERT_TRUE(dir != nullptr); EXPECT_STREQ("virtual/dir", dir->getName()); dir = manager.getDirectory("virtual"); - ASSERT_TRUE(dir != NULL); + ASSERT_TRUE(dir != nullptr); EXPECT_STREQ("virtual", dir->getName()); } @@ -123,7 +128,7 @@ TEST_F(FileManagerTest, getFileReturnsValidFileEntryForExistingRealFile) { statCache->InjectDirectory("/tmp", 42); statCache->InjectFile("/tmp/test", 43); -#ifdef _WIN32 +#ifdef LLVM_ON_WIN32 const char *DirName = "C:."; const char *FileName = "C:test"; statCache->InjectDirectory(DirName, 44); @@ -133,14 +138,14 @@ TEST_F(FileManagerTest, getFileReturnsValidFileEntryForExistingRealFile) { manager.addStatCache(statCache); const FileEntry *file = manager.getFile("/tmp/test"); - ASSERT_TRUE(file != NULL); + ASSERT_TRUE(file != nullptr); EXPECT_STREQ("/tmp/test", file->getName()); const DirectoryEntry *dir = file->getDir(); - ASSERT_TRUE(dir != NULL); + ASSERT_TRUE(dir != nullptr); EXPECT_STREQ("/tmp", dir->getName()); -#ifdef _WIN32 +#ifdef LLVM_ON_WIN32 file = manager.getFile(FileName); ASSERT_TRUE(file != NULL); @@ -157,11 +162,11 @@ TEST_F(FileManagerTest, getFileReturnsValidFileEntryForExistingVirtualFile) { manager.getVirtualFile("virtual/dir/bar.h", 100, 0); const FileEntry *file = manager.getFile("virtual/dir/bar.h"); - ASSERT_TRUE(file != NULL); + ASSERT_TRUE(file != nullptr); EXPECT_STREQ("virtual/dir/bar.h", file->getName()); const DirectoryEntry *dir = file->getDir(); - ASSERT_TRUE(dir != NULL); + ASSERT_TRUE(dir != nullptr); EXPECT_STREQ("virtual/dir", dir->getName()); } @@ -178,8 +183,8 @@ TEST_F(FileManagerTest, getFileReturnsDifferentFileEntriesForDifferentFiles) { const FileEntry *fileFoo = manager.getFile("foo.cpp"); const FileEntry *fileBar = manager.getFile("bar.cpp"); - ASSERT_TRUE(fileFoo != NULL); - ASSERT_TRUE(fileBar != NULL); + ASSERT_TRUE(fileFoo != nullptr); + ASSERT_TRUE(fileBar != nullptr); EXPECT_NE(fileFoo, fileBar); } @@ -196,12 +201,12 @@ TEST_F(FileManagerTest, getFileReturnsNULLForNonexistentFile) { manager.getVirtualFile("bar.cpp", 200, 0); const FileEntry *file = manager.getFile("xyz.txt"); - EXPECT_EQ(NULL, file); + EXPECT_EQ(nullptr, file); } // The following tests apply to Unix-like system only. -#ifndef _WIN32 +#ifndef LLVM_ON_WIN32 // getFile() returns the same FileEntry for real files that are aliases. TEST_F(FileManagerTest, getFileReturnsSameFileEntryForAliasedRealFiles) { @@ -231,6 +236,6 @@ TEST_F(FileManagerTest, getFileReturnsSameFileEntryForAliasedVirtualFiles) { EXPECT_EQ(manager.getFile("abc/foo.cpp"), manager.getFile("abc/bar.cpp")); } -#endif // !_WIN32 +#endif // !LLVM_ON_WIN32 } // anonymous namespace |