Fix symlinks from APEX to partitions

Previously, the symlink optimization for APEXes assumed that the target
of the symlinks are in the system partition. The assumption however
doesn't hold always because the file that was added to the APEX might be
with system_ext_specific: true or vendor: true.

Bug: 265598720
Test: m nothing
Change-Id: Ieb9a6769320c0ec697a88c0cae977e7d65288362
This commit is contained in:
Jiyong Park
2023-02-17 18:22:25 +09:00
parent af8b950357
commit ce2436302a
4 changed files with 33 additions and 8 deletions

View File

@@ -7122,7 +7122,10 @@ func TestSymlinksFromApexToSystem(t *testing.T) {
cc_library {
name: "mylib",
srcs: ["mylib.cpp"],
shared_libs: ["myotherlib"],
shared_libs: [
"myotherlib",
"myotherlib_ext",
],
system_shared_libs: [],
stl: "none",
apex_available: [
@@ -7146,6 +7149,20 @@ func TestSymlinksFromApexToSystem(t *testing.T) {
min_sdk_version: "current",
}
cc_library {
name: "myotherlib_ext",
srcs: ["mylib.cpp"],
system_shared_libs: [],
system_ext_specific: true,
stl: "none",
apex_available: [
"myapex",
"myapex.updatable",
"//apex_available:platform",
],
min_sdk_version: "current",
}
java_library {
name: "myjar",
srcs: ["foo/bar/MyClass.java"],
@@ -7186,12 +7203,15 @@ func TestSymlinksFromApexToSystem(t *testing.T) {
t.Errorf("%q is not found", file)
}
ensureSymlinkExists := func(t *testing.T, files []fileInApex, file string) {
ensureSymlinkExists := func(t *testing.T, files []fileInApex, file string, target string) {
for _, f := range files {
if f.path == file {
if !f.isLink {
t.Errorf("%q is not a symlink", file)
}
if f.src != target {
t.Errorf("expected symlink target to be %q, got %q", target, f.src)
}
return
}
}
@@ -7205,23 +7225,27 @@ func TestSymlinksFromApexToSystem(t *testing.T) {
ensureRealfileExists(t, files, "javalib/myjar.jar")
ensureRealfileExists(t, files, "lib64/mylib.so")
ensureRealfileExists(t, files, "lib64/myotherlib.so")
ensureRealfileExists(t, files, "lib64/myotherlib_ext.so")
files = getFiles(t, ctx, "myapex.updatable", "android_common_myapex.updatable_image")
ensureRealfileExists(t, files, "javalib/myjar.jar")
ensureRealfileExists(t, files, "lib64/mylib.so")
ensureRealfileExists(t, files, "lib64/myotherlib.so")
ensureRealfileExists(t, files, "lib64/myotherlib_ext.so")
// For bundled build, symlink to the system for the non-updatable APEXes only
ctx = testApex(t, bp)
files = getFiles(t, ctx, "myapex", "android_common_myapex_image")
ensureRealfileExists(t, files, "javalib/myjar.jar")
ensureRealfileExists(t, files, "lib64/mylib.so")
ensureSymlinkExists(t, files, "lib64/myotherlib.so") // this is symlink
ensureSymlinkExists(t, files, "lib64/myotherlib.so", "/system/lib64/myotherlib.so") // this is symlink
ensureSymlinkExists(t, files, "lib64/myotherlib_ext.so", "/system_ext/lib64/myotherlib_ext.so") // this is symlink
files = getFiles(t, ctx, "myapex.updatable", "android_common_myapex.updatable_image")
ensureRealfileExists(t, files, "javalib/myjar.jar")
ensureRealfileExists(t, files, "lib64/mylib.so")
ensureRealfileExists(t, files, "lib64/myotherlib.so") // this is a real file
ensureRealfileExists(t, files, "lib64/myotherlib.so") // this is a real file
ensureRealfileExists(t, files, "lib64/myotherlib_ext.so") // this is a real file
}
func TestSymlinksFromApexToSystemRequiredModuleNames(t *testing.T) {