diff options
author | Elliott Hughes <enh@google.com> | 2023-04-20 18:22:12 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-04-20 18:22:12 +0000 |
commit | e7e444b0d7cbebf81683dbd86edcd310357cc27a (patch) | |
tree | 7363a3fe0eaf286f29a02c4f5f967572992a5be2 | |
parent | a7187250af15bb4c30e61a9b15136ee4b9d71a0d (diff) | |
parent | 85bcb38b12aec458c4346950cec394faaecf7238 (diff) | |
download | bionic-e7e444b0d7cbebf81683dbd86edcd310357cc27a.tar.gz |
Merge "Clarify dlfcn.dladdr_libc slightly." am: e393d48bc7 am: 6607207d5c am: 7ced97ace7 am: 85bcb38b12
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2548970
Change-Id: Ie9e32c820cc5a39344c00ee18cc34ae1639d13ce
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | tests/dlfcn_test.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/tests/dlfcn_test.cpp b/tests/dlfcn_test.cpp index 0c71b2ab7..b68ee7b51 100644 --- a/tests/dlfcn_test.cpp +++ b/tests/dlfcn_test.cpp @@ -987,24 +987,25 @@ TEST(dlfcn, dladdr_libc) { #endif Dl_info info; - void* addr = reinterpret_cast<void*>(puts); // well-known libc function + void* addr = reinterpret_cast<void*>(puts); // An arbitrary libc function. ASSERT_TRUE(dladdr(addr, &info) != 0); - char libc_realpath[PATH_MAX]; - // Check if libc is in canonical path or in alternate path. + const char* expected_path; if (strncmp(ALTERNATE_PATH_TO_SYSTEM_LIB, info.dli_fname, sizeof(ALTERNATE_PATH_TO_SYSTEM_LIB) - 1) == 0) { // Platform with emulated architecture. Symlink on ARC++. - ASSERT_TRUE(realpath(ALTERNATE_PATH_TO_LIBC, libc_realpath) == libc_realpath); + expected_path = ALTERNATE_PATH_TO_LIBC; } else if (strncmp(PATH_TO_BOOTSTRAP_LIBC, info.dli_fname, sizeof(PATH_TO_BOOTSTRAP_LIBC) - 1) == 0) { - ASSERT_TRUE(realpath(PATH_TO_BOOTSTRAP_LIBC, libc_realpath) == libc_realpath); + expected_path = PATH_TO_BOOTSTRAP_LIBC; } else { // /system/lib is symlink when this test is executed on host. - ASSERT_TRUE(realpath(PATH_TO_LIBC, libc_realpath) == libc_realpath); + expected_path = PATH_TO_LIBC; } + char libc_realpath[PATH_MAX]; + ASSERT_TRUE(realpath(expected_path, libc_realpath) != nullptr) << strerror(errno); ASSERT_STREQ(libc_realpath, info.dli_fname); // TODO: add check for dfi_fbase |