A lib in APK can depend on other libs in the same APK
This hasn't worked because the path /mnt/apk/lib/<abi> wasn't in the
search paths of the linker namespace that the library is loaded (which
is the default namespace).
Fixing that by creating a new linker namespace 'microdroid' that
inherits the settings from the default namespace but adds the library
directory to the search paths, and loading the library from that
namespace.
Bug: N/A
Test: atest MicrodroidHostTestCases
Change-Id: I30c4ce86a48b80fa65e3b5ffeb90561fa1d2544e
diff --git a/tests/hostside/java/android/virt/test/MicrodroidTestCase.java b/tests/hostside/java/android/virt/test/MicrodroidTestCase.java
index f9794f7..5a11e9c 100644
--- a/tests/hostside/java/android/virt/test/MicrodroidTestCase.java
+++ b/tests/hostside/java/android/virt/test/MicrodroidTestCase.java
@@ -97,6 +97,7 @@
// Check if the command in vm_config.json was executed by examining the side effect of the
// command
assertThat(runOnMicrodroid("getprop", "debug.microdroid.app.run"), is("true"));
+ assertThat(runOnMicrodroid("getprop", "debug.microdroid.app.sublib.run"), is("true"));
// Manually execute the library and check the output
final String microdroidLauncher = "system/bin/microdroid_launcher";
diff --git a/tests/testapk/Android.bp b/tests/testapk/Android.bp
index 1122b25..fdc95de 100644
--- a/tests/testapk/Android.bp
+++ b/tests/testapk/Android.bp
@@ -13,13 +13,19 @@
// TODO(jiyong): make this a binary, not a shared library
cc_library_shared {
name: "MicrodroidTestNativeLib",
- srcs: ["src/native/*.cpp"],
+ srcs: ["src/native/testbinary.cpp"],
shared_libs: [
"android.system.keystore2-V1-ndk_platform",
"libbinder_ndk",
+ "MicrodroidTestNativeLibSub",
],
}
+cc_library_shared {
+ name: "MicrodroidTestNativeLibSub",
+ srcs: ["src/native/testlib.cpp"],
+}
+
genrule {
name: "MicrodroidTestApp.signed",
out: [
@@ -27,12 +33,12 @@
"MicrodroidTestApp.apk.idsig",
],
srcs: [":MicrodroidTestApp"],
- tools:["apksigner"],
+ tools: ["apksigner"],
tool_files: ["test.keystore"],
cmd: "$(location apksigner) sign " +
- "--ks $(location test.keystore) " +
- "--ks-pass=pass:testkey --key-pass=pass:testkey " +
- "--in $(in) " +
- "--out $(genDir)/MicrodroidTestApp.apk",
- // $(genDir)/MicrodroidTestApp.apk.idsig is generated implicitly
+ "--ks $(location test.keystore) " +
+ "--ks-pass=pass:testkey --key-pass=pass:testkey " +
+ "--in $(in) " +
+ "--out $(genDir)/MicrodroidTestApp.apk",
+ // $(genDir)/MicrodroidTestApp.apk.idsig is generated implicitly
}
diff --git a/tests/testapk/src/native/testbinary.cpp b/tests/testapk/src/native/testbinary.cpp
index 682ab2a..9bd594b 100644
--- a/tests/testapk/src/native/testbinary.cpp
+++ b/tests/testapk/src/native/testbinary.cpp
@@ -24,6 +24,8 @@
using aidl::android::system::keystore2::IKeystoreSecurityLevel;
using aidl::android::system::keystore2::IKeystoreService;
+extern void testlib_sub();
+
namespace {
bool test_keystore() {
@@ -52,6 +54,7 @@
printf(" ");
}
}
+ testlib_sub();
printf("\n");
__system_property_set("debug.microdroid.app.run", "true");
diff --git a/tests/testapk/src/native/testlib.cpp b/tests/testapk/src/native/testlib.cpp
new file mode 100644
index 0000000..792c6c8
--- /dev/null
+++ b/tests/testapk/src/native/testlib.cpp
@@ -0,0 +1,5 @@
+#include <sys/system_properties.h>
+
+void testlib_sub() {
+ __system_property_set("debug.microdroid.app.sublib.run", "true");
+}