Fix unload of recursively linked library

Expanded test for recursive libs. Fixed bug with unnecessary
  soinfo_free of already loaded library.

Change-Id: I2cc19f2650c8b12a35feeac127ef608ebba44d88
This commit is contained in:
Dmitriy Ivanov
2014-09-09 10:21:42 -07:00
parent 8d8a789c49
commit a6ac54a215
4 changed files with 42 additions and 7 deletions

View File

@@ -207,8 +207,19 @@ TEST(dlfcn, dlopen_check_order) {
// libtest_with_dependency_loop_a.so
TEST(dlfcn, dlopen_check_loop) {
void* handle = dlopen("libtest_with_dependency_loop.so", RTLD_NOW);
ASSERT_TRUE(handle == NULL);
ASSERT_TRUE(handle == nullptr);
ASSERT_STREQ("dlopen failed: recursive link to \"libtest_with_dependency_loop_a.so\"", dlerror());
// This symbol should never be exposed
void* f = dlsym(RTLD_DEFAULT, "dlopen_test_invalid_function");
ASSERT_TRUE(f == nullptr);
ASSERT_SUBSTR("undefined symbol: dlopen_test_invalid_function", dlerror());
// dlopen second time to make sure that the library wasn't loaded even though dlopen returned null.
// This may happen if during cleanup the root library or one of the depended libs were not removed
// from soinfo list.
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());
}
TEST(dlfcn, dlopen_failure) {