Refactorings to make more logic available at the top level in
native_loader.cpp.
- Make the code that determines the partition from the dex path
available to code in native_loader.cpp, and rename it since it'll be
applied to arbitrary paths, not just APK's.
- Move the linker namespace constants to a header file.
- Various other minor code cleanups.
To prepare for a later CL that needs to access these things from
OpenNativeLibrary. No functional changes.
Test: atest libnativeloader_e2e_tests libnativeloader_test
Bug: 237577392
Change-Id: Ifc762bf6d4664b2d477c4ed3af58f149fb4c1189
diff --git a/libnativeloader/native_loader_test.cpp b/libnativeloader/native_loader_test.cpp
index 72348ed..3b05aae 100644
--- a/libnativeloader/native_loader_test.cpp
+++ b/libnativeloader/native_loader_test.cpp
@@ -564,7 +564,8 @@
public com_android_bar libpublic.so
)";
- auto jni_libs = ParseApexLibrariesConfig(file_content, "jni");
+ Result<std::map<std::string, std::string>> jni_libs =
+ ParseApexLibrariesConfig(file_content, "jni");
ASSERT_RESULT_OK(jni_libs);
std::map<std::string, std::string> expected_jni_libs {
{"com_android_foo", "libfoo.so"},
@@ -572,7 +573,8 @@
};
ASSERT_EQ(expected_jni_libs, *jni_libs);
- auto public_libs = ParseApexLibrariesConfig(file_content, "public");
+ Result<std::map<std::string, std::string>> public_libs =
+ ParseApexLibrariesConfig(file_content, "public");
ASSERT_RESULT_OK(public_libs);
std::map<std::string, std::string> expected_public_libs {
{"com_android_bar", "libpublic.so"},
@@ -586,7 +588,7 @@
# missing <library list>
jni com_android_bar
)";
- auto result = ParseApexLibrariesConfig(file_content, "jni");
+ Result<std::map<std::string, std::string>> result = ParseApexLibrariesConfig(file_content, "jni");
ASSERT_FALSE(result.ok());
ASSERT_EQ("Malformed line \"jni com_android_bar\"", result.error().message());
}
@@ -598,7 +600,7 @@
# unknown tag
unknown com_android_foo libfoo
)";
- auto result = ParseApexLibrariesConfig(file_content, "jni");
+ Result<std::map<std::string, std::string>> result = ParseApexLibrariesConfig(file_content, "jni");
ASSERT_FALSE(result.ok());
ASSERT_EQ("Invalid tag \"unknown com_android_foo libfoo\"", result.error().message());
}
@@ -608,7 +610,7 @@
# apex linker namespace should be mangled ('.' -> '_')
jni com.android.foo lib
)";
- auto result = ParseApexLibrariesConfig(file_content, "jni");
+ Result<std::map<std::string, std::string>> result = ParseApexLibrariesConfig(file_content, "jni");
ASSERT_FALSE(result.ok());
ASSERT_EQ("Invalid apex_namespace \"jni com.android.foo lib\"", result.error().message());
}
@@ -618,7 +620,7 @@
# library list is ":" separated list of filenames
jni com_android_foo lib64/libfoo.so
)";
- auto result = ParseApexLibrariesConfig(file_content, "jni");
+ Result<std::map<std::string, std::string>> result = ParseApexLibrariesConfig(file_content, "jni");
ASSERT_FALSE(result.ok());
ASSERT_EQ("Invalid library_list \"jni com_android_foo lib64/libfoo.so\"", result.error().message());
}