Add test for empty symbol lookup
Check that dlsym(handle, "") fails.
Bug: http://b/33530622
Test: bionic-unit-tests --gtest_filter=dlfcn*
Test: bionic-unit-tests-glibc --gtest_filter=dlfcn*
Change-Id: Iae572bd1d9b798be619c5018de2a5450bf37977e
diff --git a/tests/dlfcn_test.cpp b/tests/dlfcn_test.cpp
index 46f6ec0..b38a353 100644
--- a/tests/dlfcn_test.cpp
+++ b/tests/dlfcn_test.cpp
@@ -172,6 +172,16 @@
dlclose(handle);
}
+TEST(dlfcn, dlsym_handle_empty_symbol) {
+ // check that dlsym of an empty symbol fails (see http://b/33530622)
+ void* handle = dlopen("libtest_dlsym_from_this.so", RTLD_NOW);
+ ASSERT_TRUE(handle != nullptr) << dlerror();
+ void* sym = dlsym(handle, "");
+ ASSERT_TRUE(sym == nullptr);
+ ASSERT_SUBSTR("undefined symbol: ", dlerror());
+ dlclose(handle);
+}
+
TEST(dlfcn, dlsym_with_dependencies) {
void* handle = dlopen("libtest_with_dependency.so", RTLD_NOW);
ASSERT_TRUE(handle != nullptr);