Merge "Hide unflagged mainline prebuilts with missing source." into main

This commit is contained in:
Treehugger Robot
2024-08-05 23:10:53 +00:00
committed by Gerrit Code Review
7 changed files with 204 additions and 48 deletions

View File

@@ -11465,6 +11465,118 @@ func TestInstallationRulesForMultipleApexPrebuilts(t *testing.T) {
}
}
// Test that product packaging installs the selected mainline module in workspaces withtout source mainline module
func TestInstallationRulesForMultipleApexPrebuiltsWithoutSource(t *testing.T) {
// for a mainline module family, check that only the flagged soong module is visible to make
checkHideFromMake := func(t *testing.T, ctx *android.TestContext, visibleModuleNames []string, hiddenModuleNames []string) {
variation := func(moduleName string) string {
ret := "android_common_com.android.adservices"
if moduleName == "com.google.android.foo" {
ret = "android_common_com.google.android.foo_com.google.android.foo"
}
return ret
}
for _, visibleModuleName := range visibleModuleNames {
visibleModule := ctx.ModuleForTests(visibleModuleName, variation(visibleModuleName)).Module()
android.AssertBoolEquals(t, "Apex "+visibleModuleName+" selected using apex_contributions should be visible to make", false, visibleModule.IsHideFromMake())
}
for _, hiddenModuleName := range hiddenModuleNames {
hiddenModule := ctx.ModuleForTests(hiddenModuleName, variation(hiddenModuleName)).Module()
android.AssertBoolEquals(t, "Apex "+hiddenModuleName+" not selected using apex_contributions should be hidden from make", true, hiddenModule.IsHideFromMake())
}
}
bp := `
apex_key {
name: "com.android.adservices.key",
public_key: "com.android.adservices.avbpubkey",
private_key: "com.android.adservices.pem",
}
// AOSP source apex
apex {
name: "com.android.adservices",
key: "com.android.adservices.key",
updatable: false,
}
// Prebuilt Google APEX.
prebuilt_apex {
name: "com.google.android.adservices",
apex_name: "com.android.adservices",
src: "com.android.foo-arm.apex",
}
// Another Prebuilt Google APEX
prebuilt_apex {
name: "com.google.android.adservices.v2",
apex_name: "com.android.adservices",
src: "com.android.foo-arm.apex",
}
// APEX contribution modules
apex_contributions {
name: "adservices.prebuilt.contributions",
api_domain: "com.android.adservices",
contents: ["prebuilt_com.google.android.adservices"],
}
apex_contributions {
name: "adservices.prebuilt.v2.contributions",
api_domain: "com.android.adservices",
contents: ["prebuilt_com.google.android.adservices.v2"],
}
`
testCases := []struct {
desc string
selectedApexContributions string
expectedVisibleModuleNames []string
expectedHiddenModuleNames []string
}{
{
desc: "No apex contributions selected, source aosp apex should be visible, and mainline prebuilts should be hidden",
selectedApexContributions: "",
expectedVisibleModuleNames: []string{"com.android.adservices"},
expectedHiddenModuleNames: []string{"com.google.android.adservices", "com.google.android.adservices.v2"},
},
{
desc: "Prebuilt apex prebuilt_com.android.foo is selected",
selectedApexContributions: "adservices.prebuilt.contributions",
expectedVisibleModuleNames: []string{"com.android.adservices", "com.google.android.adservices"},
expectedHiddenModuleNames: []string{"com.google.android.adservices.v2"},
},
{
desc: "Prebuilt apex prebuilt_com.android.foo.v2 is selected",
selectedApexContributions: "adservices.prebuilt.v2.contributions",
expectedVisibleModuleNames: []string{"com.android.adservices", "com.google.android.adservices.v2"},
expectedHiddenModuleNames: []string{"com.google.android.adservices"},
},
}
for _, tc := range testCases {
preparer := android.GroupFixturePreparers(
android.FixtureMergeMockFs(map[string][]byte{
"system/sepolicy/apex/com.android.adservices-file_contexts": nil,
}),
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.BuildFlags = map[string]string{
"RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": tc.selectedApexContributions,
}
}),
)
ctx := testApex(t, bp, preparer)
checkHideFromMake(t, ctx, tc.expectedVisibleModuleNames, tc.expectedHiddenModuleNames)
}
}
func TestAconfifDeclarationsValidation(t *testing.T) {
aconfigDeclarationLibraryString := func(moduleNames []string) (ret string) {
for _, moduleName := range moduleNames {

View File

@@ -561,6 +561,7 @@ func TestBootclasspathFragmentInPrebuiltArtApex(t *testing.T) {
result := preparers.RunTestWithBp(t, fmt.Sprintf(bp, "enabled: false,"))
java.CheckModuleDependencies(t, result.TestContext, "com.android.art", "android_common_com.android.art", []string{
`all_apex_contributions`,
`dex2oatd`,
`prebuilt_art-bootclasspath-fragment`,
`prebuilt_com.android.art.apex.selector`,
@@ -568,6 +569,7 @@ func TestBootclasspathFragmentInPrebuiltArtApex(t *testing.T) {
})
java.CheckModuleDependencies(t, result.TestContext, "art-bootclasspath-fragment", "android_common_com.android.art", []string{
`all_apex_contributions`,
`dex2oatd`,
`prebuilt_bar`,
`prebuilt_com.android.art.deapexer`,

View File

@@ -274,6 +274,7 @@ func TestPrebuiltSystemserverclasspathFragmentContents(t *testing.T) {
ctx := result.TestContext
java.CheckModuleDependencies(t, ctx, "myapex", "android_common_myapex", []string{
`all_apex_contributions`,
`dex2oatd`,
`prebuilt_myapex.apex.selector`,
`prebuilt_myapex.deapexer`,
@@ -281,6 +282,7 @@ func TestPrebuiltSystemserverclasspathFragmentContents(t *testing.T) {
})
java.CheckModuleDependencies(t, ctx, "mysystemserverclasspathfragment", "android_common_myapex", []string{
`all_apex_contributions`,
`prebuilt_bar`,
`prebuilt_foo`,
`prebuilt_myapex.deapexer`,
@@ -432,6 +434,7 @@ func TestPrebuiltStandaloneSystemserverclasspathFragmentContents(t *testing.T) {
ctx := result.TestContext
java.CheckModuleDependencies(t, ctx, "mysystemserverclasspathfragment", "android_common_myapex", []string{
`all_apex_contributions`,
`prebuilt_bar`,
`prebuilt_foo`,
`prebuilt_myapex.deapexer`,