Merge "Improve error message for empty list of public libs"

This commit is contained in:
Dimitry Ivanov 2016-04-22 14:30:24 +00:00 committed by Gerrit Code Review
commit 130bec7103
2 changed files with 9 additions and 1 deletions

View File

@ -2365,12 +2365,16 @@ int do_dlclose(void* handle) {
}
bool init_namespaces(const char* public_ns_sonames, const char* anon_ns_library_path) {
CHECK(public_ns_sonames != nullptr);
if (g_public_namespace_initialized) {
DL_ERR("public namespace has already been initialized.");
return false;
}
if (public_ns_sonames == nullptr || public_ns_sonames[0] == '\0') {
DL_ERR("error initializing public namespace: the list of public libraries is empty.");
return false;
}
std::vector<std::string> sonames = android::base::Split(public_ns_sonames, ":");
ProtectedDataGuard guard;

View File

@ -629,6 +629,10 @@ TEST(dlext, ns_smoke) {
ASSERT_STREQ("android_init_namespaces failed: error initializing public namespace: "
"\"libnstest_public.so\" was not found in the default namespace", dlerror());
ASSERT_FALSE(android_init_namespaces("", nullptr));
ASSERT_STREQ("android_init_namespaces failed: error initializing public namespace: "
"the list of public libraries is empty.", dlerror());
const std::string lib_path = std::string(getenv("ANDROID_DATA")) + NATIVE_TESTS_PATH;
const std::string lib_public_path = lib_path + "/public_namespace_libs/" + g_public_lib;