summaryrefslogtreecommitdiffstats
path: root/libunwindstack/tests/ElfTestUtils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libunwindstack/tests/ElfTestUtils.cpp')
-rw-r--r--libunwindstack/tests/ElfTestUtils.cpp11
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 {