summaryrefslogtreecommitdiff
path: root/scripts/test_config_fixer.py
diff options
context:
space:
mode:
author Seth Moore <sethmo@google.com> 2023-02-02 13:22:26 -0800
committer Seth Moore <sethmo@google.com> 2023-02-08 12:38:50 -0800
commitc6f4b532f3bd2a4d204fa059631907560e76ab5b (patch)
tree44cffe17f0846ca579a0071cdad1f345eb945d2f /scripts/test_config_fixer.py
parent800f64078ccc52ab1ced951376e44fb24e61fcaa (diff)
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
Diffstat (limited to 'scripts/test_config_fixer.py')
-rw-r--r--scripts/test_config_fixer.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/scripts/test_config_fixer.py b/scripts/test_config_fixer.py
index 3dbc22ec2..07e01a14a 100644
--- a/scripts/test_config_fixer.py
+++ b/scripts/test_config_fixer.py
@@ -31,6 +31,8 @@ from manifest import write_xml
KNOWN_PREPARERS = ['com.android.tradefed.targetprep.TestAppInstallSetup',
'com.android.tradefed.targetprep.suite.SuiteApkInstaller']
+MAINLINE_CONTROLLER = 'com.android.tradefed.testtype.suite.module.MainlineTestModuleController'
+
def parse_args():
"""Parse commandline arguments."""
@@ -41,6 +43,8 @@ def parse_args():
help=('overwrite package fields in the test config'))
parser.add_argument('--test-file-name', default='', dest='test_file_name',
help=('overwrite test file name in the test config'))
+ parser.add_argument('--mainline-package-name', default='', dest='mainline_package_name',
+ help=('overwrite mainline module package name in the test config'))
parser.add_argument('input', help='input test config file')
parser.add_argument('output', help='output test config file')
return parser.parse_args()
@@ -72,6 +76,16 @@ def overwrite_test_file_name(test_config_doc, test_file_name):
if option.getAttribute('name') == "test-file-name":
option.setAttribute('value', test_file_name)
+def overwrite_mainline_module_package_name(test_config_doc, mainline_package_name):
+
+ test_config = parse_test_config(test_config_doc)
+
+ for obj in get_children_with_tag(test_config, 'object'):
+ if obj.getAttribute('class') == MAINLINE_CONTROLLER:
+ for option in get_children_with_tag(obj, 'option'):
+ if option.getAttribute('name') == "mainline-module-package-name":
+ option.setAttribute('value', mainline_package_name)
+
def main():
"""Program entry point."""
try:
@@ -88,6 +102,9 @@ def main():
if args.test_file_name:
overwrite_test_file_name(doc, args.test_file_name)
+ if args.mainline_package_name:
+ overwrite_mainline_module_package_name(doc, args.mainline_package_name)
+
with open(args.output, 'w') as f:
write_xml(f, doc)