am 898aab28: Merge "Add test for --hash-style=sysv"

* commit '898aab282cff2a2949bc1726f8a4b81c1c30148e':
  Add test for --hash-style=sysv
This commit is contained in:
Dmitriy Ivanov 2014-11-14 19:33:51 +00:00 committed by Android Git Automerger
commit 4ed181416a
3 changed files with 35 additions and 4 deletions

View File

@ -301,9 +301,7 @@ bionic-unit-tests-glibc_shared_libraries := \
libdl_preempt_test_1 \ libdl_preempt_test_1 \
libdl_preempt_test_2 libdl_preempt_test_2
ifneq ($(filter $(TARGET_ARCH),arm arm64),$(TARGET_ARCH))
bionic-unit-tests-glibc_shared_libraries += libdl_test_df_1_global bionic-unit-tests-glibc_shared_libraries += libdl_test_df_1_global
endif
bionic-unit-tests-glibc_whole_static_libraries := \ bionic-unit-tests-glibc_whole_static_libraries := \
libBionicStandardTests \ libBionicStandardTests \

View File

@ -669,12 +669,32 @@ TEST(dlfcn, dlopen_library_with_only_gnu_hash) {
ASSERT_TRUE(fn == dlinfo.dli_saddr); ASSERT_TRUE(fn == dlinfo.dli_saddr);
ASSERT_STREQ("getRandomNumber", dlinfo.dli_sname); ASSERT_STREQ("getRandomNumber", dlinfo.dli_sname);
ASSERT_STREQ("libgnu-hash-table-library.so", dlinfo.dli_fname); ASSERT_SUBSTR("libgnu-hash-table-library.so", dlinfo.dli_fname);
#else #else
GTEST_LOG_(INFO) << "This test does nothing for mips/mips64; mips toolchain does not support '--hash-style=gnu'\n"; GTEST_LOG_(INFO) << "This test does nothing for mips/mips64; mips toolchain does not support '--hash-style=gnu'\n";
#endif #endif
} }
TEST(dlfcn, dlopen_library_with_only_sysv_hash) {
void* handle = dlopen("libsysv-hash-table-library.so", RTLD_NOW);
ASSERT_TRUE(handle != nullptr) << dlerror();
auto guard = make_scope_guard([&]() {
dlclose(handle);
});
void* sym = dlsym(handle, "getRandomNumber");
ASSERT_TRUE(sym != nullptr) << dlerror();
int (*fn)(void);
fn = reinterpret_cast<int (*)(void)>(sym);
EXPECT_EQ(4, fn());
Dl_info dlinfo;
ASSERT_TRUE(0 != dladdr(reinterpret_cast<void*>(fn), &dlinfo));
ASSERT_TRUE(fn == dlinfo.dli_saddr);
ASSERT_STREQ("getRandomNumber", dlinfo.dli_sname);
ASSERT_SUBSTR("libsysv-hash-table-library.so", dlinfo.dli_fname);
}
TEST(dlfcn, dlopen_bad_flags) { TEST(dlfcn, dlopen_bad_flags) {
dlerror(); // Clear any pending errors. dlerror(); // Clear any pending errors.
void* handle; void* handle;

View File

@ -28,7 +28,7 @@ common_additional_dependencies := \
$(TEST_PATH)/Android.build.mk $(TEST_PATH)/Android.build.mk
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# Library used by dlfcn tests. # Library to test gnu-styled hash
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
ifneq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),mips mips64)) ifneq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),mips mips64))
libgnu-hash-table-library_src_files := \ libgnu-hash-table-library_src_files := \
@ -42,6 +42,19 @@ module_tag := optional
include $(LOCAL_PATH)/Android.build.testlib.mk include $(LOCAL_PATH)/Android.build.testlib.mk
endif endif
# -----------------------------------------------------------------------------
# Library to test sysv-styled hash
# -----------------------------------------------------------------------------
libsysv-hash-table-library_src_files := \
dlext_test_library.cpp \
libsysv-hash-table-library_ldflags := \
-Wl,--hash-style=sysv \
module := libsysv-hash-table-library
module_tag := optional
include $(LOCAL_PATH)/Android.build.testlib.mk
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# Library used by dlext tests - with GNU RELRO program header # Library used by dlext tests - with GNU RELRO program header
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------