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
diff --git a/libunwindstack/tests/ElfTestUtils.cpp b/libunwindstack/tests/ElfTestUtils.cpp
index 8755f16..81064dd 100644
--- a/libunwindstack/tests/ElfTestUtils.cpp
+++ b/libunwindstack/tests/ElfTestUtils.cpp
@@ -45,6 +45,15 @@
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 @@
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 {