diff options
author | Christopher Ferris <cferris@google.com> | 2017-07-11 15:29:32 -0700 |
---|---|---|
committer | Christopher Ferris <cferris@google.com> | 2017-07-11 19:10:34 -0700 |
commit | f6d5431273a6293703853fc3d4043ed2c5d5a3c9 (patch) | |
tree | 38b0e92916e097f917d5464954e1434e96acc6f9 /libunwindstack/tests/ElfTestUtils.cpp | |
parent | 5aee3ff22a42f9ff7a35e0181d19821b1510fee2 (diff) | |
download | system_core-f6d5431273a6293703853fc3d4043ed2c5d5a3c9.tar.gz system_core-f6d5431273a6293703853fc3d4043ed2c5d5a3c9.tar.bz2 system_core-f6d5431273a6293703853fc3d4043ed2c5d5a3c9.zip |
A few cleanups.
- Cleanup the blueprint file a bit.
- Fix the formatting in DwarfMemoryTest.cpp.
- Fix the misnamed test MemoryBuffer.cpp to MemoryBufferTest.cpp.
- Add a function to find the location of the test files so it's not
necessary to run the test in the same directory as the test files.
Bug: 23762183
Test: Builds and unit tests pass.
Change-Id: I5666972bd01f14b8ee47c518f1840f8aeb7fd08b
Diffstat (limited to 'libunwindstack/tests/ElfTestUtils.cpp')
-rw-r--r-- | libunwindstack/tests/ElfTestUtils.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libunwindstack/tests/ElfTestUtils.cpp b/libunwindstack/tests/ElfTestUtils.cpp index 8755f163b..81064ddf1 100644 --- a/libunwindstack/tests/ElfTestUtils.cpp +++ b/libunwindstack/tests/ElfTestUtils.cpp @@ -45,6 +45,15 @@ void TestInitEhdr(Ehdr* ehdr, uint32_t elf_class, uint32_t machine_type) { ehdr->e_ehsize = sizeof(Ehdr); } +static std::string GetTestFileDirectory() { + std::string exec(testing::internal::GetArgvs()[0]); + auto const value = exec.find_last_of('/'); + if (value == std::string::npos) { + return "tests/files/"; + } + return exec.substr(0, value + 1) + "tests/files/"; +} + template <typename Ehdr, typename Shdr> void TestInitGnuDebugdata(uint32_t elf_class, uint32_t machine, bool init_gnu_debugdata, TestCopyFuncType copy_func) { @@ -91,7 +100,7 @@ void TestInitGnuDebugdata(uint32_t elf_class, uint32_t machine, bool init_gnu_de offset = symtab_offset + 0x100; if (init_gnu_debugdata) { // Read in the compressed elf data and copy it in. - name = "tests/files/"; + name = GetTestFileDirectory(); if (elf_class == ELFCLASS32) { name += "elf32.xz"; } else { |