diff options
| author | 2019-01-29 22:17:02 +0000 | |
|---|---|---|
| committer | 2019-01-29 14:17:21 -0800 | |
| commit | b1d5567778a493ec8a0300b1f6834a9e66ec0103 (patch) | |
| tree | 7a5c722dfda665bf5e9e27f995e3a0b22087fae7 | |
| parent | 2c846cd99daf995bff2aafaf20080738e2da1c64 (diff) | |
Revert^2 "ART: Add list and tree modes to apex checker"
This reverts commit 482ee5384f163bd02090ddcf6b274ac377fe1beb.
Reason for revert: No longer a build component
Change-Id: I960704268e1ded1bcb1ee4b1429bb2badab1af48
Test: manual
| -rwxr-xr-x | build/apex/art_apex_test.py | 72 |
1 files changed, 70 insertions, 2 deletions
diff --git a/build/apex/art_apex_test.py b/build/apex/art_apex_test.py index 5ac2f724db..6ea1fcccbd 100755 --- a/build/apex/art_apex_test.py +++ b/build/apex/art_apex_test.py @@ -260,10 +260,66 @@ class DebugChecker(Checker): # Check that the mounted image contains additional required debug libraries. self.check_library('libadbconnectiond.so') +def print_list(provider): + def print_list_impl(provider, path): + map = provider.read_dir(path) + if map is None: + return + map = dict(map) + if '.' in map: + del map['.'] + if '..' in map: + del map['..'] + for (_, val) in sorted(map.items()): + new_path = os.path.join(path, val.name) + print(new_path) + if val.is_dir: + print_list_impl(provider, new_path) + print_list_impl(provider, '.') + +def print_tree(provider, title): + def get_vertical(has_next_list): + str = '' + for v in has_next_list: + str += '%s ' % ('│' if v else ' ') + return str + def get_last_vertical(last): + return '└── ' if last else '├── '; + def print_tree_impl(provider, path, has_next_list): + map = provider.read_dir(path) + if map is None: + return + map = dict(map) + if '.' in map: + del map['.'] + if '..' in map: + del map['..'] + key_list = list(sorted(map.keys())) + for i in range(0, len(key_list)): + val = map[key_list[i]] + prev = get_vertical(has_next_list) + last = get_last_vertical(i == len(key_list) - 1) + print('%s%s%s' % (prev, last, val.name)) + if val.is_dir: + has_next_list.append(i < len(key_list) - 1) + print_tree_impl(provider, os.path.join(path, val.name), has_next_list) + has_next_list.pop() + print('%s' % (title)) + print_tree_impl(provider, '.', []) + # Note: do not sys.exit early, for __del__ cleanup. def artApexTestMain(args): - if not args.host and not args.target and not args.debug: - logging.error("None of --host, --target nor --debug set") + if not args.host and not args.target and not args.debug and not args.tree and not args.list: + logging.error("None of --host, --target, --debug, --tree nor --list set") + return 1 + if args.tree and (args.host or args.debug): + logging.error("Both of --tree and --host|--debug set") + return 1 + if args.list and (args.host or args.debug): + logging.error("Both of --list and --host|--debug set") + return 1 + if args.list and args.tree: + logging.error("Both of --list and --tree set") return 1 if args.host and (args.target or args.debug): logging.error("Both of --host and --target|--debug set") @@ -283,6 +339,13 @@ def artApexTestMain(args): logging.error('Failed to create provider') return 1 + if args.tree: + print_tree(apex_provider, args.apex) + return 0 + if args.list: + print_list(apex_provider) + return 0 + checkers = [] if args.host: logging.error('host checking not yet supported') @@ -317,6 +380,8 @@ def artApexTestDefault(parser): args = parser.parse_args(['dummy']) # For consistency. args.debugfs = '%s/bin/debugfs' % (host_out) args.tmpdir = '.' + args.tree = False + args.list = False failed = False if not os.path.exists(args.debugfs): @@ -357,6 +422,9 @@ if __name__ == "__main__": parser.add_argument('--target', help='Check as target apex', action='store_true') parser.add_argument('--debug', help='Check as debug 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') + parser.add_argument('--tmpdir', help='Directory for temp files') parser.add_argument('--debugfs', help='Path to debugfs') |