summaryrefslogtreecommitdiff
path: root/libnativeloader/native_loader_test.cpp
diff options
context:
space:
mode:
authorJooyung Han <jooyung@google.com>2020-03-03 00:46:50 +0900
committerTreehugger Robot <treehugger-gerrit@google.com>2020-03-04 05:56:39 +0000
commit538f99ab285c1440969b9b3331fc0ce750c0d316 (patch)
tree018e9cbfc08ba39b3f35e457a8658fcc4cc8db75 /libnativeloader/native_loader_test.cpp
parent6fc471e510d6a4e9c31fcab6c0542e2efdf50099 (diff)
Loading JNI libraries in an APEX
To load JNI libraries in an APEX, libnativeloader relies on jni.config.txt file which contains available JNI libraries for APEX namespaces: com_android_foo libfoo_jni.so:... com_android_bar libbar_jni.so:... This file is generated by linkerconfig. Bug: 143733063 Test: cuttlestone boots (For now, no behavioral changes because jni.config.txt is empty) Change-Id: I066de90a73875118be53972e50d076061922d762
Diffstat (limited to 'libnativeloader/native_loader_test.cpp')
-rw-r--r--libnativeloader/native_loader_test.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/libnativeloader/native_loader_test.cpp b/libnativeloader/native_loader_test.cpp
index f0446f0db1..e36a7e6de2 100644
--- a/libnativeloader/native_loader_test.cpp
+++ b/libnativeloader/native_loader_test.cpp
@@ -38,6 +38,7 @@ using ::testing::StrEq;
using ::testing::_;
using internal::ConfigEntry;
using internal::ParseConfig;
+using internal::ParseJniConfig;
#if defined(__LP64__)
#define LIB_DIR "lib64"
@@ -682,5 +683,28 @@ TEST(NativeLoaderConfigParser, RejectMalformed) {
ASSERT_FALSE(ParseConfig("libA.so nopreload # comment", always_true).ok());
}
+TEST(NativeLoaderJniConfigParser, BasicLoading) {
+ const char file_content[] = R"(
+# comment
+com_android_foo libfoo.so
+# Empty line is ignored
+
+com_android_bar libbar.so:libbar2.so
+)";
+
+ std::map<std::string, std::string> expected_result{
+ {"com_android_foo", "libfoo.so"},
+ {"com_android_bar", "libbar.so:libbar2.so"},
+ };
+
+ Result<std::map<std::string, std::string>> result = ParseJniConfig(file_content);
+ ASSERT_RESULT_OK(result);
+ ASSERT_EQ(expected_result, *result);
+}
+
+TEST(NativeLoaderJniConfigParser, RejectMalformed) {
+ ASSERT_FALSE(ParseJniConfig("com_android_foo").ok());
+}
+
} // namespace nativeloader
} // namespace android