diff options
| author | 2019-09-09 16:29:12 +0100 | |
|---|---|---|
| committer | 2019-09-23 09:43:06 +0000 | |
| commit | d7ea0437a8dd11253b55651fcfab23b65d504ee2 (patch) | |
| tree | ce73f4c05123ae8f1b99900a489b284ed1bc2dc1 /build/apex/art_apex_test.py | |
| parent | 4ba700af65f8346a96ba8d1dec051358a09487f4 (diff) | |
Generalize ART APEX flavor handling in `art_apex_test.py`.
Introduce flag `--flavor` in `build/apex/art_apex_test.py` to select
the flavor of the ART APEX to check (`release`, `debug`, `testing`,
`auto`). Default to `auto`, which auto-detects the flavor based on the
name of the APEX passed as argument to the script.
Update `build/apex/runtests.sh` and `build/apex/Android.bp` to use
these new options instead of `--debug` and `--testing`.
Test: art/build/apex/runtests.sh
Bug: 139277987
Change-Id: I463ae6504576f77ee70b3ac4111bd43c49e450d0
Diffstat (limited to 'build/apex/art_apex_test.py')
| -rwxr-xr-x | build/apex/art_apex_test.py | 66 |
1 files changed, 53 insertions, 13 deletions
diff --git a/build/apex/art_apex_test.py b/build/apex/art_apex_test.py index 2b424044f2..6d29fc9769 100755 --- a/build/apex/art_apex_test.py +++ b/build/apex/art_apex_test.py @@ -1047,9 +1047,21 @@ def art_apex_test_main(test_args): if test_args.size and not (test_args.list or test_args.tree): logging.error("--size set but neither --list nor --tree set") return 1 + if test_args.host and test_args.flavor: + logging.error("Both of --host and --flavor set") + return 1 if test_args.host and test_args.testing: logging.error("Both of --host and --testing set") return 1 + if test_args.debug and test_args.testing: + logging.error("Both of --debug and --testing set") + return 1 + if test_args.flavor and test_args.debug: + logging.error("Both of --flavor and --debug set") + return 1 + if test_args.flavor and test_args.testing: + logging.error("Both of --flavor and --testing set") + return 1 if not test_args.flattened and not test_args.tmpdir: logging.error("Need a tmpdir.") return 1 @@ -1078,6 +1090,30 @@ def art_apex_test_main(test_args): List(apex_provider, test_args.size).print_list() return 0 + # Handle legacy flavor flags. + if test_args.debug: + logging.warning('Using deprecated option --debug') + test_args.flavor='debug' + if test_args.testing: + logging.warning('Using deprecated option --testing') + test_args.flavor='testing' + if test_args.flavor == 'auto': + logging.warning('--flavor=auto, trying to autodetect. This may be incorrect!') + if fnmatch.fnmatch(test_args.apex, '*.release*'): + logging.warning(' Detected Release APEX') + test_args.flavor='release' + elif fnmatch.fnmatch(test_args.apex, '*.debug*'): + logging.warning(' Detected Debug APEX') + test_args.flavor='debug' + elif fnmatch.fnmatch(test_args.apex, '*.testing*'): + logging.warning(' Detected Testing APEX') + test_args.flavor='testing' + else: + logging.error(' Could not detect APEX flavor, neither \'release\', \'debug\' nor ' + + '\'testing\' in \'%s\'', + test_args.apex) + return 1 + checkers = [] if test_args.bitness == 'auto': logging.warning('--bitness=auto, trying to autodetect. This may be incorrect!') @@ -1110,11 +1146,11 @@ def art_apex_test_main(test_args): checkers.append(ReleaseHostChecker(base_checker)) else: checkers.append(ReleaseTargetChecker(base_checker)) - if test_args.debug or test_args.testing: + if test_args.flavor == 'debug' or test_args.flavor == 'testing': checkers.append(DebugChecker(base_checker)) if not test_args.host: checkers.append(DebugTargetChecker(base_checker)) - if test_args.testing: + if test_args.flavor == 'testing': checkers.append(TestingTargetChecker(base_checker)) # These checkers must be last. @@ -1162,11 +1198,12 @@ def art_apex_test_default(test_parser): test_args.debugfs) sys.exit(1) - # TODO: Add host support + # TODO: Add host support. + # TODO: Add support for flattened APEX packages. configs = [ - {'name': 'com.android.art.release', 'debug': False, 'testing': False, 'host': False}, - {'name': 'com.android.art.debug', 'debug': True, 'testing': False, 'host': False}, - {'name': 'com.android.art.testing', 'debug': False, 'testing': True, 'host': False}, + {'name': 'com.android.art.release', 'flavor': 'release', 'host': False}, + {'name': 'com.android.art.debug', 'flavor': 'debug', 'host': False}, + {'name': 'com.android.art.testing', 'flavor': 'testing', 'host': False}, ] for config in configs: @@ -1177,8 +1214,7 @@ def art_apex_test_default(test_parser): failed = True logging.error("Cannot find APEX %s. Please build it first.", test_args.apex) continue - test_args.debug = config['debug'] - test_args.testing = config['testing'] + test_args.flavor = config['flavor'] test_args.host = config['host'] failed = art_apex_test_main(test_args) != 0 @@ -1189,14 +1225,18 @@ def art_apex_test_default(test_parser): if __name__ == "__main__": parser = argparse.ArgumentParser(description='Check integrity of a Runtime APEX.') - parser.add_argument('apex', help='apex file input') + parser.add_argument('apex', help='APEX file input') - parser.add_argument('--host', help='Check as host apex', action='store_true') + parser.add_argument('--host', help='Check as host APEX', action='store_true') - parser.add_argument('--flattened', help='Check as flattened (target) apex', action='store_true') + parser.add_argument('--flattened', help='Check as flattened (target) APEX', action='store_true') - parser.add_argument('--debug', help='Check as debug apex', action='store_true') - parser.add_argument('--testing', help='Check as testing apex', action='store_true') + parser.add_argument('--flavor', help='Check as FLAVOR APEX, release|debug|testing|auto', + default='auto') + # Deprecated flavor flags. + # TODO: Stop supporting those flags eventually. + parser.add_argument('--debug', help='Check as debug APEX', action='store_true') + parser.add_argument('--testing', help='Check as testing APEX', action='store_true') parser.add_argument('--list', help='List all files', action='store_true') parser.add_argument('--tree', help='Print directory tree', action='store_true') |