Fix dl* tests to run-on-host
Bug: http://b/20121152
Change-Id: I1e1f41d885c75dbb26f91565a53a15d62ef72ce6
diff --git a/tests/dlext_test.cpp b/tests/dlext_test.cpp
index 7012418..56a8f6f 100644
--- a/tests/dlext_test.cpp
+++ b/tests/dlext_test.cpp
@@ -134,6 +134,10 @@
TEST_F(DlExtTest, ExtInfoUseFdWithInvalidOffset) {
const std::string lib_path = std::string(getenv("ANDROID_DATA")) + LIBZIPPATH;
+ // lib_path is relative when $ANDROID_DATA is relative
+ char lib_realpath_buf[PATH_MAX];
+ ASSERT_TRUE(realpath(lib_path.c_str(), lib_realpath_buf) == lib_realpath_buf);
+ const std::string lib_realpath = std::string(lib_realpath_buf);
android_dlextinfo extinfo;
extinfo.flags = ANDROID_DLEXT_USE_LIBRARY_FD | ANDROID_DLEXT_USE_LIBRARY_FD_OFFSET;
@@ -158,7 +162,7 @@
extinfo.library_fd_offset = PAGE_SIZE;
handle_ = android_dlopen_ext("libname_ignored", RTLD_NOW, &extinfo);
ASSERT_TRUE(handle_ == nullptr);
- ASSERT_EQ("dlopen failed: \"" + lib_path + "\" has bad ELF magic", dlerror());
+ ASSERT_EQ("dlopen failed: \"" + lib_realpath + "\" has bad ELF magic", dlerror());
close(extinfo.library_fd);
}