summaryrefslogtreecommitdiffstats
path: root/lldb/unittests
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2018-10-31 21:49:27 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2018-10-31 21:49:27 +0000
commit46376966ea0f7ea9935e5d27deb423d5d9b72eff (patch)
treef67a900874bc732e7bec2afe10764076cbacc3c1 /lldb/unittests
parent063fd98bcc06e49009df8cbd18484a81a612aeb6 (diff)
downloadbcm5719-llvm-46376966ea0f7ea9935e5d27deb423d5d9b72eff.tar.gz
bcm5719-llvm-46376966ea0f7ea9935e5d27deb423d5d9b72eff.zip
[FileSystem] Extend file system and have it use the VFS.
This patch extends the FileSystem class with a bunch of functions that are currently implemented as methods of the FileSpec class. These methods will be removed in future commits and replaced by calls to the file system. The new functions are operated in terms of the virtual file system which was recently moved from clang into LLVM so it could be reused in lldb. Because the VFS is stateful, we turned the FileSystem class into a singleton. Differential revision: https://reviews.llvm.org/D53532 llvm-svn: 345783
Diffstat (limited to 'lldb/unittests')
-rw-r--r--lldb/unittests/Core/MangledTest.cpp3
-rw-r--r--lldb/unittests/Expression/ClangParserTest.cpp11
-rw-r--r--lldb/unittests/Host/FileSystemTest.cpp263
-rw-r--r--lldb/unittests/Host/HostInfoTest.cpp19
-rw-r--r--lldb/unittests/Host/SymbolsTest.cpp27
-rw-r--r--lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp3
-rw-r--r--lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp4
-rw-r--r--lldb/unittests/Symbol/TestClangASTContext.cpp17
-rw-r--r--lldb/unittests/Symbol/TestDWARFCallFrameInfo.cpp10
-rw-r--r--lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp15
-rw-r--r--lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp3
-rw-r--r--lldb/unittests/Target/ModuleCacheTest.cpp5
12 files changed, 350 insertions, 30 deletions
diff --git a/lldb/unittests/Core/MangledTest.cpp b/lldb/unittests/Core/MangledTest.cpp
index 40df29621fa..b727e3bb939 100644
--- a/lldb/unittests/Core/MangledTest.cpp
+++ b/lldb/unittests/Core/MangledTest.cpp
@@ -14,6 +14,7 @@
#include "lldb/Core/Mangled.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
+#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Symbol/SymbolContext.h"
@@ -61,6 +62,7 @@ TEST(MangledTest, EmptyForInvalidName) {
}
TEST(MangledTest, NameIndexes_FindFunctionSymbols) {
+ FileSystem::Initialize();
HostInfo::Initialize();
ObjectFileELF::Initialize();
SymbolVendorELF::Initialize();
@@ -167,4 +169,5 @@ TEST(MangledTest, NameIndexes_FindFunctionSymbols) {
SymbolVendorELF::Terminate();
ObjectFileELF::Terminate();
HostInfo::Terminate();
+ FileSystem::Terminate();
}
diff --git a/lldb/unittests/Expression/ClangParserTest.cpp b/lldb/unittests/Expression/ClangParserTest.cpp
index c776e48c952..f6a16cce287 100644
--- a/lldb/unittests/Expression/ClangParserTest.cpp
+++ b/lldb/unittests/Expression/ClangParserTest.cpp
@@ -9,6 +9,7 @@
#include "Plugins/ExpressionParser/Clang/ClangHost.h"
#include "TestingSupport/TestUtilities.h"
+#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/lldb-defines.h"
@@ -18,8 +19,14 @@ using namespace lldb_private;
namespace {
struct ClangHostTest : public testing::Test {
- static void SetUpTestCase() { HostInfo::Initialize(); }
- static void TearDownTestCase() { HostInfo::Terminate(); }
+ static void SetUpTestCase() {
+ FileSystem::Initialize();
+ HostInfo::Initialize();
+ }
+ static void TearDownTestCase() {
+ HostInfo::Terminate();
+ FileSystem::Terminate();
+ }
};
} // namespace
diff --git a/lldb/unittests/Host/FileSystemTest.cpp b/lldb/unittests/Host/FileSystemTest.cpp
index d5160b1a0da..142ad7bb9ce 100644
--- a/lldb/unittests/Host/FileSystemTest.cpp
+++ b/lldb/unittests/Host/FileSystemTest.cpp
@@ -7,13 +7,154 @@
//
//===----------------------------------------------------------------------===//
+#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "lldb/Host/FileSystem.h"
+#include "llvm/Support/Errc.h"
extern const char *TestMainArgv0;
using namespace lldb_private;
+using namespace llvm;
+using llvm::sys::fs::UniqueID;
+
+// Modified from llvm/unittests/Support/VirtualFileSystemTest.cpp
+namespace {
+struct DummyFile : public vfs::File {
+ vfs::Status S;
+ explicit DummyFile(vfs::Status S) : S(S) {}
+ llvm::ErrorOr<vfs::Status> status() override { return S; }
+ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
+ getBuffer(const Twine &Name, int64_t FileSize, bool RequiresNullTerminator,
+ bool IsVolatile) override {
+ llvm_unreachable("unimplemented");
+ }
+ std::error_code close() override { return std::error_code(); }
+};
+
+class DummyFileSystem : public vfs::FileSystem {
+ int FSID; // used to produce UniqueIDs
+ int FileID; // used to produce UniqueIDs
+ std::string cwd;
+ std::map<std::string, vfs::Status> FilesAndDirs;
+
+ static int getNextFSID() {
+ static int Count = 0;
+ return Count++;
+ }
+
+public:
+ DummyFileSystem() : FSID(getNextFSID()), FileID(0) {}
+
+ ErrorOr<vfs::Status> status(const Twine &Path) override {
+ std::map<std::string, vfs::Status>::iterator I =
+ FilesAndDirs.find(Path.str());
+ if (I == FilesAndDirs.end())
+ return make_error_code(llvm::errc::no_such_file_or_directory);
+ return I->second;
+ }
+ ErrorOr<std::unique_ptr<vfs::File>>
+ openFileForRead(const Twine &Path) override {
+ auto S = status(Path);
+ if (S)
+ return std::unique_ptr<vfs::File>(new DummyFile{*S});
+ return S.getError();
+ }
+ llvm::ErrorOr<std::string> getCurrentWorkingDirectory() const override {
+ return cwd;
+ }
+ std::error_code setCurrentWorkingDirectory(const Twine &Path) override {
+ cwd = Path.str();
+ return std::error_code();
+ }
+ // Map any symlink to "/symlink".
+ std::error_code getRealPath(const Twine &Path,
+ SmallVectorImpl<char> &Output) const override {
+ auto I = FilesAndDirs.find(Path.str());
+ if (I == FilesAndDirs.end())
+ return make_error_code(llvm::errc::no_such_file_or_directory);
+ if (I->second.isSymlink()) {
+ Output.clear();
+ Twine("/symlink").toVector(Output);
+ return std::error_code();
+ }
+ Output.clear();
+ Path.toVector(Output);
+ return std::error_code();
+ }
+
+ struct DirIterImpl : public llvm::vfs::detail::DirIterImpl {
+ std::map<std::string, vfs::Status> &FilesAndDirs;
+ std::map<std::string, vfs::Status>::iterator I;
+ std::string Path;
+ bool isInPath(StringRef S) {
+ if (Path.size() < S.size() && S.find(Path) == 0) {
+ auto LastSep = S.find_last_of('/');
+ if (LastSep == Path.size() || LastSep == Path.size() - 1)
+ return true;
+ }
+ return false;
+ }
+ DirIterImpl(std::map<std::string, vfs::Status> &FilesAndDirs,
+ const Twine &_Path)
+ : FilesAndDirs(FilesAndDirs), I(FilesAndDirs.begin()),
+ Path(_Path.str()) {
+ for (; I != FilesAndDirs.end(); ++I) {
+ if (isInPath(I->first)) {
+ CurrentEntry =
+ vfs::directory_entry(I->second.getName(), I->second.getType());
+ break;
+ }
+ }
+ }
+ std::error_code increment() override {
+ ++I;
+ for (; I != FilesAndDirs.end(); ++I) {
+ if (isInPath(I->first)) {
+ CurrentEntry =
+ vfs::directory_entry(I->second.getName(), I->second.getType());
+ break;
+ }
+ }
+ if (I == FilesAndDirs.end())
+ CurrentEntry = vfs::directory_entry();
+ return std::error_code();
+ }
+ };
+
+ vfs::directory_iterator dir_begin(const Twine &Dir,
+ std::error_code &EC) override {
+ return vfs::directory_iterator(
+ std::make_shared<DirIterImpl>(FilesAndDirs, Dir));
+ }
+
+ void addEntry(StringRef Path, const vfs::Status &Status) {
+ FilesAndDirs[Path] = Status;
+ }
+
+ void addRegularFile(StringRef Path, sys::fs::perms Perms = sys::fs::all_all) {
+ vfs::Status S(Path, UniqueID(FSID, FileID++),
+ std::chrono::system_clock::now(), 0, 0, 1024,
+ sys::fs::file_type::regular_file, Perms);
+ addEntry(Path, S);
+ }
+
+ void addDirectory(StringRef Path, sys::fs::perms Perms = sys::fs::all_all) {
+ vfs::Status S(Path, UniqueID(FSID, FileID++),
+ std::chrono::system_clock::now(), 0, 0, 0,
+ sys::fs::file_type::directory_file, Perms);
+ addEntry(Path, S);
+ }
+
+ void addSymlink(StringRef Path) {
+ vfs::Status S(Path, UniqueID(FSID, FileID++),
+ std::chrono::system_clock::now(), 0, 0, 0,
+ sys::fs::file_type::symlink_file, sys::fs::all_all);
+ addEntry(Path, S);
+ }
+};
+} // namespace
TEST(FileSystemTest, FileAndDirectoryComponents) {
using namespace std::chrono;
@@ -26,7 +167,125 @@ TEST(FileSystemTest, FileAndDirectoryComponents) {
#endif
FileSpec fs2(TestMainArgv0, resolve);
- EXPECT_EQ(system_clock::time_point(), FileSystem::GetModificationTime(fs1));
+ FileSystem fs;
+
+ EXPECT_EQ(system_clock::time_point(), fs.GetModificationTime(fs1));
EXPECT_LT(system_clock::time_point() + hours(24 * 365 * 20),
- FileSystem::GetModificationTime(fs2));
+ fs.GetModificationTime(fs2));
+}
+
+static IntrusiveRefCntPtr<DummyFileSystem> GetSimpleDummyFS() {
+ IntrusiveRefCntPtr<DummyFileSystem> D(new DummyFileSystem());
+ D->addRegularFile("/foo");
+ D->addDirectory("/bar");
+ D->addSymlink("/baz");
+ D->addRegularFile("/qux", ~sys::fs::perms::all_read);
+ D->setCurrentWorkingDirectory("/");
+ return D;
+}
+
+TEST(FileSystemTest, Exists) {
+ FileSystem fs(GetSimpleDummyFS());
+
+ EXPECT_TRUE(fs.Exists("/foo"));
+ EXPECT_TRUE(fs.Exists(FileSpec("/foo", false, FileSpec::Style::posix)));
+}
+
+TEST(FileSystemTest, Readable) {
+ FileSystem fs(GetSimpleDummyFS());
+
+ EXPECT_TRUE(fs.Readable("/foo"));
+ EXPECT_TRUE(fs.Readable(FileSpec("/foo", false, FileSpec::Style::posix)));
+
+ EXPECT_FALSE(fs.Readable("/qux"));
+ EXPECT_FALSE(fs.Readable(FileSpec("/qux", false, FileSpec::Style::posix)));
+}
+
+TEST(FileSystemTest, GetByteSize) {
+ FileSystem fs(GetSimpleDummyFS());
+
+ EXPECT_EQ((uint64_t)1024, fs.GetByteSize("/foo"));
+ EXPECT_EQ((uint64_t)1024,
+ fs.GetByteSize(FileSpec("/foo", false, FileSpec::Style::posix)));
+}
+
+TEST(FileSystemTest, GetPermissions) {
+ FileSystem fs(GetSimpleDummyFS());
+
+ EXPECT_EQ(sys::fs::all_all, fs.GetPermissions("/foo"));
+ EXPECT_EQ(sys::fs::all_all,
+ fs.GetPermissions(FileSpec("/foo", false, FileSpec::Style::posix)));
+}
+
+TEST(FileSystemTest, MakeAbsolute) {
+ FileSystem fs(GetSimpleDummyFS());
+
+ {
+ StringRef foo_relative = "foo";
+ SmallString<16> foo(foo_relative);
+ auto EC = fs.MakeAbsolute(foo);
+ EXPECT_FALSE(EC);
+ EXPECT_TRUE(foo.equals("/foo"));
+ }
+
+ {
+ FileSpec file_spec("foo", false);
+ auto EC = fs.MakeAbsolute(file_spec);
+ EXPECT_FALSE(EC);
+ EXPECT_EQ("/foo", file_spec.GetPath());
+ }
+}
+
+TEST(FileSystemTest, Resolve) {
+ FileSystem fs(GetSimpleDummyFS());
+
+ {
+ StringRef foo_relative = "foo";
+ SmallString<16> foo(foo_relative);
+ fs.Resolve(foo);
+ EXPECT_TRUE(foo.equals("/foo"));
+ }
+
+ {
+ FileSpec file_spec("foo", false);
+ fs.Resolve(file_spec);
+ EXPECT_EQ("/foo", file_spec.GetPath());
+ }
+
+ {
+ StringRef foo_relative = "bogus";
+ SmallString<16> foo(foo_relative);
+ fs.Resolve(foo);
+ EXPECT_TRUE(foo.equals("bogus"));
+ }
+
+ {
+ FileSpec file_spec("bogus", false);
+ fs.Resolve(file_spec);
+ EXPECT_EQ("bogus", file_spec.GetPath());
+ }
+}
+
+FileSystem::EnumerateDirectoryResult
+VFSCallback(void *baton, llvm::sys::fs::file_type file_type,
+ llvm::StringRef path) {
+ auto visited = static_cast<std::vector<std::string> *>(baton);
+ visited->push_back(path.str());
+ return FileSystem::eEnumerateDirectoryResultNext;
+}
+
+TEST(FileSystemTest, EnumerateDirectory) {
+ FileSystem fs(GetSimpleDummyFS());
+
+ std::vector<std::string> visited;
+
+ constexpr bool find_directories = true;
+ constexpr bool find_files = true;
+ constexpr bool find_other = true;
+
+ fs.EnumerateDirectory("/", find_directories, find_files, find_other,
+ VFSCallback, &visited);
+
+ EXPECT_THAT(visited,
+ testing::UnorderedElementsAre("/foo", "/bar", "/baz", "/qux"));
}
diff --git a/lldb/unittests/Host/HostInfoTest.cpp b/lldb/unittests/Host/HostInfoTest.cpp
index 3870673d0f4..47bfefc7994 100644
--- a/lldb/unittests/Host/HostInfoTest.cpp
+++ b/lldb/unittests/Host/HostInfoTest.cpp
@@ -8,20 +8,27 @@
//===----------------------------------------------------------------------===//
#include "lldb/Host/HostInfo.h"
-#include "lldb/lldb-defines.h"
#include "TestingSupport/TestUtilities.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/lldb-defines.h"
#include "gtest/gtest.h"
using namespace lldb_private;
using namespace llvm;
namespace {
-class HostInfoTest: public ::testing::Test {
- public:
- void SetUp() override { HostInfo::Initialize(); }
- void TearDown() override { HostInfo::Terminate(); }
+class HostInfoTest : public ::testing::Test {
+public:
+ void SetUp() override {
+ FileSystem::Initialize();
+ HostInfo::Initialize();
+ }
+ void TearDown() override {
+ HostInfo::Terminate();
+ FileSystem::Terminate();
+ }
};
-}
+} // namespace
TEST_F(HostInfoTest, GetAugmentedArchSpec) {
// Fully specified triple should not be changed.
diff --git a/lldb/unittests/Host/SymbolsTest.cpp b/lldb/unittests/Host/SymbolsTest.cpp
index 253ce39e31b..7b5996b2554 100644
--- a/lldb/unittests/Host/SymbolsTest.cpp
+++ b/lldb/unittests/Host/SymbolsTest.cpp
@@ -9,20 +9,37 @@
#include "gtest/gtest.h"
-#include "lldb/Host/Symbols.h"
#include "lldb/Core/ModuleSpec.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Host/Symbols.h"
using namespace lldb_private;
-TEST(SymbolsTest,
- LocateExecutableSymbolFileForUnknownExecutableAndUnknownSymbolFile) {
+namespace {
+class SymbolsTest : public ::testing::Test {
+public:
+ void SetUp() override {
+ FileSystem::Initialize();
+ HostInfo::Initialize();
+ }
+ void TearDown() override {
+ HostInfo::Terminate();
+ FileSystem::Terminate();
+ }
+};
+} // namespace
+
+TEST_F(
+ SymbolsTest,
+ TerminateLocateExecutableSymbolFileForUnknownExecutableAndUnknownSymbolFile) {
ModuleSpec module_spec;
FileSpec symbol_file_spec = Symbols::LocateExecutableSymbolFile(module_spec);
EXPECT_TRUE(symbol_file_spec.GetFilename().IsEmpty());
}
-TEST(SymbolsTest,
- LocateExecutableSymbolFileForUnknownExecutableAndMissingSymbolFile) {
+TEST_F(SymbolsTest,
+ LocateExecutableSymbolFileForUnknownExecutableAndMissingSymbolFile) {
ModuleSpec module_spec;
// using a GUID here because the symbol file shouldn't actually exist on disk
module_spec.GetSymbolFileSpec().SetFile(
diff --git a/lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp b/lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp
index cf8d7042cb0..f670b2390f9 100644
--- a/lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp
+++ b/lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp
@@ -14,6 +14,7 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/Section.h"
+#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostInfo.h"
#include "llvm/ADT/Optional.h"
#include "llvm/Support/Compression.h"
@@ -29,6 +30,7 @@ using namespace lldb;
class ObjectFileELFTest : public testing::Test {
public:
void SetUp() override {
+ FileSystem::Initialize();
HostInfo::Initialize();
ObjectFileELF::Initialize();
SymbolVendorELF::Initialize();
@@ -38,6 +40,7 @@ public:
SymbolVendorELF::Terminate();
ObjectFileELF::Terminate();
HostInfo::Terminate();
+ FileSystem::Terminate();
}
protected:
diff --git a/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp b/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
index 608f3ee45e5..66680f10563 100644
--- a/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
+++ b/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
@@ -7,10 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "Plugins/ScriptInterpreter/Python/lldb-python.h"
#include "gtest/gtest.h"
#include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h"
+#include "Plugins/ScriptInterpreter/Python/lldb-python.h"
+#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostInfo.h"
#include "PythonTestSuite.h"
@@ -18,6 +19,7 @@
using namespace lldb_private;
void PythonTestSuite::SetUp() {
+ FileSystem::Initialize();
HostInfoBase::Initialize();
// ScriptInterpreterPython::Initialize() depends on HostInfo being
// initializedso it can compute the python directory etc.
diff --git a/lldb/unittests/Symbol/TestClangASTContext.cpp b/lldb/unittests/Symbol/TestClangASTContext.cpp
index e422e3ba347..ed272a77f12 100644
--- a/lldb/unittests/Symbol/TestClangASTContext.cpp
+++ b/lldb/unittests/Symbol/TestClangASTContext.cpp
@@ -13,6 +13,7 @@
#include "clang/AST/DeclCXX.h"
+#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ClangUtil.h"
@@ -25,9 +26,15 @@ using namespace lldb_private;
class TestClangASTContext : public testing::Test {
public:
- static void SetUpTestCase() { HostInfo::Initialize(); }
+ static void SetUpTestCase() {
+ FileSystem::Initialize();
+ HostInfo::Initialize();
+ }
- static void TearDownTestCase() { HostInfo::Terminate(); }
+ static void TearDownTestCase() {
+ HostInfo::Terminate();
+ FileSystem::Terminate();
+ }
virtual void SetUp() override {
std::string triple = HostInfo::GetTargetTriple();
@@ -357,7 +364,7 @@ TEST_F(TestClangASTContext, TestRecordHasFields) {
RecordDecl *empty_derived_non_empty_base_decl =
ClangASTContext::GetAsRecordDecl(empty_derived);
EXPECT_EQ(1u, ClangASTContext::GetNumBaseClasses(
- empty_derived_non_empty_base_cxx_decl, false));
+ empty_derived_non_empty_base_cxx_decl, false));
EXPECT_TRUE(
ClangASTContext::RecordHasFields(empty_derived_non_empty_base_decl));
@@ -380,7 +387,7 @@ TEST_F(TestClangASTContext, TestRecordHasFields) {
RecordDecl *empty_derived_non_empty_vbase_decl =
ClangASTContext::GetAsRecordDecl(empty_derived2);
EXPECT_EQ(1u, ClangASTContext::GetNumBaseClasses(
- empty_derived_non_empty_vbase_cxx_decl, false));
+ empty_derived_non_empty_vbase_cxx_decl, false));
EXPECT_TRUE(
ClangASTContext::RecordHasFields(empty_derived_non_empty_vbase_decl));
}
@@ -420,7 +427,7 @@ TEST_F(TestClangASTContext, TemplateArguments) {
clang::AutoTypeKeyword::Auto, false));
CompilerType int_type(m_ast->getASTContext(), m_ast->getASTContext()->IntTy);
- for(CompilerType t: { type, typedef_type, auto_type }) {
+ for (CompilerType t : {type, typedef_type, auto_type}) {
SCOPED_TRACE(t.GetTypeName().AsCString());
EXPECT_EQ(m_ast->GetTemplateArgumentKind(t.GetOpaqueQualType(), 0),
diff --git a/lldb/unittests/Symbol/TestDWARFCallFrameInfo.cpp b/lldb/unittests/Symbol/TestDWARFCallFrameInfo.cpp
index c8d560f03de..f2054f768e1 100644
--- a/lldb/unittests/Symbol/TestDWARFCallFrameInfo.cpp
+++ b/lldb/unittests/Symbol/TestDWARFCallFrameInfo.cpp
@@ -8,20 +8,24 @@
//
//===----------------------------------------------------------------------===//
+#include "gtest/gtest.h"
+
#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
#include "Plugins/Process/Utility/RegisterContext_x86.h"
+#include "TestingSupport/TestUtilities.h"
+
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/Section.h"
+#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Symbol/DWARFCallFrameInfo.h"
#include "lldb/Utility/StreamString.h"
-#include "TestingSupport/TestUtilities.h"
+
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/raw_ostream.h"
-#include "gtest/gtest.h"
using namespace lldb_private;
using namespace lldb;
@@ -29,6 +33,7 @@ using namespace lldb;
class DWARFCallFrameInfoTest : public testing::Test {
public:
void SetUp() override {
+ FileSystem::Initialize();
HostInfo::Initialize();
ObjectFileELF::Initialize();
}
@@ -36,6 +41,7 @@ public:
void TearDown() override {
ObjectFileELF::Terminate();
HostInfo::Terminate();
+ FileSystem::Terminate();
}
protected:
diff --git a/lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp b/lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
index 743b91a2879..9dd88d1b1f6 100644
--- a/lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
@@ -22,6 +22,7 @@
#include "lldb/Core/Address.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
+#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/CompileUnit.h"
@@ -38,13 +39,14 @@ public:
// Initialize and TearDown the plugin every time, so we get a brand new
// AST every time so that modifications to the AST from each test don't
// leak into the next test.
- HostInfo::Initialize();
- ObjectFilePECOFF::Initialize();
- SymbolFileDWARF::Initialize();
- ClangASTContext::Initialize();
- SymbolFilePDB::Initialize();
+FileSystem::Initialize();
+HostInfo::Initialize();
+ObjectFilePECOFF::Initialize();
+SymbolFileDWARF::Initialize();
+ClangASTContext::Initialize();
+SymbolFilePDB::Initialize();
- m_dwarf_test_exe = GetInputFilePath("test-dwarf.exe");
+m_dwarf_test_exe = GetInputFilePath("test-dwarf.exe");
}
void TearDown() override {
@@ -53,6 +55,7 @@ public:
SymbolFileDWARF::Terminate();
ObjectFilePECOFF::Terminate();
HostInfo::Terminate();
+ FileSystem::Terminate();
}
protected:
diff --git a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
index 75405a2774e..7f722b055bf 100644
--- a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
+++ b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
@@ -22,6 +22,7 @@
#include "lldb/Core/Address.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
+#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/CompileUnit.h"
@@ -49,6 +50,7 @@ public:
::CoInitializeEx(nullptr, COINIT_MULTITHREADED);
#endif
+ FileSystem::Initialize();
HostInfo::Initialize();
ObjectFilePECOFF::Initialize();
SymbolFileDWARF::Initialize();
@@ -65,6 +67,7 @@ public:
SymbolFileDWARF::Terminate();
ObjectFilePECOFF::Terminate();
HostInfo::Terminate();
+ FileSystem::Terminate();
#if defined(_MSC_VER)
::CoUninitialize();
diff --git a/lldb/unittests/Target/ModuleCacheTest.cpp b/lldb/unittests/Target/ModuleCacheTest.cpp
index 0b9e02df781..59abe8e6c12 100644
--- a/lldb/unittests/Target/ModuleCacheTest.cpp
+++ b/lldb/unittests/Target/ModuleCacheTest.cpp
@@ -5,12 +5,13 @@
#include "llvm/Support/Path.h"
#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
+#include "TestingSupport/TestUtilities.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
+#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Target/ModuleCache.h"
-#include "TestingSupport/TestUtilities.h"
using namespace lldb_private;
using namespace lldb;
@@ -65,6 +66,7 @@ static FileSpec GetSysrootView(FileSpec spec, const char *hostname) {
}
void ModuleCacheTest::SetUpTestCase() {
+ FileSystem::Initialize();
HostInfo::Initialize();
ObjectFileELF::Initialize();
@@ -75,6 +77,7 @@ void ModuleCacheTest::SetUpTestCase() {
void ModuleCacheTest::TearDownTestCase() {
ObjectFileELF::Terminate();
HostInfo::Terminate();
+ FileSystem::Terminate();
}
static void VerifyDiskState(const FileSpec &cache_dir, const char *hostname) {
OpenPOWER on IntegriCloud