Merge "Convert test specific customizers to FixturePreparers"
This commit is contained in:
12
apex/apex.go
12
apex/apex.go
@@ -1207,11 +1207,13 @@ func useVendorAllowList(config android.Config) []string {
|
|||||||
}).([]string)
|
}).([]string)
|
||||||
}
|
}
|
||||||
|
|
||||||
// setUseVendorAllowListForTest overrides useVendorAllowList and must be called before the first
|
// setUseVendorAllowListForTest returns a FixturePreparer that overrides useVendorAllowList and
|
||||||
// call to useVendorAllowList()
|
// must be called before the first call to useVendorAllowList()
|
||||||
func setUseVendorAllowListForTest(config android.Config, allowList []string) {
|
func setUseVendorAllowListForTest(allowList []string) android.FixturePreparer {
|
||||||
config.Once(useVendorAllowListKey, func() interface{} {
|
return android.FixtureModifyConfig(func(config android.Config) {
|
||||||
return allowList
|
config.Once(useVendorAllowListKey, func() interface{} {
|
||||||
|
return allowList
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1021,11 +1021,13 @@ func TestApex_PlatformUsesLatestStubFromApex(t *testing.T) {
|
|||||||
srcs: ["mylib.cpp"],
|
srcs: ["mylib.cpp"],
|
||||||
shared_libs: ["libstub"],
|
shared_libs: ["libstub"],
|
||||||
}
|
}
|
||||||
`, func(fs map[string][]byte, config android.Config) {
|
`,
|
||||||
config.TestProductVariables.Platform_sdk_codename = proptools.StringPtr("Z")
|
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
||||||
config.TestProductVariables.Platform_sdk_final = proptools.BoolPtr(false)
|
variables.Platform_sdk_codename = proptools.StringPtr("Z")
|
||||||
config.TestProductVariables.Platform_version_active_codenames = []string{"Z"}
|
variables.Platform_sdk_final = proptools.BoolPtr(false)
|
||||||
})
|
variables.Platform_version_active_codenames = []string{"Z"}
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
// Ensure that mylib from myapex is built against the latest stub (current)
|
// Ensure that mylib from myapex is built against the latest stub (current)
|
||||||
mylibCflags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_static_apex10000").Rule("cc").Args["cFlags"]
|
mylibCflags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_static_apex10000").Rule("cc").Args["cFlags"]
|
||||||
@@ -1373,9 +1375,10 @@ func TestApexDependsOnLLNDKTransitively(t *testing.T) {
|
|||||||
name: "libbar.llndk",
|
name: "libbar.llndk",
|
||||||
symbol_file: "",
|
symbol_file: "",
|
||||||
}
|
}
|
||||||
`, func(fs map[string][]byte, config android.Config) {
|
`,
|
||||||
setUseVendorAllowListForTest(config, []string{"myapex"})
|
setUseVendorAllowListForTest([]string{"myapex"}),
|
||||||
}, withUnbundledBuild)
|
withUnbundledBuild,
|
||||||
|
)
|
||||||
|
|
||||||
// Ensure that LLNDK dep is not included
|
// Ensure that LLNDK dep is not included
|
||||||
ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
|
ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
|
||||||
@@ -1609,9 +1612,11 @@ func TestApexMinSdkVersion_SupportsCodeNames(t *testing.T) {
|
|||||||
versions: ["29", "R"],
|
versions: ["29", "R"],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
`, func(fs map[string][]byte, config android.Config) {
|
`,
|
||||||
config.TestProductVariables.Platform_version_active_codenames = []string{"R"}
|
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
||||||
})
|
variables.Platform_version_active_codenames = []string{"R"}
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
expectLink := func(from, from_variant, to, to_variant string) {
|
expectLink := func(from, from_variant, to, to_variant string) {
|
||||||
ldArgs := ctx.ModuleForTests(from, "android_arm64_armv8-a_"+from_variant).Rule("ld").Args["libFlags"]
|
ldArgs := ctx.ModuleForTests(from, "android_arm64_armv8-a_"+from_variant).Rule("ld").Args["libFlags"]
|
||||||
@@ -1720,6 +1725,12 @@ func TestPlatformUsesLatestStubsFromApexes(t *testing.T) {
|
|||||||
expectNoLink("libz", "shared", "libz", "shared")
|
expectNoLink("libz", "shared", "libz", "shared")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var prepareForTestWithSantitizeHwaddress = android.FixtureModifyProductVariables(
|
||||||
|
func(variables android.FixtureProductVariables) {
|
||||||
|
variables.SanitizeDevice = []string{"hwaddress"}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
func TestQApexesUseLatestStubsInBundledBuildsAndHWASAN(t *testing.T) {
|
func TestQApexesUseLatestStubsInBundledBuildsAndHWASAN(t *testing.T) {
|
||||||
ctx := testApex(t, `
|
ctx := testApex(t, `
|
||||||
apex {
|
apex {
|
||||||
@@ -1748,9 +1759,9 @@ func TestQApexesUseLatestStubsInBundledBuildsAndHWASAN(t *testing.T) {
|
|||||||
versions: ["29", "30"],
|
versions: ["29", "30"],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
`, func(fs map[string][]byte, config android.Config) {
|
`,
|
||||||
config.TestProductVariables.SanitizeDevice = []string{"hwaddress"}
|
prepareForTestWithSantitizeHwaddress,
|
||||||
})
|
)
|
||||||
expectLink := func(from, from_variant, to, to_variant string) {
|
expectLink := func(from, from_variant, to, to_variant string) {
|
||||||
ld := ctx.ModuleForTests(from, "android_arm64_armv8-a_"+from_variant).Rule("ld")
|
ld := ctx.ModuleForTests(from, "android_arm64_armv8-a_"+from_variant).Rule("ld")
|
||||||
libFlags := ld.Args["libFlags"]
|
libFlags := ld.Args["libFlags"]
|
||||||
@@ -2143,10 +2154,12 @@ func TestApexMinSdkVersion_OkayEvenWhenDepIsNewer_IfItSatisfiesApexMinSdkVersion
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestApexMinSdkVersion_WorksWithSdkCodename(t *testing.T) {
|
func TestApexMinSdkVersion_WorksWithSdkCodename(t *testing.T) {
|
||||||
withSAsActiveCodeNames := func(fs map[string][]byte, config android.Config) {
|
withSAsActiveCodeNames := android.FixtureModifyProductVariables(
|
||||||
config.TestProductVariables.Platform_sdk_codename = proptools.StringPtr("S")
|
func(variables android.FixtureProductVariables) {
|
||||||
config.TestProductVariables.Platform_version_active_codenames = []string{"S"}
|
variables.Platform_sdk_codename = proptools.StringPtr("S")
|
||||||
}
|
variables.Platform_version_active_codenames = []string{"S"}
|
||||||
|
},
|
||||||
|
)
|
||||||
testApexError(t, `libbar.*: should support min_sdk_version\(S\)`, `
|
testApexError(t, `libbar.*: should support min_sdk_version\(S\)`, `
|
||||||
apex {
|
apex {
|
||||||
name: "myapex",
|
name: "myapex",
|
||||||
@@ -2173,10 +2186,10 @@ func TestApexMinSdkVersion_WorksWithSdkCodename(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestApexMinSdkVersion_WorksWithActiveCodenames(t *testing.T) {
|
func TestApexMinSdkVersion_WorksWithActiveCodenames(t *testing.T) {
|
||||||
withSAsActiveCodeNames := func(fs map[string][]byte, config android.Config) {
|
withSAsActiveCodeNames := android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
||||||
config.TestProductVariables.Platform_sdk_codename = proptools.StringPtr("S")
|
variables.Platform_sdk_codename = proptools.StringPtr("S")
|
||||||
config.TestProductVariables.Platform_version_active_codenames = []string{"S", "T"}
|
variables.Platform_version_active_codenames = []string{"S", "T"}
|
||||||
}
|
})
|
||||||
ctx := testApex(t, `
|
ctx := testApex(t, `
|
||||||
apex {
|
apex {
|
||||||
name: "myapex",
|
name: "myapex",
|
||||||
@@ -2366,9 +2379,9 @@ func TestUseVendor(t *testing.T) {
|
|||||||
stl: "none",
|
stl: "none",
|
||||||
apex_available: [ "myapex" ],
|
apex_available: [ "myapex" ],
|
||||||
}
|
}
|
||||||
`, func(fs map[string][]byte, config android.Config) {
|
`,
|
||||||
setUseVendorAllowListForTest(config, []string{"myapex"})
|
setUseVendorAllowListForTest([]string{"myapex"}),
|
||||||
})
|
)
|
||||||
|
|
||||||
inputsList := []string{}
|
inputsList := []string{}
|
||||||
for _, i := range ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().BuildParamsForTests() {
|
for _, i := range ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().BuildParamsForTests() {
|
||||||
@@ -2399,9 +2412,9 @@ func TestUseVendorNotAllowedForSystemApexes(t *testing.T) {
|
|||||||
public_key: "testkey.avbpubkey",
|
public_key: "testkey.avbpubkey",
|
||||||
private_key: "testkey.pem",
|
private_key: "testkey.pem",
|
||||||
}
|
}
|
||||||
`, func(fs map[string][]byte, config android.Config) {
|
`,
|
||||||
setUseVendorAllowListForTest(config, []string{""})
|
setUseVendorAllowListForTest([]string{""}),
|
||||||
})
|
)
|
||||||
// no error with allow list
|
// no error with allow list
|
||||||
testApex(t, `
|
testApex(t, `
|
||||||
apex {
|
apex {
|
||||||
@@ -2415,9 +2428,9 @@ func TestUseVendorNotAllowedForSystemApexes(t *testing.T) {
|
|||||||
public_key: "testkey.avbpubkey",
|
public_key: "testkey.avbpubkey",
|
||||||
private_key: "testkey.pem",
|
private_key: "testkey.pem",
|
||||||
}
|
}
|
||||||
`, func(fs map[string][]byte, config android.Config) {
|
`,
|
||||||
setUseVendorAllowListForTest(config, []string{"myapex"})
|
setUseVendorAllowListForTest([]string{"myapex"}),
|
||||||
})
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUseVendorFailsIfNotVendorAvailable(t *testing.T) {
|
func TestUseVendorFailsIfNotVendorAvailable(t *testing.T) {
|
||||||
@@ -2569,9 +2582,10 @@ func TestProductVariant(t *testing.T) {
|
|||||||
apex_available: ["myapex"],
|
apex_available: ["myapex"],
|
||||||
srcs: ["foo.cpp"],
|
srcs: ["foo.cpp"],
|
||||||
}
|
}
|
||||||
`, func(fs map[string][]byte, config android.Config) {
|
`, android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
||||||
config.TestProductVariables.ProductVndkVersion = proptools.StringPtr("current")
|
variables.ProductVndkVersion = proptools.StringPtr("current")
|
||||||
})
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
cflags := strings.Fields(
|
cflags := strings.Fields(
|
||||||
ctx.ModuleForTests("foo", "android_product.VER_arm64_armv8-a_apex10000").Rule("cc").Args["cFlags"])
|
ctx.ModuleForTests("foo", "android_product.VER_arm64_armv8-a_apex10000").Rule("cc").Args["cFlags"])
|
||||||
@@ -2639,9 +2653,9 @@ func TestAndroidMk_UseVendorRequired(t *testing.T) {
|
|||||||
vendor_available: true,
|
vendor_available: true,
|
||||||
apex_available: ["myapex"],
|
apex_available: ["myapex"],
|
||||||
}
|
}
|
||||||
`, func(fs map[string][]byte, config android.Config) {
|
`,
|
||||||
setUseVendorAllowListForTest(config, []string{"myapex"})
|
setUseVendorAllowListForTest([]string{"myapex"}),
|
||||||
})
|
)
|
||||||
|
|
||||||
apexBundle := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
|
apexBundle := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
|
||||||
data := android.AndroidMkDataForTest(t, ctx, apexBundle)
|
data := android.AndroidMkDataForTest(t, ctx, apexBundle)
|
||||||
@@ -4935,9 +4949,11 @@ func TestInstallExtraFlattenedApexes(t *testing.T) {
|
|||||||
public_key: "testkey.avbpubkey",
|
public_key: "testkey.avbpubkey",
|
||||||
private_key: "testkey.pem",
|
private_key: "testkey.pem",
|
||||||
}
|
}
|
||||||
`, func(fs map[string][]byte, config android.Config) {
|
`,
|
||||||
config.TestProductVariables.InstallExtraFlattenedApexes = proptools.BoolPtr(true)
|
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
||||||
})
|
variables.InstallExtraFlattenedApexes = proptools.BoolPtr(true)
|
||||||
|
}),
|
||||||
|
)
|
||||||
ab := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
|
ab := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
|
||||||
ensureListContains(t, ab.requiredDeps, "myapex.flattened")
|
ensureListContains(t, ab.requiredDeps, "myapex.flattened")
|
||||||
mk := android.AndroidMkDataForTest(t, ctx, ab)
|
mk := android.AndroidMkDataForTest(t, ctx, ab)
|
||||||
@@ -6250,10 +6266,12 @@ func TestApexMutatorsDontRunIfDisabled(t *testing.T) {
|
|||||||
public_key: "testkey.avbpubkey",
|
public_key: "testkey.avbpubkey",
|
||||||
private_key: "testkey.pem",
|
private_key: "testkey.pem",
|
||||||
}
|
}
|
||||||
`, func(fs map[string][]byte, config android.Config) {
|
`,
|
||||||
delete(config.Targets, android.Android)
|
android.FixtureModifyConfig(func(config android.Config) {
|
||||||
config.AndroidCommonTarget = android.Target{}
|
delete(config.Targets, android.Android)
|
||||||
})
|
config.AndroidCommonTarget = android.Target{}
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
if expected, got := []string{""}, ctx.ModuleVariantsForTests("myapex"); !reflect.DeepEqual(expected, got) {
|
if expected, got := []string{""}, ctx.ModuleVariantsForTests("myapex"); !reflect.DeepEqual(expected, got) {
|
||||||
t.Errorf("Expected variants: %v, but got: %v", expected, got)
|
t.Errorf("Expected variants: %v, but got: %v", expected, got)
|
||||||
@@ -6325,7 +6343,7 @@ func TestAppSetBundle(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAppSetBundlePrebuilt(t *testing.T) {
|
func TestAppSetBundlePrebuilt(t *testing.T) {
|
||||||
ctx := testApex(t, "", func(fs map[string][]byte, config android.Config) {
|
ctx := testApex(t, "", android.FixtureModifyMockFS(func(fs android.MockFS) {
|
||||||
bp := `
|
bp := `
|
||||||
apex_set {
|
apex_set {
|
||||||
name: "myapex",
|
name: "myapex",
|
||||||
@@ -6336,9 +6354,9 @@ func TestAppSetBundlePrebuilt(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}`
|
}`
|
||||||
fs["Android.bp"] = []byte(bp)
|
fs["Android.bp"] = []byte(bp)
|
||||||
|
}),
|
||||||
config.TestProductVariables.SanitizeDevice = []string{"hwaddress"}
|
prepareForTestWithSantitizeHwaddress,
|
||||||
})
|
)
|
||||||
|
|
||||||
m := ctx.ModuleForTests("myapex", "android_common")
|
m := ctx.ModuleForTests("myapex", "android_common")
|
||||||
extractedApex := m.Output(buildDir + "/.intermediates/myapex/android_common/foo_v2.apex")
|
extractedApex := m.Output(buildDir + "/.intermediates/myapex/android_common/foo_v2.apex")
|
||||||
@@ -6903,13 +6921,17 @@ func TestApexSet(t *testing.T) {
|
|||||||
filename: "foo_v2.apex",
|
filename: "foo_v2.apex",
|
||||||
overrides: ["foo"],
|
overrides: ["foo"],
|
||||||
}
|
}
|
||||||
`, func(fs map[string][]byte, config android.Config) {
|
`,
|
||||||
config.TestProductVariables.Platform_sdk_version = intPtr(30)
|
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
||||||
config.Targets[android.Android] = []android.Target{
|
variables.Platform_sdk_version = intPtr(30)
|
||||||
{Os: android.Android, Arch: android.Arch{ArchType: android.Arm, ArchVariant: "armv7-a-neon", Abi: []string{"armeabi-v7a"}}},
|
}),
|
||||||
{Os: android.Android, Arch: android.Arch{ArchType: android.Arm64, ArchVariant: "armv8-a", Abi: []string{"arm64-v8a"}}},
|
android.FixtureModifyConfig(func(config android.Config) {
|
||||||
}
|
config.Targets[android.Android] = []android.Target{
|
||||||
})
|
{Os: android.Android, Arch: android.Arch{ArchType: android.Arm, ArchVariant: "armv7-a-neon", Abi: []string{"armeabi-v7a"}}},
|
||||||
|
{Os: android.Android, Arch: android.Arch{ArchType: android.Arm64, ArchVariant: "armv8-a", Abi: []string{"arm64-v8a"}}},
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
m := ctx.ModuleForTests("myapex", "android_common")
|
m := ctx.ModuleForTests("myapex", "android_common")
|
||||||
|
|
||||||
@@ -7117,9 +7139,11 @@ func TestCompressedApex(t *testing.T) {
|
|||||||
public_key: "testkey.avbpubkey",
|
public_key: "testkey.avbpubkey",
|
||||||
private_key: "testkey.pem",
|
private_key: "testkey.pem",
|
||||||
}
|
}
|
||||||
`, func(fs map[string][]byte, config android.Config) {
|
`,
|
||||||
config.TestProductVariables.CompressedApex = proptools.BoolPtr(true)
|
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
||||||
})
|
variables.CompressedApex = proptools.BoolPtr(true)
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
compressRule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("compressRule")
|
compressRule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("compressRule")
|
||||||
ensureContains(t, compressRule.Output.String(), "myapex.capex.unsigned")
|
ensureContains(t, compressRule.Output.String(), "myapex.capex.unsigned")
|
||||||
|
@@ -48,9 +48,11 @@ func TestVndkApexForVndkLite(t *testing.T) {
|
|||||||
stl: "none",
|
stl: "none",
|
||||||
apex_available: [ "com.android.vndk.current" ],
|
apex_available: [ "com.android.vndk.current" ],
|
||||||
}
|
}
|
||||||
`+vndkLibrariesTxtFiles("current"), func(fs map[string][]byte, config android.Config) {
|
`+vndkLibrariesTxtFiles("current"),
|
||||||
config.TestProductVariables.DeviceVndkVersion = proptools.StringPtr("")
|
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
||||||
})
|
variables.DeviceVndkVersion = proptools.StringPtr("")
|
||||||
|
}),
|
||||||
|
)
|
||||||
// VNDK-Lite contains only core variants of VNDK-Sp libraries
|
// VNDK-Lite contains only core variants of VNDK-Sp libraries
|
||||||
ensureExactContents(t, ctx, "com.android.vndk.current", "android_common_image", []string{
|
ensureExactContents(t, ctx, "com.android.vndk.current", "android_common_image", []string{
|
||||||
"lib/libvndksp.so",
|
"lib/libvndksp.so",
|
||||||
@@ -113,20 +115,24 @@ func TestVndkApexUsesVendorVariant(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("VNDK APEX gathers only vendor variants even if product variants are available", func(t *testing.T) {
|
t.Run("VNDK APEX gathers only vendor variants even if product variants are available", func(t *testing.T) {
|
||||||
ctx := testApex(t, bp, func(fs map[string][]byte, config android.Config) {
|
ctx := testApex(t, bp,
|
||||||
// Now product variant is available
|
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
||||||
config.TestProductVariables.ProductVndkVersion = proptools.StringPtr("current")
|
// Now product variant is available
|
||||||
})
|
variables.ProductVndkVersion = proptools.StringPtr("current")
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
files := getFiles(t, ctx, "com.android.vndk.current", "android_common_image")
|
files := getFiles(t, ctx, "com.android.vndk.current", "android_common_image")
|
||||||
ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.VER_arm_armv7-a-neon_shared/libfoo.so")
|
ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.VER_arm_armv7-a-neon_shared/libfoo.so")
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("VNDK APEX supports coverage variants", func(t *testing.T) {
|
t.Run("VNDK APEX supports coverage variants", func(t *testing.T) {
|
||||||
ctx := testApex(t, bp, func(fs map[string][]byte, config android.Config) {
|
ctx := testApex(t, bp,
|
||||||
config.TestProductVariables.GcovCoverage = proptools.BoolPtr(true)
|
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
||||||
config.TestProductVariables.Native_coverage = proptools.BoolPtr(true)
|
variables.GcovCoverage = proptools.BoolPtr(true)
|
||||||
})
|
variables.Native_coverage = proptools.BoolPtr(true)
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
files := getFiles(t, ctx, "com.android.vndk.current", "android_common_image")
|
files := getFiles(t, ctx, "com.android.vndk.current", "android_common_image")
|
||||||
ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.VER_arm_armv7-a-neon_shared/libfoo.so")
|
ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.VER_arm_armv7-a-neon_shared/libfoo.so")
|
||||||
|
Reference in New Issue
Block a user