Add dlfcn_test to glibc test suite.

Bug: 18186310

(cherry picked from commit eb27bbae8f)

Change-Id: I1d608dfa12dbafbdcdb8bc6d818c5872404c19e0
This commit is contained in:
Dmitriy Ivanov
2014-10-30 23:42:45 -07:00
parent e4bc6f026a
commit 382e06ce8e
5 changed files with 81 additions and 79 deletions

View File

@@ -188,14 +188,14 @@ TEST(dlfcn, dlopen_check_order) {
// get_answer2() is defined in (b, d)
void* sym = dlsym(RTLD_DEFAULT, "dlopen_test_get_answer");
ASSERT_TRUE(sym == nullptr);
void* handle = dlopen("libtest_check_order.so", RTLD_NOW);
void* handle = dlopen("libtest_check_order.so", RTLD_NOW | RTLD_GLOBAL);
ASSERT_TRUE(handle != nullptr);
typedef int (*fn_t) (void);
fn_t fn, fn2;
fn = reinterpret_cast<fn_t>(dlsym(RTLD_DEFAULT, "dlopen_test_get_answer"));
ASSERT_TRUE(fn != NULL);
ASSERT_TRUE(fn != NULL) << dlerror();
fn2 = reinterpret_cast<fn_t>(dlsym(RTLD_DEFAULT, "dlopen_test_get_answer2"));
ASSERT_TRUE(fn2 != NULL);
ASSERT_TRUE(fn2 != NULL) << dlerror();
ASSERT_EQ(42, fn());
ASSERT_EQ(43, fn2());
@@ -248,6 +248,7 @@ TEST(dlfcn, dlopen_check_rtld_global) {
// libtest_with_dependency_loop_a.so
TEST(dlfcn, dlopen_check_loop) {
void* handle = dlopen("libtest_with_dependency_loop.so", RTLD_NOW);
#if defined(__BIONIC__)
ASSERT_TRUE(handle == nullptr);
ASSERT_STREQ("dlopen failed: recursive link to \"libtest_with_dependency_loop_a.so\"", dlerror());
// This symbol should never be exposed
@@ -261,6 +262,10 @@ TEST(dlfcn, dlopen_check_loop) {
handle = dlopen("libtest_with_dependency_loop.so", RTLD_NOW | RTLD_NOLOAD);
ASSERT_TRUE(handle == nullptr);
ASSERT_STREQ("dlopen failed: library \"libtest_with_dependency_loop.so\" wasn't loaded and RTLD_NOLOAD prevented it", dlerror());
#else // glibc allows recursive links
ASSERT_TRUE(handle != nullptr);
dlclose(handle);
#endif
}
TEST(dlfcn, dlopen_nodelete) {