summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/unittests/Interpreter/CMakeLists.txt2
-rw-r--r--lldb/unittests/Interpreter/TestCompletion.cpp3
-rw-r--r--lldb/unittests/ObjectFile/ELF/CMakeLists.txt1
-rw-r--r--lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp16
-rw-r--r--lldb/unittests/Process/minidump/CMakeLists.txt1
-rw-r--r--lldb/unittests/Process/minidump/MinidumpParserTest.cpp15
-rw-r--r--lldb/unittests/Symbol/CMakeLists.txt1
-rw-r--r--lldb/unittests/Symbol/TestDWARFCallFrameInfo.cpp14
-rw-r--r--lldb/unittests/SymbolFile/DWARF/CMakeLists.txt1
-rw-r--r--lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp21
-rw-r--r--lldb/unittests/SymbolFile/PDB/CMakeLists.txt1
-rw-r--r--lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp20
-rw-r--r--lldb/unittests/Target/CMakeLists.txt1
-rw-r--r--lldb/unittests/Target/ModuleCacheTest.cpp12
-rw-r--r--lldb/unittests/Utility/CMakeLists.txt4
-rw-r--r--lldb/unittests/Utility/Helpers/CMakeLists.txt (renamed from lldb/unittests/Utility/Mocks/CMakeLists.txt)4
-rw-r--r--lldb/unittests/Utility/Helpers/MockTildeExpressionResolver.cpp (renamed from lldb/unittests/Utility/Mocks/MockTildeExpressionResolver.cpp)0
-rw-r--r--lldb/unittests/Utility/Helpers/MockTildeExpressionResolver.h (renamed from lldb/unittests/Utility/Mocks/MockTildeExpressionResolver.h)2
-rw-r--r--lldb/unittests/Utility/Helpers/TestUtilities.cpp22
-rw-r--r--lldb/unittests/Utility/Helpers/TestUtilities.h20
-rw-r--r--lldb/unittests/Utility/StructuredDataTest.cpp26
-rw-r--r--lldb/unittests/Utility/TildeExpressionResolverTest.cpp2
22 files changed, 89 insertions, 100 deletions
diff --git a/lldb/unittests/Interpreter/CMakeLists.txt b/lldb/unittests/Interpreter/CMakeLists.txt
index d884dee62ec..7be092b24b5 100644
--- a/lldb/unittests/Interpreter/CMakeLists.txt
+++ b/lldb/unittests/Interpreter/CMakeLists.txt
@@ -4,7 +4,7 @@ add_lldb_unittest(InterpreterTests
LINK_LIBS
lldbInterpreter
- lldbUtilityMocks
+ lldbUtilityHelpers
)
target_link_libraries(InterpreterTests
diff --git a/lldb/unittests/Interpreter/TestCompletion.cpp b/lldb/unittests/Interpreter/TestCompletion.cpp
index 0548b93d6f7..0baf61fdaf3 100644
--- a/lldb/unittests/Interpreter/TestCompletion.cpp
+++ b/lldb/unittests/Interpreter/TestCompletion.cpp
@@ -12,13 +12,12 @@
#include "lldb/Utility/StringList.h"
#include "lldb/Utility/TildeExpressionResolver.h"
+#include "unittests/Utility/Helpers/MockTildeExpressionResolver.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
-#include "unittests/Utility/Mocks/MockTildeExpressionResolver.h"
-
namespace fs = llvm::sys::fs;
namespace path = llvm::sys::path;
using namespace llvm;
diff --git a/lldb/unittests/ObjectFile/ELF/CMakeLists.txt b/lldb/unittests/ObjectFile/ELF/CMakeLists.txt
index a182f4a4244..652c221a6d8 100644
--- a/lldb/unittests/ObjectFile/ELF/CMakeLists.txt
+++ b/lldb/unittests/ObjectFile/ELF/CMakeLists.txt
@@ -6,6 +6,7 @@ add_lldb_unittest(ObjectFileELFTests
lldbPluginObjectFileELF
lldbPluginSymbolVendorELF
lldbCore
+ lldbUtilityHelpers
)
add_dependencies(ObjectFileELFTests yaml2obj)
diff --git a/lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp b/lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp
index 6ed9b2357bb..e9b3e9fcf23 100644
--- a/lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp
+++ b/lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp
@@ -9,20 +9,18 @@
//===----------------------------------------------------------------------===//
#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
+#include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/Section.h"
#include "lldb/Host/HostInfo.h"
+#include "unittests/Utility/Helpers/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"
-#include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h"
-
-extern const char *TestMainArgv0;
-
using namespace lldb_private;
using namespace lldb;
@@ -32,10 +30,6 @@ public:
HostInfo::Initialize();
ObjectFileELF::Initialize();
SymbolVendorELF::Initialize();
-
- m_inputs_folder = llvm::sys::path::parent_path(TestMainArgv0);
- llvm::sys::path::append(m_inputs_folder, "Inputs");
- llvm::sys::fs::make_absolute(m_inputs_folder);
}
void TearDown() override {
@@ -45,7 +39,6 @@ public:
}
protected:
- llvm::SmallString<128> m_inputs_folder;
};
#define ASSERT_NO_ERROR(x) \
@@ -60,9 +53,8 @@ protected:
}
TEST_F(ObjectFileELFTest, SectionsResolveConsistently) {
- llvm::SmallString<128> yaml = m_inputs_folder;
- llvm::sys::path::append(yaml, "sections-resolve-consistently.yaml");
- llvm::SmallString<128> obj = m_inputs_folder;
+ std::string yaml = GetInputFilePath("sections-resolve-consistently.yaml");
+ llvm::SmallString<128> obj;
ASSERT_NO_ERROR(llvm::sys::fs::createTemporaryFile(
"sections-resolve-consistently-%%%%%%", "obj", obj));
diff --git a/lldb/unittests/Process/minidump/CMakeLists.txt b/lldb/unittests/Process/minidump/CMakeLists.txt
index 2b2df6327e9..e1b8154e1c3 100644
--- a/lldb/unittests/Process/minidump/CMakeLists.txt
+++ b/lldb/unittests/Process/minidump/CMakeLists.txt
@@ -7,6 +7,7 @@ add_lldb_unittest(LLDBMinidumpTests
lldbTarget
lldbPluginProcessUtility
lldbPluginProcessMinidump
+ lldbUtilityHelpers
LINK_COMPONENTS
Support
)
diff --git a/lldb/unittests/Process/minidump/MinidumpParserTest.cpp b/lldb/unittests/Process/minidump/MinidumpParserTest.cpp
index 755095f7591..a029466fc59 100644
--- a/lldb/unittests/Process/minidump/MinidumpParserTest.cpp
+++ b/lldb/unittests/Process/minidump/MinidumpParserTest.cpp
@@ -23,7 +23,7 @@
#include "lldb/Utility/DataBufferLLVM.h"
#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/FileSpec.h"
-
+#include "unittests/Utility/Helpers/TestUtilities.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/Optional.h"
#include "llvm/Support/FileSystem.h"
@@ -35,24 +35,14 @@
// C++ includes
#include <memory>
-extern const char *TestMainArgv0;
-
using namespace lldb_private;
using namespace minidump;
class MinidumpParserTest : public testing::Test {
public:
- void SetUp() override {
- llvm::StringRef dmp_folder = llvm::sys::path::parent_path(TestMainArgv0);
- inputs_folder = dmp_folder;
- llvm::sys::path::append(inputs_folder, "Inputs");
- }
-
void SetUpData(const char *minidump_filename,
uint64_t load_size = UINT64_MAX) {
- llvm::SmallString<128> filename = inputs_folder;
- llvm::sys::path::append(filename, minidump_filename);
-
+ std::string filename = GetInputFilePath(minidump_filename);
auto BufferPtr = DataBufferLLVM::CreateSliceFromPath(filename, load_size, 0);
llvm::Optional<MinidumpParser> optional_parser =
@@ -62,7 +52,6 @@ public:
ASSERT_GT(parser->GetData().size(), 0UL);
}
- llvm::SmallString<128> inputs_folder;
std::unique_ptr<MinidumpParser> parser;
};
diff --git a/lldb/unittests/Symbol/CMakeLists.txt b/lldb/unittests/Symbol/CMakeLists.txt
index de74680e413..2d042648c4b 100644
--- a/lldb/unittests/Symbol/CMakeLists.txt
+++ b/lldb/unittests/Symbol/CMakeLists.txt
@@ -6,6 +6,7 @@ add_lldb_unittest(SymbolTests
LINK_LIBS
lldbHost
lldbSymbol
+ lldbUtilityHelpers
)
add_dependencies(SymbolTests yaml2obj)
diff --git a/lldb/unittests/Symbol/TestDWARFCallFrameInfo.cpp b/lldb/unittests/Symbol/TestDWARFCallFrameInfo.cpp
index ae659c9a39a..40e3aac5fb3 100644
--- a/lldb/unittests/Symbol/TestDWARFCallFrameInfo.cpp
+++ b/lldb/unittests/Symbol/TestDWARFCallFrameInfo.cpp
@@ -16,14 +16,13 @@
#include "lldb/Host/HostInfo.h"
#include "lldb/Symbol/DWARFCallFrameInfo.h"
#include "lldb/Utility/StreamString.h"
+#include "unittests/Utility/Helpers/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"
-extern const char *TestMainArgv0;
-
using namespace lldb_private;
using namespace lldb;
@@ -32,10 +31,6 @@ public:
void SetUp() override {
HostInfo::Initialize();
ObjectFileELF::Initialize();
-
- m_inputs_folder = llvm::sys::path::parent_path(TestMainArgv0);
- llvm::sys::path::append(m_inputs_folder, "Inputs");
- llvm::sys::fs::make_absolute(m_inputs_folder);
}
void TearDown() override {
@@ -44,8 +39,6 @@ public:
}
protected:
- llvm::SmallString<128> m_inputs_folder;
-
void TestBasic(DWARFCallFrameInfo::Type type, llvm::StringRef symbol);
};
@@ -96,9 +89,8 @@ static UnwindPlan::Row GetExpectedRow2() {
void DWARFCallFrameInfoTest::TestBasic(DWARFCallFrameInfo::Type type,
llvm::StringRef symbol) {
- llvm::SmallString<128> yaml = m_inputs_folder;
- llvm::sys::path::append(yaml, "basic-call-frame-info.yaml");
- llvm::SmallString<128> obj = m_inputs_folder;
+ std::string yaml = GetInputFilePath("basic-call-frame-info.yaml");
+ llvm::SmallString<128> obj;
ASSERT_NO_ERROR(llvm::sys::fs::createTemporaryFile(
"basic-call-frame-info-%%%%%%", "obj", obj));
diff --git a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
index c764bd477fa..b2ece4eeaed 100644
--- a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
+++ b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
@@ -8,6 +8,7 @@ add_lldb_unittest(SymbolFileDWARFTests
lldbPluginObjectFilePECOFF
lldbPluginSymbolFileDWARF
lldbPluginSymbolFilePDB
+ lldbUtilityHelpers
LINK_COMPONENTS
Support
DebugInfoPDB
diff --git a/lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp b/lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
index 8ef6ad05bd5..298bed10f3f 100644
--- a/lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
@@ -15,6 +15,9 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
+#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
+#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
+#include "Plugins/SymbolFile/PDB/SymbolFilePDB.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/Module.h"
@@ -25,12 +28,7 @@
#include "lldb/Symbol/LineTable.h"
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Utility/FileSpec.h"
-
-#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
-#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
-#include "Plugins/SymbolFile/PDB/SymbolFilePDB.h"
-
-extern const char *TestMainArgv0;
+#include "unittests/Utility/Helpers/TestUtilities.h"
using namespace lldb_private;
@@ -46,12 +44,7 @@ public:
ClangASTContext::Initialize();
SymbolFilePDB::Initialize();
- llvm::StringRef exe_folder = llvm::sys::path::parent_path(TestMainArgv0);
- llvm::SmallString<128> inputs_folder = exe_folder;
- llvm::sys::path::append(inputs_folder, "Inputs");
-
- m_dwarf_test_exe = inputs_folder;
- llvm::sys::path::append(m_dwarf_test_exe, "test-dwarf.exe");
+ m_dwarf_test_exe = GetInputFilePath("test-dwarf.exe");
}
void TearDown() override {
@@ -63,12 +56,12 @@ public:
}
protected:
- llvm::SmallString<128> m_dwarf_test_exe;
+ std::string m_dwarf_test_exe;
};
TEST_F(SymbolFileDWARFTests, TestAbilitiesForDWARF) {
// Test that when we have Dwarf debug info, SymbolFileDWARF is used.
- FileSpec fspec(m_dwarf_test_exe.c_str(), false);
+ FileSpec fspec(m_dwarf_test_exe, false);
ArchSpec aspec("i686-pc-windows");
lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
diff --git a/lldb/unittests/SymbolFile/PDB/CMakeLists.txt b/lldb/unittests/SymbolFile/PDB/CMakeLists.txt
index d9aff4e2eac..f9a266f8ebb 100644
--- a/lldb/unittests/SymbolFile/PDB/CMakeLists.txt
+++ b/lldb/unittests/SymbolFile/PDB/CMakeLists.txt
@@ -8,6 +8,7 @@ add_lldb_unittest(SymbolFilePDBTests
lldbPluginObjectFilePECOFF
lldbPluginSymbolFileDWARF
lldbPluginSymbolFilePDB
+ lldbUtiltyHelpers
LINK_COMPONENTS
Support
DebugInfoPDB
diff --git a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
index 226057f8936..249e1bbf739 100644
--- a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
+++ b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
@@ -15,6 +15,9 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
+#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
+#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
+#include "Plugins/SymbolFile/PDB/SymbolFilePDB.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/Module.h"
@@ -25,10 +28,7 @@
#include "lldb/Symbol/LineTable.h"
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Utility/FileSpec.h"
-
-#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
-#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
-#include "Plugins/SymbolFile/PDB/SymbolFilePDB.h"
+#include "unittests/Utility/Helpers/TestUtilities.h"
#if defined(_MSC_VER)
#include "lldb/Host/windows/windows.h"
@@ -37,8 +37,6 @@
#include <algorithm>
-extern const char *TestMainArgv0;
-
using namespace lldb_private;
class SymbolFilePDBTests : public testing::Test {
@@ -61,10 +59,8 @@ public:
llvm::SmallString<128> inputs_folder = exe_folder;
llvm::sys::path::append(inputs_folder, "Inputs");
- m_pdb_test_exe = inputs_folder;
- m_types_test_exe = inputs_folder;
- llvm::sys::path::append(m_pdb_test_exe, "test-pdb.exe");
- llvm::sys::path::append(m_types_test_exe, "test-pdb-types.exe");
+ m_pdb_test_exe = GetInputFile("test-pdb.exe");
+ m_types_test_exe = GetInputFile("test-pdb-types.exe");
}
void TearDown() override {
@@ -80,8 +76,8 @@ public:
}
protected:
- llvm::SmallString<128> m_pdb_test_exe;
- llvm::SmallString<128> m_types_test_exe;
+ std::string m_pdb_test_exe;
+ std::string m_types_test_exe;
bool FileSpecMatchesAsBaseOrFull(const FileSpec &left,
const FileSpec &right) const {
diff --git a/lldb/unittests/Target/CMakeLists.txt b/lldb/unittests/Target/CMakeLists.txt
index e4f6e52b063..ec8f2db2c39 100644
--- a/lldb/unittests/Target/CMakeLists.txt
+++ b/lldb/unittests/Target/CMakeLists.txt
@@ -8,6 +8,7 @@ add_lldb_unittest(TargetTests
lldbSymbol
lldbUtility
lldbPluginObjectFileELF
+ lldbUtilityHelpers
LINK_COMPONENTS
Support
)
diff --git a/lldb/unittests/Target/ModuleCacheTest.cpp b/lldb/unittests/Target/ModuleCacheTest.cpp
index 8914f8b5eac..122d789daf5 100644
--- a/lldb/unittests/Target/ModuleCacheTest.cpp
+++ b/lldb/unittests/Target/ModuleCacheTest.cpp
@@ -10,8 +10,7 @@
#include "lldb/Host/HostInfo.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Target/ModuleCache.h"
-
-extern const char *TestMainArgv0;
+#include "unittests/Utility/Helpers/TestUtilities.h"
using namespace lldb_private;
using namespace lldb;
@@ -26,7 +25,7 @@ public:
protected:
static FileSpec s_cache_dir;
- static llvm::SmallString<128> s_test_executable;
+ static std::string s_test_executable;
void TryGetAndPut(const FileSpec &cache_dir, const char *hostname,
bool expect_download);
@@ -34,7 +33,7 @@ protected:
}
FileSpec ModuleCacheTest::s_cache_dir;
-llvm::SmallString<128> ModuleCacheTest::s_test_executable;
+std::string ModuleCacheTest::s_test_executable;
static const char dummy_hostname[] = "dummy_hostname";
static const char dummy_remote_dir[] = "bin";
@@ -71,10 +70,7 @@ void ModuleCacheTest::SetUpTestCase() {
FileSpec tmpdir_spec;
HostInfo::GetLLDBPath(lldb::ePathTypeLLDBTempSystemDir, s_cache_dir);
-
- llvm::StringRef exe_folder = llvm::sys::path::parent_path(TestMainArgv0);
- s_test_executable = exe_folder;
- llvm::sys::path::append(s_test_executable, "Inputs", module_name);
+ s_test_executable = GetInputFilePath(module_name);
}
void ModuleCacheTest::TearDownTestCase() {
diff --git a/lldb/unittests/Utility/CMakeLists.txt b/lldb/unittests/Utility/CMakeLists.txt
index 41ae8a4a216..bf9be3eb9c4 100644
--- a/lldb/unittests/Utility/CMakeLists.txt
+++ b/lldb/unittests/Utility/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_subdirectory(Mocks)
+add_subdirectory(Helpers)
add_lldb_unittest(UtilityTests
ConstStringTest.cpp
@@ -15,7 +15,7 @@ add_lldb_unittest(UtilityTests
LINK_LIBS
lldbUtility
- lldbUtilityMocks
+ lldbUtilityHelpers
LINK_COMPONENTS
Support
)
diff --git a/lldb/unittests/Utility/Mocks/CMakeLists.txt b/lldb/unittests/Utility/Helpers/CMakeLists.txt
index 57db5bf3b62..36c774cb682 100644
--- a/lldb/unittests/Utility/Mocks/CMakeLists.txt
+++ b/lldb/unittests/Utility/Helpers/CMakeLists.txt
@@ -1,5 +1,7 @@
-add_lldb_library(lldbUtilityMocks
+set(EXCLUDE_FROM_ALL ON)
+add_lldb_library(lldbUtilityHelpers
MockTildeExpressionResolver.cpp
+ TestUtilities.cpp
LINK_LIBS
lldbUtility
diff --git a/lldb/unittests/Utility/Mocks/MockTildeExpressionResolver.cpp b/lldb/unittests/Utility/Helpers/MockTildeExpressionResolver.cpp
index 832836682b5..832836682b5 100644
--- a/lldb/unittests/Utility/Mocks/MockTildeExpressionResolver.cpp
+++ b/lldb/unittests/Utility/Helpers/MockTildeExpressionResolver.cpp
diff --git a/lldb/unittests/Utility/Mocks/MockTildeExpressionResolver.h b/lldb/unittests/Utility/Helpers/MockTildeExpressionResolver.h
index 7ae5623f839..18be1102e1f 100644
--- a/lldb/unittests/Utility/Mocks/MockTildeExpressionResolver.h
+++ b/lldb/unittests/Utility/Helpers/MockTildeExpressionResolver.h
@@ -32,6 +32,6 @@ public:
llvm::SmallVectorImpl<char> &Output) override;
bool ResolvePartial(llvm::StringRef Expr, llvm::StringSet<> &Output) override;
};
-}
+} // namespace lldb_private
#endif
diff --git a/lldb/unittests/Utility/Helpers/TestUtilities.cpp b/lldb/unittests/Utility/Helpers/TestUtilities.cpp
new file mode 100644
index 00000000000..eacf8766142
--- /dev/null
+++ b/lldb/unittests/Utility/Helpers/TestUtilities.cpp
@@ -0,0 +1,22 @@
+//===- TestUtilities.cpp ----------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "TestUtilities.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+
+extern const char *TestMainArgv0;
+
+std::string lldb_private::GetInputFilePath(const llvm::Twine &name) {
+ llvm::SmallString<128> result = llvm::sys::path::parent_path(TestMainArgv0);
+ llvm::sys::fs::make_absolute(result);
+ llvm::sys::path::append(result, "Inputs", name);
+ return result.str();
+}
diff --git a/lldb/unittests/Utility/Helpers/TestUtilities.h b/lldb/unittests/Utility/Helpers/TestUtilities.h
new file mode 100644
index 00000000000..8d848797b7b
--- /dev/null
+++ b/lldb/unittests/Utility/Helpers/TestUtilities.h
@@ -0,0 +1,20 @@
+//===- TestUtilities.h ------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_UNITTESTS_UTILITY_HELPERS_TESTUTILITIES_H
+#define LLDB_UNITTESTS_UTILITY_HELPERS_TESTUTILITIES_H
+
+#include "llvm/ADT/Twine.h"
+#include <string>
+
+namespace lldb_private {
+std::string GetInputFilePath(const llvm::Twine &name);
+}
+
+#endif
diff --git a/lldb/unittests/Utility/StructuredDataTest.cpp b/lldb/unittests/Utility/StructuredDataTest.cpp
index 98ba34c5eec..f346dd9e832 100644
--- a/lldb/unittests/Utility/StructuredDataTest.cpp
+++ b/lldb/unittests/Utility/StructuredDataTest.cpp
@@ -9,33 +9,16 @@
#include "gtest/gtest.h"
+#include "Helpers/TestUtilities.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/StructuredData.h"
#include "llvm/Support/Path.h"
-extern const char *TestMainArgv0;
-
using namespace lldb;
using namespace lldb_private;
-namespace {
-
-class StructuredDataTest : public testing::Test {
-public:
- static void SetUpTestCase() {
- s_inputs_folder = llvm::sys::path::parent_path(TestMainArgv0);
- llvm::sys::path::append(s_inputs_folder, "Inputs");
- }
-
-protected:
- static llvm::SmallString<128> s_inputs_folder;
-};
-} // namespace
-
-llvm::SmallString<128> StructuredDataTest::s_inputs_folder;
-
-TEST_F(StructuredDataTest, StringDump) {
+TEST(StructuredDataTest, StringDump) {
std::pair<llvm::StringRef, llvm::StringRef> TestCases[] = {
{R"(asdfg)", R"("asdfg")"},
{R"(as"df)", R"("as\"df")"},
@@ -49,14 +32,13 @@ TEST_F(StructuredDataTest, StringDump) {
}
}
-TEST_F(StructuredDataTest, ParseJSONFromFile) {
+TEST(StructuredDataTest, ParseJSONFromFile) {
Status status;
auto object_sp = StructuredData::ParseJSONFromFile(
FileSpec("non-existing-file.json", false), status);
EXPECT_EQ(nullptr, object_sp);
- llvm::SmallString<128> input = s_inputs_folder;
- llvm::sys::path::append(input, "StructuredData-basic.json");
+ std::string input = GetInputFilePath("StructuredData-basic.json");
object_sp = StructuredData::ParseJSONFromFile(FileSpec(input, false), status);
ASSERT_NE(nullptr, object_sp);
diff --git a/lldb/unittests/Utility/TildeExpressionResolverTest.cpp b/lldb/unittests/Utility/TildeExpressionResolverTest.cpp
index fd953390ed5..a24e998cb81 100644
--- a/lldb/unittests/Utility/TildeExpressionResolverTest.cpp
+++ b/lldb/unittests/Utility/TildeExpressionResolverTest.cpp
@@ -1,6 +1,6 @@
#include "gtest/gtest.h"
-#include "Mocks/MockTildeExpressionResolver.h"
+#include "Helpers/MockTildeExpressionResolver.h"
#include "lldb/Utility/TildeExpressionResolver.h"
#include "llvm/ADT/SmallString.h"
OpenPOWER on IntegriCloud