Merge "Hide unflagged mainline prebuilts with missing source." into main
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user