Add test for interactions between product variables and arch variant properties
Add a test that verifies that arch variant product variable
properties are correctly squashed into the top level properties.
Bug: 322089980
Flag: EXEMPT test only
Test: TestProductVariablesArch
Change-Id: I62e9b4166761ce6ac0269e2fafc26d603e6b169e
diff --git a/android/variable_test.go b/android/variable_test.go
index 928bca6..73dc052 100644
--- a/android/variable_test.go
+++ b/android/variable_test.go
@@ -199,9 +199,7 @@
ctx.RegisterModuleType("module3", testProductVariableModuleFactoryFactory(&struct {
Foo []string
}{}))
- ctx.PreDepsMutators(func(ctx RegisterMutatorsContext) {
- ctx.BottomUp("variable", VariableMutator).Parallel()
- })
+ registerVariableBuildComponents(ctx)
}),
FixtureWithRootAndroidBp(bp),
).RunTest(t)
@@ -210,14 +208,14 @@
var testProductVariableDefaultsProperties = struct {
Product_variables struct {
Eng struct {
- Foo []string
+ Foo []string `android:"arch_variant"`
Bar []string
- }
- }
+ } `android:"arch_variant"`
+ } `android:"arch_variant"`
}{}
type productVariablesDefaultsTestProperties struct {
- Foo []string
+ Foo []string `android:"arch_variant"`
}
type productVariablesDefaultsTestProperties2 struct {
@@ -242,7 +240,7 @@
module := &productVariablesDefaultsTestModule{}
module.AddProperties(&module.properties)
module.variableProperties = testProductVariableDefaultsProperties
- InitAndroidModule(module)
+ InitAndroidArchModule(module, DeviceSupported, MultilibBoth)
InitDefaultableModule(module)
return module
}
@@ -324,3 +322,46 @@
})
}
}
+
+// Test a defaults module that supports more product variable properties than the target module.
+func TestProductVariablesArch(t *testing.T) {
+ bp := `
+ test {
+ name: "foo",
+ arch: {
+ arm: {
+ product_variables: {
+ eng: {
+ foo: ["arm"],
+ },
+ },
+ },
+ arm64: {
+ product_variables: {
+ eng: {
+ foo: ["arm64"],
+ },
+ },
+ },
+ },
+ foo: ["module"],
+ }
+ `
+
+ result := GroupFixturePreparers(
+ FixtureModifyProductVariables(func(variables FixtureProductVariables) {
+ variables.Eng = boolPtr(true)
+ }),
+ PrepareForTestWithArchMutator,
+ PrepareForTestWithVariables,
+ FixtureRegisterWithContext(func(ctx RegistrationContext) {
+ ctx.RegisterModuleType("test", productVariablesDefaultsTestModuleFactory)
+ }),
+ FixtureWithRootAndroidBp(bp),
+ ).RunTest(t)
+
+ foo := result.ModuleForTests("foo", "android_arm64_armv8-a").Module().(*productVariablesDefaultsTestModule)
+
+ want := []string{"module", "arm64"}
+ AssertDeepEquals(t, "foo", want, foo.properties.Foo)
+}