Change-Id: I5a3cbc99d34e05559426b521a964d1407b67a6c4
}
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;
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;