Define vsr_min_shipping_api_level to cc_test

test_options in cc_test can have vsr_min_shipping_api_level to define
the minimum shipping api level that checks vendor api level in
addition to the device shipping api level. It can be used for the
tests that have dependency on the vendor api level.
vsr stands for the vendor software requirements.

Bug: 181284704
Test: manual test
Change-Id: I7f2cecd2818d35d86f7c08cb220e0c9db71fe0a8
This commit is contained in:
Justin Yun 2021-05-13 12:39:42 +09:00
parent 0589914135
commit a364cfb69d

View file

@ -48,12 +48,19 @@ type TestOptions struct {
Unit_test *bool Unit_test *bool
// Add ShippingApiLevelModuleController to auto generated test config. If the device properties // Add ShippingApiLevelModuleController to auto generated test config. If the device properties
// for the shipping api level is less than the test_min_api_level, skip this module. // for the shipping api level is less than the min_shipping_api_level, skip this module.
Test_min_api_level *int64 Min_shipping_api_level *int64
// Add ShippingApiLevelModuleController to auto generated test config. If any of the device
// shipping api level and vendor api level properties are less than the
// vsr_min_shipping_api_level, skip this module.
// As this includes the shipping api level check, it is not allowed to define
// min_shipping_api_level at the same time with this property.
Vsr_min_shipping_api_level *int64
// Add MinApiLevelModuleController with ro.vndk.version property. If ro.vndk.version has an // Add MinApiLevelModuleController with ro.vndk.version property. If ro.vndk.version has an
// integer value and the value is less than the test_min_vndk_version, skip this module. // integer value and the value is less than the min_vndk_version, skip this module.
Test_min_vndk_version *int64 Min_vndk_version *int64
} }
type TestBinaryProperties struct { type TestBinaryProperties struct {
@ -97,7 +104,7 @@ type TestBinaryProperties struct {
// Add ShippingApiLevelModuleController to auto generated test config. If the device properties // Add ShippingApiLevelModuleController to auto generated test config. If the device properties
// for the shipping api level is less than the test_min_api_level, skip this module. // for the shipping api level is less than the test_min_api_level, skip this module.
// Deprecated (b/187258404). Use test_options.test_min_api_level instead. // Deprecated (b/187258404). Use test_options.min_shipping_api_level instead.
Test_min_api_level *int64 Test_min_api_level *int64
// Flag to indicate whether or not to create test config automatically. If AndroidTest.xml // Flag to indicate whether or not to create test config automatically. If AndroidTest.xml
@ -404,19 +411,30 @@ func (test *testBinary) install(ctx ModuleContext, file android.Path) {
for _, tag := range test.Properties.Test_options.Test_suite_tag { for _, tag := range test.Properties.Test_options.Test_suite_tag {
configs = append(configs, tradefed.Option{Name: "test-suite-tag", Value: tag}) configs = append(configs, tradefed.Option{Name: "test-suite-tag", Value: tag})
} }
if test.Properties.Test_options.Test_min_api_level != nil { if test.Properties.Test_options.Min_shipping_api_level != nil {
if test.Properties.Test_options.Vsr_min_shipping_api_level != nil {
ctx.PropertyErrorf("test_options.min_shipping_api_level", "must not be set at the same time as 'vsr_min_shipping_api_level'.")
}
var options []tradefed.Option var options []tradefed.Option
options = append(options, tradefed.Option{Name: "min-api-level", Value: strconv.FormatInt(int64(*test.Properties.Test_options.Test_min_api_level), 10)}) options = append(options, tradefed.Option{Name: "min-api-level", Value: strconv.FormatInt(int64(*test.Properties.Test_options.Min_shipping_api_level), 10)})
configs = append(configs, tradefed.Object{"module_controller", "com.android.tradefed.testtype.suite.module.ShippingApiLevelModuleController", options}) configs = append(configs, tradefed.Object{"module_controller", "com.android.tradefed.testtype.suite.module.ShippingApiLevelModuleController", options})
} else if test.Properties.Test_min_api_level != nil { } else if test.Properties.Test_min_api_level != nil {
// TODO: (b/187258404) Remove test.Properties.Test_min_api_level // TODO: (b/187258404) Remove test.Properties.Test_min_api_level
if test.Properties.Test_options.Vsr_min_shipping_api_level != nil {
ctx.PropertyErrorf("test_min_api_level", "must not be set at the same time as 'vsr_min_shipping_api_level'.")
}
var options []tradefed.Option var options []tradefed.Option
options = append(options, tradefed.Option{Name: "min-api-level", Value: strconv.FormatInt(int64(*test.Properties.Test_min_api_level), 10)}) options = append(options, tradefed.Option{Name: "min-api-level", Value: strconv.FormatInt(int64(*test.Properties.Test_min_api_level), 10)})
configs = append(configs, tradefed.Object{"module_controller", "com.android.tradefed.testtype.suite.module.ShippingApiLevelModuleController", options}) configs = append(configs, tradefed.Object{"module_controller", "com.android.tradefed.testtype.suite.module.ShippingApiLevelModuleController", options})
} }
if test.Properties.Test_options.Test_min_vndk_version != nil { if test.Properties.Test_options.Vsr_min_shipping_api_level != nil {
var options []tradefed.Option var options []tradefed.Option
options = append(options, tradefed.Option{Name: "min-api-level", Value: strconv.FormatInt(int64(*test.Properties.Test_options.Test_min_vndk_version), 10)}) options = append(options, tradefed.Option{Name: "vsr-min-api-level", Value: strconv.FormatInt(int64(*test.Properties.Test_options.Vsr_min_shipping_api_level), 10)})
configs = append(configs, tradefed.Object{"module_controller", "com.android.tradefed.testtype.suite.module.ShippingApiLevelModuleController", options})
}
if test.Properties.Test_options.Min_vndk_version != nil {
var options []tradefed.Option
options = append(options, tradefed.Option{Name: "min-api-level", Value: strconv.FormatInt(int64(*test.Properties.Test_options.Min_vndk_version), 10)})
options = append(options, tradefed.Option{Name: "api-level-prop", Value: "ro.vndk.version"}) options = append(options, tradefed.Option{Name: "api-level-prop", Value: "ro.vndk.version"})
configs = append(configs, tradefed.Object{"module_controller", "com.android.tradefed.testtype.suite.module.MinApiLevelModuleController", options}) configs = append(configs, tradefed.Object{"module_controller", "com.android.tradefed.testtype.suite.module.MinApiLevelModuleController", options})
} }