diff options
author | Elliott Hughes <enh@google.com> | 2023-04-19 12:57:08 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2023-04-19 20:01:17 +0000 |
commit | 0cf311c53b6fe7249d71d067787ad58056a49700 (patch) | |
tree | f9bbbdf3b70eb4200ac364f9e3e624ffd910d8ca | |
parent | be39cd5ebb76ad91984122b09edcbb1c865308cc (diff) | |
download | bionic-0cf311c53b6fe7249d71d067787ad58056a49700.tar.gz |
Clarify dlfcn.dladdr_libc slightly.
This isn't a very helpful way to say "realpath() failed":
```
bionic/tests/dlfcn_test.cpp:(1006) Failure in test dlfcn.dladdr_libc
Value of: realpath("/system/lib64/" "hwasan/libc.so", libc_realpath) == libc_realpath
Actual: false
Expected: true
```
Bug: http://b/278795547
Test: treehugger
Change-Id: I1078ab4a675b956327f2578086a1a5e7d8a2928b
-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 3f70279c1..f1f7759b4 100644 --- a/tests/dlfcn_test.cpp +++ b/tests/dlfcn_test.cpp @@ -981,24 +981,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 |