summaryrefslogtreecommitdiff
path: root/apex/apex_test.go
diff options
context:
space:
mode:
author Jiyong Park <jiyong@google.com> 2021-06-11 17:22:09 +0900
committer Jiyong Park <jiyong@google.com> 2021-06-24 11:27:41 +0900
commit7d55b617838a425d9d24ae87dd5ae8a13f18e082 (patch)
tree049b731e04d73c569fdc47d01da41125efd6a1ae /apex/apex_test.go
parenta8de9fb2aea3e543313eef63ec2c8b1389796097 (diff)
Rust module in APEX uses stub libraries across APEX boundaries
This change fixes a bug that rust module in APEX has access to private symbols of a native library even when the native library is outside of the APEX. To fix this, the stub selection logic in the cc package is exctacted as a function ChooseStubOrImpl and is used also in the rust package. Bug: 190767845 Test: m Merged-In: I5c4cbdd5d27f257ab329d9dadbcd87d41a87f46a Change-Id: I5c4cbdd5d27f257ab329d9dadbcd87d41a87f46a (cherry picked from commit 3b5f88e0913f3df579f4dc0c87daac88665b1073)
Diffstat (limited to 'apex/apex_test.go')
-rw-r--r--apex/apex_test.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 792f7f392..624ad1b22 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -839,6 +839,7 @@ func TestApexWithStubs(t *testing.T) {
name: "myapex",
key: "myapex.key",
native_shared_libs: ["mylib", "mylib3"],
+ binaries: ["foo.rust"],
updatable: false,
}
@@ -887,6 +888,25 @@ func TestApexWithStubs(t *testing.T) {
stl: "none",
apex_available: [ "myapex" ],
}
+
+ rust_binary {
+ name: "foo.rust",
+ srcs: ["foo.rs"],
+ shared_libs: ["libfoo.shared_from_rust"],
+ prefer_rlib: true,
+ apex_available: ["myapex"],
+ }
+
+ cc_library_shared {
+ name: "libfoo.shared_from_rust",
+ srcs: ["mylib.cpp"],
+ system_shared_libs: [],
+ stl: "none",
+ stubs: {
+ versions: ["10", "11", "12"],
+ },
+ }
+
`)
apexRule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("apexRule")
@@ -924,7 +944,17 @@ func TestApexWithStubs(t *testing.T) {
"lib64/mylib.so",
"lib64/mylib3.so",
"lib64/mylib4.so",
+ "bin/foo.rust",
+ "lib64/libc++.so", // by the implicit dependency from foo.rust
+ "lib64/liblog.so", // by the implicit dependency from foo.rust
})
+
+ // Ensure that stub dependency from a rust module is not included
+ ensureNotContains(t, copyCmds, "image.apex/lib64/libfoo.shared_from_rust.so")
+ // The rust module is linked to the stub cc library
+ rustDeps := ctx.ModuleForTests("foo.rust", "android_arm64_armv8-a_apex10000").Rule("rustc").Args["linkFlags"]
+ ensureContains(t, rustDeps, "libfoo.shared_from_rust/android_arm64_armv8-a_shared_current/libfoo.shared_from_rust.so")
+ ensureNotContains(t, rustDeps, "libfoo.shared_from_rust/android_arm64_armv8-a_shared/libfoo.shared_from_rust.so")
}
func TestApexWithStubsWithMinSdkVersion(t *testing.T) {