Allow android tests to specify a mainline package name
Tests that run against mainline modules generally need to be built twice: once for aosp (unsigned) and once for internal (signed). The override_android_test rule is really useful for generating a signed version of the unsigned test. However, mainline tests need to use a MainlineTestModuleController to only run tests on targets with the expected module. Since unsigned and signed mainline modules have different package names, this means the test config needs to be updated when overriding a test. Add a new "mainline_package_name" argument so that android test rules can update the targeted mainline package. Without this, the only way to create a mainline package test is to instead use android_test, which results in a lot of copy-pasta. Test: added tests to soong Test: manual, using a locally-modified RkpdAppUnitTest Test: test_config_fixer_test.py Change-Id: Idaffd63f225719a2bfda41018fda630b17db0080
This commit is contained in:
10
java/app.go
10
java/app.go
@@ -984,8 +984,11 @@ type appTestProperties struct {
|
||||
// The name of the android_app module that the tests will run against.
|
||||
Instrumentation_for *string
|
||||
|
||||
// if specified, the instrumentation target package name in the manifest is overwritten by it.
|
||||
// If specified, the instrumentation target package name in the manifest is overwritten by it.
|
||||
Instrumentation_target_package *string
|
||||
|
||||
// If specified, the mainline module package name in the test config is overwritten by it.
|
||||
Mainline_package_name *string
|
||||
}
|
||||
|
||||
type AndroidTest struct {
|
||||
@@ -1063,6 +1066,11 @@ func (a *AndroidTest) FixTestConfig(ctx android.ModuleContext, testConfig androi
|
||||
FlagWithArg("--package-name ", *a.overridableAppProperties.Package_name)
|
||||
}
|
||||
|
||||
if a.appTestProperties.Mainline_package_name != nil {
|
||||
fixNeeded = true
|
||||
command.FlagWithArg("--mainline-package-name ", *a.appTestProperties.Mainline_package_name)
|
||||
}
|
||||
|
||||
if fixNeeded {
|
||||
rule.Build("fix_test_config", "fix test config")
|
||||
return fixedConfig
|
||||
|
Reference in New Issue
Block a user