Loading apex/apex.go +8 −2 Original line number Diff line number Diff line Loading @@ -684,8 +684,14 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext, keyFile and } else { readOnlyPaths = append(readOnlyPaths, pathInApex) } if !android.InList(f.installDir, executablePaths) { executablePaths = append(executablePaths, f.installDir) dir := f.installDir for !android.InList(dir, executablePaths) && dir != "" { executablePaths = append(executablePaths, dir) dir, _ = filepath.Split(dir) // move up to the parent if len(dir) > 0 { // remove trailing slash dir = dir[:len(dir)-1] } } } sort.Strings(readOnlyPaths) Loading apex/apex_test.go +32 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ func testApex(t *testing.T, bp string) *android.TestContext { ctx.RegisterModuleType("cc_library_shared", android.ModuleFactoryAdaptor(cc.LibrarySharedFactory)) ctx.RegisterModuleType("cc_object", android.ModuleFactoryAdaptor(cc.ObjectFactory)) ctx.RegisterModuleType("toolchain_library", android.ModuleFactoryAdaptor(cc.ToolchainLibraryFactory)) ctx.RegisterModuleType("prebuilt_etc", android.ModuleFactoryAdaptor(android.PrebuiltEtcFactory)) ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) { ctx.BottomUp("link", cc.LinkageMutator).Parallel() ctx.BottomUp("version", cc.VersionMutator).Parallel() Loading Loading @@ -94,6 +95,7 @@ func testApex(t *testing.T, bp string) *android.TestContext { "apex_manifest.json": nil, "system/sepolicy/apex/myapex-file_contexts": nil, "mylib.cpp": nil, "myprebuilt": nil, }) _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) android.FailIfErrored(t, errs) Loading Loading @@ -415,3 +417,33 @@ func TestApexWithSystemLibsStubs(t *testing.T) { ensureContains(t, mylibCFlags, "__LIBDL_API__=27") ensureContains(t, mylibSharedCFlags, "__LIBDL_API__=27") } func TestFilesInSubDir(t *testing.T) { ctx := testApex(t, ` apex { name: "myapex", key: "myapex.key", prebuilts: ["myetc"], } apex_key { name: "myapex.key", public_key: "testkey.avbpubkey", private_key: "testkey.pem", } prebuilt_etc { name: "myetc", src: "myprebuilt", sub_dir: "foo/bar", } `) generateFsRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("generateFsConfig") dirs := strings.Split(generateFsRule.Args["exec_paths"], " ") // Ensure that etc, etc/foo, and etc/foo/bar are all listed ensureListContains(t, dirs, "etc") ensureListContains(t, dirs, "etc/foo") ensureListContains(t, dirs, "etc/foo/bar") } Loading
apex/apex.go +8 −2 Original line number Diff line number Diff line Loading @@ -684,8 +684,14 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext, keyFile and } else { readOnlyPaths = append(readOnlyPaths, pathInApex) } if !android.InList(f.installDir, executablePaths) { executablePaths = append(executablePaths, f.installDir) dir := f.installDir for !android.InList(dir, executablePaths) && dir != "" { executablePaths = append(executablePaths, dir) dir, _ = filepath.Split(dir) // move up to the parent if len(dir) > 0 { // remove trailing slash dir = dir[:len(dir)-1] } } } sort.Strings(readOnlyPaths) Loading
apex/apex_test.go +32 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ func testApex(t *testing.T, bp string) *android.TestContext { ctx.RegisterModuleType("cc_library_shared", android.ModuleFactoryAdaptor(cc.LibrarySharedFactory)) ctx.RegisterModuleType("cc_object", android.ModuleFactoryAdaptor(cc.ObjectFactory)) ctx.RegisterModuleType("toolchain_library", android.ModuleFactoryAdaptor(cc.ToolchainLibraryFactory)) ctx.RegisterModuleType("prebuilt_etc", android.ModuleFactoryAdaptor(android.PrebuiltEtcFactory)) ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) { ctx.BottomUp("link", cc.LinkageMutator).Parallel() ctx.BottomUp("version", cc.VersionMutator).Parallel() Loading Loading @@ -94,6 +95,7 @@ func testApex(t *testing.T, bp string) *android.TestContext { "apex_manifest.json": nil, "system/sepolicy/apex/myapex-file_contexts": nil, "mylib.cpp": nil, "myprebuilt": nil, }) _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) android.FailIfErrored(t, errs) Loading Loading @@ -415,3 +417,33 @@ func TestApexWithSystemLibsStubs(t *testing.T) { ensureContains(t, mylibCFlags, "__LIBDL_API__=27") ensureContains(t, mylibSharedCFlags, "__LIBDL_API__=27") } func TestFilesInSubDir(t *testing.T) { ctx := testApex(t, ` apex { name: "myapex", key: "myapex.key", prebuilts: ["myetc"], } apex_key { name: "myapex.key", public_key: "testkey.avbpubkey", private_key: "testkey.pem", } prebuilt_etc { name: "myetc", src: "myprebuilt", sub_dir: "foo/bar", } `) generateFsRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("generateFsConfig") dirs := strings.Split(generateFsRule.Args["exec_paths"], " ") // Ensure that etc, etc/foo, and etc/foo/bar are all listed ensureListContains(t, dirs, "etc") ensureListContains(t, dirs, "etc/foo") ensureListContains(t, dirs, "etc/foo/bar") }