diff options
author | Pavel Labath <labath@google.com> | 2017-06-29 13:02:11 +0000 |
---|---|---|
committer | Pavel Labath <labath@google.com> | 2017-06-29 13:02:11 +0000 |
commit | 7ed3e22f00468c71d561843bdb53d93d309ae92e (patch) | |
tree | b9ce5cd4c82dfee7b77c9268de58c6614ac89769 /lldb/unittests/ObjectFile | |
parent | 476f855ec8cbe465e26fc9e828cc1fe376c491ef (diff) | |
download | bcm5719-llvm-7ed3e22f00468c71d561843bdb53d93d309ae92e.tar.gz bcm5719-llvm-7ed3e22f00468c71d561843bdb53d93d309ae92e.zip |
[unittests] Add a helper function for getting an input file
Summary:
Fetching an input file required about five lines of code, and this was
repeated in multiple unit tests, with slight variations. Add a helper
function for doing that into the lldbUtilityMocks module (which I rename
to lldbUtilityHelpers to commemorate the fact it includes more than
mocks)
Reviewers: zturner, eugene
Subscribers: emaste, mgorny, lldb-commits
Differential Revision: https://reviews.llvm.org/D34683
llvm-svn: 306668
Diffstat (limited to 'lldb/unittests/ObjectFile')
-rw-r--r-- | lldb/unittests/ObjectFile/ELF/CMakeLists.txt | 1 | ||||
-rw-r--r-- | lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp | 16 |
2 files changed, 5 insertions, 12 deletions
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)); |