Roland Levillain | 29e740f | 2019-08-20 15:31:37 +0100 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # -*- coding: utf-8 -*- |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 3 | |
| 4 | # Copyright (C) 2019 The Android Open Source Project |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | # you may not use this file except in compliance with the License. |
| 8 | # You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | # |
| 18 | |
| 19 | import argparse |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 20 | import fnmatch |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 21 | import logging |
| 22 | import os |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 23 | import os.path |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 24 | import subprocess |
| 25 | import sys |
| 26 | import zipfile |
| 27 | |
| 28 | logging.basicConfig(format='%(message)s') |
| 29 | |
Roland Levillain | 61f0716 | 2019-06-26 12:44:04 +0100 | [diff] [blame] | 30 | # Architectures supported by APEX packages. |
| 31 | archs = ["arm", "arm64", "x86", "x86_64"] |
| 32 | # Directory containing ART tests within a Runtime APEX (if the package includes |
| 33 | # any). ART test executables are installed in `bin/art/<arch>`. Segregating |
| 34 | # tests by architecture is useful on devices supporting more than one |
| 35 | # architecture, as it permits testing all of them using a single Runtime APEX |
| 36 | # package. |
Roland Levillain | d4d6fb5 | 2019-08-05 12:28:39 +0100 | [diff] [blame] | 37 | art_test_dir = 'bin/art' |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 38 | |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 39 | class FSObject: |
Roland Levillain | 88e5569 | 2019-07-25 15:57:06 +0100 | [diff] [blame] | 40 | def __init__(self, name, is_dir, is_exec, is_symlink, size): |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 41 | self.name = name |
| 42 | self.is_dir = is_dir |
| 43 | self.is_exec = is_exec |
| 44 | self.is_symlink = is_symlink |
Roland Levillain | 88e5569 | 2019-07-25 15:57:06 +0100 | [diff] [blame] | 45 | self.size = size |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 46 | |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 47 | def __str__(self): |
Roland Levillain | 88e5569 | 2019-07-25 15:57:06 +0100 | [diff] [blame] | 48 | return '%s(dir=%r,exec=%r,symlink=%r,size=%d)' \ |
| 49 | % (self.name, self.is_dir, self.is_exec, self.is_symlink, self.size) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 50 | |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 51 | |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 52 | class TargetApexProvider: |
| 53 | def __init__(self, apex, tmpdir, debugfs): |
| 54 | self._tmpdir = tmpdir |
| 55 | self._debugfs = debugfs |
| 56 | self._folder_cache = {} |
| 57 | self._payload = os.path.join(self._tmpdir, 'apex_payload.img') |
| 58 | # Extract payload to tmpdir. |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 59 | apex_zip = zipfile.ZipFile(apex) |
| 60 | apex_zip.extract('apex_payload.img', tmpdir) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 61 | |
| 62 | def __del__(self): |
| 63 | # Delete temps. |
| 64 | if os.path.exists(self._payload): |
| 65 | os.remove(self._payload) |
| 66 | |
| 67 | def get(self, path): |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 68 | apex_dir, name = os.path.split(path) |
| 69 | if not apex_dir: |
| 70 | apex_dir = '.' |
| 71 | apex_map = self.read_dir(apex_dir) |
| 72 | return apex_map[name] if name in apex_map else None |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 73 | |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 74 | def read_dir(self, apex_dir): |
| 75 | if apex_dir in self._folder_cache: |
| 76 | return self._folder_cache[apex_dir] |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 77 | # Cannot use check_output as it will annoy with stderr. |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 78 | process = subprocess.Popen([self._debugfs, '-R', 'ls -l -p %s' % apex_dir, self._payload], |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 79 | stdout=subprocess.PIPE, stderr=subprocess.PIPE, |
| 80 | universal_newlines=True) |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 81 | stdout, _ = process.communicate() |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 82 | res = str(stdout) |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 83 | apex_map = {} |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 84 | # Debugfs output looks like this: |
| 85 | # debugfs 1.44.4 (18-Aug-2018) |
| 86 | # /12/040755/0/2000/.// |
| 87 | # /2/040755/1000/1000/..// |
| 88 | # /13/100755/0/2000/dalvikvm32/28456/ |
| 89 | # /14/100755/0/2000/dexoptanalyzer/20396/ |
| 90 | # /15/100755/0/2000/linker/1152724/ |
| 91 | # /16/100755/0/2000/dex2oat/563508/ |
| 92 | # /17/100755/0/2000/linker64/1605424/ |
| 93 | # /18/100755/0/2000/profman/85304/ |
| 94 | # /19/100755/0/2000/dalvikvm64/28576/ |
| 95 | # | | | | | | |
| 96 | # | | | #- gid #- name #- size |
| 97 | # | | #- uid |
| 98 | # | #- type and permission bits |
| 99 | # #- inode nr (?) |
| 100 | # |
| 101 | # Note: could break just on '/' to avoid names with newlines. |
| 102 | for line in res.split("\n"): |
| 103 | if not line: |
| 104 | continue |
| 105 | comps = line.split('/') |
| 106 | if len(comps) != 8: |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 107 | logging.warning('Could not break and parse line \'%s\'', line) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 108 | continue |
| 109 | bits = comps[2] |
| 110 | name = comps[5] |
Roland Levillain | 88e5569 | 2019-07-25 15:57:06 +0100 | [diff] [blame] | 111 | size_str = comps[6] |
| 112 | # Use a negative value as an indicator of undefined/unknown size. |
| 113 | size = int(size_str) if size_str != '' else -1 |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 114 | if len(bits) != 6: |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 115 | logging.warning('Dont understand bits \'%s\'', bits) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 116 | continue |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 117 | is_dir = bits[1] == '4' |
| 118 | |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 119 | def is_exec_bit(ch): |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 120 | return int(ch) & 1 == 1 |
| 121 | |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 122 | is_exec = is_exec_bit(bits[3]) and is_exec_bit(bits[4]) and is_exec_bit(bits[5]) |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 123 | is_symlink = bits[1] == '2' |
Roland Levillain | 88e5569 | 2019-07-25 15:57:06 +0100 | [diff] [blame] | 124 | apex_map[name] = FSObject(name, is_dir, is_exec, is_symlink, size) |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 125 | self._folder_cache[apex_dir] = apex_map |
| 126 | return apex_map |
| 127 | |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 128 | |
Roland Levillain | dd20d00 | 2019-07-19 16:09:47 +0100 | [diff] [blame] | 129 | class TargetFlattenedApexProvider: |
| 130 | def __init__(self, apex): |
| 131 | self._folder_cache = {} |
| 132 | self._apex = apex |
| 133 | |
| 134 | def get(self, path): |
| 135 | apex_dir, name = os.path.split(path) |
| 136 | if not apex_dir: |
| 137 | apex_dir = '.' |
| 138 | apex_map = self.read_dir(apex_dir) |
| 139 | return apex_map[name] if name in apex_map else None |
| 140 | |
| 141 | def read_dir(self, apex_dir): |
| 142 | if apex_dir in self._folder_cache: |
| 143 | return self._folder_cache[apex_dir] |
| 144 | apex_map = {} |
| 145 | dirname = os.path.join(self._apex, apex_dir) |
| 146 | if os.path.exists(dirname): |
| 147 | for basename in os.listdir(dirname): |
| 148 | filepath = os.path.join(dirname, basename) |
| 149 | is_dir = os.path.isdir(filepath) |
| 150 | is_exec = os.access(filepath, os.X_OK) |
| 151 | is_symlink = os.path.islink(filepath) |
Roland Levillain | 88e5569 | 2019-07-25 15:57:06 +0100 | [diff] [blame] | 152 | size = os.path.getsize(filepath) |
| 153 | apex_map[basename] = FSObject(basename, is_dir, is_exec, is_symlink, size) |
Roland Levillain | dd20d00 | 2019-07-19 16:09:47 +0100 | [diff] [blame] | 154 | self._folder_cache[apex_dir] = apex_map |
| 155 | return apex_map |
| 156 | |
| 157 | |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 158 | class HostApexProvider: |
| 159 | def __init__(self, apex, tmpdir): |
| 160 | self._tmpdir = tmpdir |
Roland Levillain | 77251f9 | 2019-08-09 15:00:04 +0100 | [diff] [blame] | 161 | self._folder_cache = {} |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 162 | self._payload = os.path.join(self._tmpdir, 'apex_payload.zip') |
| 163 | # Extract payload to tmpdir. |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 164 | apex_zip = zipfile.ZipFile(apex) |
| 165 | apex_zip.extract('apex_payload.zip', tmpdir) |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 166 | |
| 167 | def __del__(self): |
| 168 | # Delete temps. |
| 169 | if os.path.exists(self._payload): |
| 170 | os.remove(self._payload) |
| 171 | |
| 172 | def get(self, path): |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 173 | apex_dir, name = os.path.split(path) |
| 174 | if not apex_dir: |
| 175 | apex_dir = '' |
| 176 | apex_map = self.read_dir(apex_dir) |
| 177 | return apex_map[name] if name in apex_map else None |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 178 | |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 179 | def read_dir(self, apex_dir): |
Roland Levillain | 77251f9 | 2019-08-09 15:00:04 +0100 | [diff] [blame] | 180 | if apex_dir in self._folder_cache: |
| 181 | return self._folder_cache[apex_dir] |
| 182 | if not self._folder_cache: |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 183 | self.parse_zip() |
Roland Levillain | 77251f9 | 2019-08-09 15:00:04 +0100 | [diff] [blame] | 184 | if apex_dir in self._folder_cache: |
| 185 | return self._folder_cache[apex_dir] |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 186 | return {} |
| 187 | |
| 188 | def parse_zip(self): |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 189 | apex_zip = zipfile.ZipFile(self._payload) |
| 190 | infos = apex_zip.infolist() |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 191 | for zipinfo in infos: |
| 192 | path = zipinfo.filename |
| 193 | |
| 194 | # Assume no empty file is stored. |
| 195 | assert path |
| 196 | |
| 197 | def get_octal(val, index): |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 198 | return (val >> (index * 3)) & 0x7 |
| 199 | |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 200 | def bits_is_exec(val): |
| 201 | # TODO: Enforce group/other, too? |
| 202 | return get_octal(val, 2) & 1 == 1 |
| 203 | |
| 204 | is_zipinfo = True |
| 205 | while path: |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 206 | apex_dir, base = os.path.split(path) |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 207 | # TODO: If directories are stored, base will be empty. |
| 208 | |
Roland Levillain | 77251f9 | 2019-08-09 15:00:04 +0100 | [diff] [blame] | 209 | if apex_dir not in self._folder_cache: |
| 210 | self._folder_cache[apex_dir] = {} |
| 211 | dir_map = self._folder_cache[apex_dir] |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 212 | if base not in dir_map: |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 213 | if is_zipinfo: |
| 214 | bits = (zipinfo.external_attr >> 16) & 0xFFFF |
| 215 | is_dir = get_octal(bits, 4) == 4 |
| 216 | is_symlink = get_octal(bits, 4) == 2 |
| 217 | is_exec = bits_is_exec(bits) |
Roland Levillain | 88e5569 | 2019-07-25 15:57:06 +0100 | [diff] [blame] | 218 | size = zipinfo.file_size |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 219 | else: |
| 220 | is_exec = False # Seems we can't get this easily? |
| 221 | is_symlink = False |
| 222 | is_dir = True |
Roland Levillain | 88e5569 | 2019-07-25 15:57:06 +0100 | [diff] [blame] | 223 | # Use a negative value as an indicator of undefined/unknown size. |
| 224 | size = -1 |
| 225 | dir_map[base] = FSObject(base, is_dir, is_exec, is_symlink, size) |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 226 | is_zipinfo = False |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 227 | path = apex_dir |
| 228 | |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 229 | |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 230 | # DO NOT USE DIRECTLY! This is an "abstract" base class. |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 231 | class Checker: |
| 232 | def __init__(self, provider): |
| 233 | self._provider = provider |
| 234 | self._errors = 0 |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 235 | self._expected_file_globs = set() |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 236 | |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 237 | def fail(self, msg, *fail_args): |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 238 | self._errors += 1 |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 239 | logging.error(msg, *fail_args) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 240 | |
| 241 | def error_count(self): |
| 242 | return self._errors |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 243 | |
Andreas Gampe | 9dc4b05 | 2019-01-30 13:47:25 -0800 | [diff] [blame] | 244 | def reset_errors(self): |
| 245 | self._errors = 0 |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 246 | |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 247 | def is_file(self, path): |
| 248 | fs_object = self._provider.get(path) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 249 | if fs_object is None: |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 250 | return False, 'Could not find %s' |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 251 | if fs_object.is_dir: |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 252 | return False, '%s is a directory' |
| 253 | return True, '' |
Andreas Gampe | a0242cf | 2019-01-29 13:01:23 -0800 | [diff] [blame] | 254 | |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 255 | def check_file(self, path): |
| 256 | ok, msg = self.is_file(path) |
| 257 | if not ok: |
| 258 | self.fail(msg, path) |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 259 | self._expected_file_globs.add(path) |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 260 | return ok |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 261 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 262 | def check_executable(self, filename): |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 263 | path = 'bin/%s' % filename |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 264 | if not self.check_file(path): |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 265 | return |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 266 | if not self._provider.get(path).is_exec: |
| 267 | self.fail('%s is not executable', path) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 268 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 269 | def check_executable_symlink(self, filename): |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 270 | path = 'bin/%s' % filename |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 271 | fs_object = self._provider.get(path) |
| 272 | if fs_object is None: |
| 273 | self.fail('Could not find %s', path) |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 274 | return |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 275 | if fs_object.is_dir: |
| 276 | self.fail('%s is a directory', path) |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 277 | return |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 278 | if not fs_object.is_symlink: |
| 279 | self.fail('%s is not a symlink', path) |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 280 | self._expected_file_globs.add(path) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 281 | |
Roland Levillain | 61f0716 | 2019-06-26 12:44:04 +0100 | [diff] [blame] | 282 | def check_art_test_executable(self, filename): |
| 283 | # This is a simplistic implementation, as we declare victory as soon as the |
| 284 | # test binary is found for one of the supported (not built) architectures. |
| 285 | # Ideally we would propagate the built architectures from the build system |
| 286 | # to this script and require test binaries for all of them to be present. |
| 287 | # Note that this behavior is not specific to this method: there are other |
| 288 | # places in this script where we rely on this simplified strategy. |
| 289 | # |
| 290 | # TODO: Implement the suggestion above (here and in other places in this |
| 291 | # script). |
| 292 | test_found = False |
| 293 | for arch in archs: |
| 294 | test_path = '%s/%s/%s' % (art_test_dir, arch, filename) |
| 295 | test_is_file, _ = self.is_file(test_path) |
| 296 | if test_is_file: |
| 297 | test_found = True |
| 298 | self._expected_file_globs.add(test_path) |
| 299 | if not self._provider.get(test_path).is_exec: |
| 300 | self.fail('%s is not executable', test_path) |
| 301 | if not test_found: |
| 302 | self.fail('ART test binary missing: %s', filename) |
| 303 | |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 304 | def check_single_library(self, filename): |
| 305 | lib_path = 'lib/%s' % filename |
| 306 | lib64_path = 'lib64/%s' % filename |
| 307 | lib_is_file, _ = self.is_file(lib_path) |
| 308 | if lib_is_file: |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 309 | self._expected_file_globs.add(lib_path) |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 310 | lib64_is_file, _ = self.is_file(lib64_path) |
| 311 | if lib64_is_file: |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 312 | self._expected_file_globs.add(lib64_path) |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 313 | if not lib_is_file and not lib64_is_file: |
| 314 | self.fail('Library missing: %s', filename) |
Andreas Gampe | a0242cf | 2019-01-29 13:01:23 -0800 | [diff] [blame] | 315 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 316 | def check_java_library(self, basename): |
| 317 | return self.check_file('javalib/%s.jar' % basename) |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 318 | |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 319 | def ignore_path(self, path_glob): |
| 320 | self._expected_file_globs.add(path_glob) |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 321 | |
Roland Levillain | 61f0716 | 2019-06-26 12:44:04 +0100 | [diff] [blame] | 322 | def check_optional_art_test_executable(self, filename): |
| 323 | for arch in archs: |
| 324 | self.ignore_path('%s/%s/%s' % (art_test_dir, arch, filename)) |
| 325 | |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 326 | def check_no_superfluous_files(self, dir_path): |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 327 | paths = [] |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 328 | for name in sorted(self._provider.read_dir(dir_path).keys()): |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 329 | if name not in ('.', '..'): |
| 330 | paths.append(os.path.join(dir_path, name)) |
| 331 | expected_paths = set() |
| 332 | dir_prefix = dir_path + '/' |
| 333 | for path_glob in self._expected_file_globs: |
| 334 | expected_paths |= set(fnmatch.filter(paths, path_glob)) |
| 335 | # If there are globs in subdirectories of dir_path we want to match their |
| 336 | # path segments at this directory level. |
| 337 | if path_glob.startswith(dir_prefix): |
| 338 | subpath = path_glob[len(dir_prefix):] |
| 339 | subpath_first_segment, _, _ = subpath.partition('/') |
| 340 | expected_paths |= set(fnmatch.filter(paths, dir_prefix + subpath_first_segment)) |
| 341 | for unexpected_path in set(paths) - expected_paths: |
| 342 | self.fail('Unexpected file \'%s\'', unexpected_path) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 343 | |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 344 | # Just here for docs purposes, even if it isn't good Python style. |
| 345 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 346 | def check_symlinked_multilib_executable(self, filename): |
| 347 | """Check bin/filename32, and/or bin/filename64, with symlink bin/filename.""" |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 348 | raise NotImplementedError |
| 349 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 350 | def check_multilib_executable(self, filename): |
| 351 | """Check bin/filename for 32 bit, and/or bin/filename64.""" |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 352 | raise NotImplementedError |
| 353 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 354 | def check_native_library(self, basename): |
| 355 | """Check lib/basename.so, and/or lib64/basename.so.""" |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 356 | raise NotImplementedError |
| 357 | |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 358 | def check_optional_native_library(self, basename_glob): |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 359 | """Allow lib/basename.so and/or lib64/basename.so to exist.""" |
Martin Stjernholm | b81fe23 | 2019-03-25 17:38:04 +0000 | [diff] [blame] | 360 | raise NotImplementedError |
| 361 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 362 | def check_prefer64_library(self, basename): |
| 363 | """Check lib64/basename.so, or lib/basename.so on 32 bit only.""" |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 364 | raise NotImplementedError |
| 365 | |
| 366 | |
| 367 | class Arch32Checker(Checker): |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 368 | def check_symlinked_multilib_executable(self, filename): |
| 369 | self.check_executable('%s32' % filename) |
| 370 | self.check_executable_symlink(filename) |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 371 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 372 | def check_multilib_executable(self, filename): |
| 373 | self.check_executable(filename) |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 374 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 375 | def check_native_library(self, basename): |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 376 | # TODO: Use $TARGET_ARCH (e.g. check whether it is "arm" or "arm64") to improve |
| 377 | # the precision of this test? |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 378 | self.check_file('lib/%s.so' % basename) |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 379 | |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 380 | def check_optional_native_library(self, basename_glob): |
| 381 | self.ignore_path('lib/%s.so' % basename_glob) |
Martin Stjernholm | b81fe23 | 2019-03-25 17:38:04 +0000 | [diff] [blame] | 382 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 383 | def check_prefer64_library(self, basename): |
| 384 | self.check_native_library(basename) |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 385 | |
| 386 | |
| 387 | class Arch64Checker(Checker): |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 388 | def check_symlinked_multilib_executable(self, filename): |
| 389 | self.check_executable('%s64' % filename) |
| 390 | self.check_executable_symlink(filename) |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 391 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 392 | def check_multilib_executable(self, filename): |
| 393 | self.check_executable('%s64' % filename) |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 394 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 395 | def check_native_library(self, basename): |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 396 | # TODO: Use $TARGET_ARCH (e.g. check whether it is "arm" or "arm64") to improve |
| 397 | # the precision of this test? |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 398 | self.check_file('lib64/%s.so' % basename) |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 399 | |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 400 | def check_optional_native_library(self, basename_glob): |
| 401 | self.ignore_path('lib64/%s.so' % basename_glob) |
Martin Stjernholm | b81fe23 | 2019-03-25 17:38:04 +0000 | [diff] [blame] | 402 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 403 | def check_prefer64_library(self, basename): |
| 404 | self.check_native_library(basename) |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 405 | |
| 406 | |
| 407 | class MultilibChecker(Checker): |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 408 | def check_symlinked_multilib_executable(self, filename): |
| 409 | self.check_executable('%s32' % filename) |
| 410 | self.check_executable('%s64' % filename) |
| 411 | self.check_executable_symlink(filename) |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 412 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 413 | def check_multilib_executable(self, filename): |
| 414 | self.check_executable('%s64' % filename) |
| 415 | self.check_executable(filename) |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 416 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 417 | def check_native_library(self, basename): |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 418 | # TODO: Use $TARGET_ARCH (e.g. check whether it is "arm" or "arm64") to improve |
| 419 | # the precision of this test? |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 420 | self.check_file('lib/%s.so' % basename) |
| 421 | self.check_file('lib64/%s.so' % basename) |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 422 | |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 423 | def check_optional_native_library(self, basename_glob): |
| 424 | self.ignore_path('lib/%s.so' % basename_glob) |
| 425 | self.ignore_path('lib64/%s.so' % basename_glob) |
Martin Stjernholm | b81fe23 | 2019-03-25 17:38:04 +0000 | [diff] [blame] | 426 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 427 | def check_prefer64_library(self, basename): |
| 428 | self.check_file('lib64/%s.so' % basename) |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 429 | |
| 430 | |
Andreas Gampe | 9dc4b05 | 2019-01-30 13:47:25 -0800 | [diff] [blame] | 431 | class ReleaseChecker: |
| 432 | def __init__(self, checker): |
| 433 | self._checker = checker |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 434 | |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 435 | def __str__(self): |
| 436 | return 'Release Checker' |
| 437 | |
| 438 | def run(self): |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 439 | # Check the APEX manifest. |
Andreas Gampe | 9dc4b05 | 2019-01-30 13:47:25 -0800 | [diff] [blame] | 440 | self._checker.check_file('apex_manifest.json') |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 441 | |
Martin Stjernholm | 77f1766 | 2019-04-03 17:08:21 +0100 | [diff] [blame] | 442 | # Check binaries for ART. |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 443 | self._checker.check_executable('dex2oat') |
Martin Stjernholm | 77f1766 | 2019-04-03 17:08:21 +0100 | [diff] [blame] | 444 | self._checker.check_executable('dexdump') |
| 445 | self._checker.check_executable('dexlist') |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 446 | self._checker.check_executable('dexoptanalyzer') |
| 447 | self._checker.check_executable('profman') |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 448 | self._checker.check_symlinked_multilib_executable('dalvikvm') |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 449 | |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 450 | # Check exported libraries for ART. |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 451 | self._checker.check_native_library('libdexfile_external') |
| 452 | self._checker.check_native_library('libnativebridge') |
| 453 | self._checker.check_native_library('libnativehelper') |
| 454 | self._checker.check_native_library('libnativeloader') |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 455 | |
| 456 | # Check internal libraries for ART. |
| 457 | self._checker.check_native_library('libadbconnection') |
| 458 | self._checker.check_native_library('libart') |
| 459 | self._checker.check_native_library('libart-compiler') |
| 460 | self._checker.check_native_library('libart-dexlayout') |
| 461 | self._checker.check_native_library('libartbase') |
| 462 | self._checker.check_native_library('libartpalette') |
| 463 | self._checker.check_native_library('libdexfile') |
| 464 | self._checker.check_native_library('libdexfile_support') |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 465 | self._checker.check_native_library('libopenjdkjvm') |
| 466 | self._checker.check_native_library('libopenjdkjvmti') |
| 467 | self._checker.check_native_library('libprofile') |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 468 | self._checker.check_native_library('libsigchain') |
| 469 | |
| 470 | # Check java libraries for Managed Core Library. |
| 471 | self._checker.check_java_library('apache-xml') |
| 472 | self._checker.check_java_library('bouncycastle') |
Victor Chang | 759845f | 2019-08-06 16:04:36 +0100 | [diff] [blame] | 473 | self._checker.check_java_library('core-icu4j') |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 474 | self._checker.check_java_library('core-libart') |
| 475 | self._checker.check_java_library('core-oj') |
| 476 | self._checker.check_java_library('okhttp') |
| 477 | |
| 478 | # Check internal native libraries for Managed Core Library. |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 479 | self._checker.check_native_library('libjavacore') |
| 480 | self._checker.check_native_library('libopenjdk') |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 481 | |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 482 | # Check internal native library dependencies. |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 483 | # |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 484 | # Any internal dependency not listed here will cause a failure in |
| 485 | # NoSuperfluousLibrariesChecker. Internal dependencies are generally just |
| 486 | # implementation details, but in the release package we want to track them |
| 487 | # because a) they add to the package size and the RAM usage (in particular |
| 488 | # if the library is also present in /system or another APEX and hence might |
| 489 | # get loaded twice through linker namespace separation), and b) we need to |
| 490 | # catch invalid dependencies on /system or other APEXes that should go |
| 491 | # through an exported library with stubs (b/128708192 tracks implementing a |
| 492 | # better approach for that). |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 493 | self._checker.check_native_library('libbacktrace') |
| 494 | self._checker.check_native_library('libbase') |
| 495 | self._checker.check_native_library('libc++') |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 496 | self._checker.check_native_library('libdt_fd_forward') |
| 497 | self._checker.check_native_library('libdt_socket') |
| 498 | self._checker.check_native_library('libjdwp') |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 499 | self._checker.check_native_library('liblzma') |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 500 | self._checker.check_native_library('libnpt') |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 501 | self._checker.check_native_library('libunwindstack') |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 502 | self._checker.check_native_library('libziparchive') |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 503 | self._checker.check_optional_native_library('libvixl') # Only on ARM/ARM64 |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 504 | |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 505 | # Allow extra dependencies that appear in ASAN builds. |
| 506 | self._checker.check_optional_native_library('libclang_rt.asan*') |
| 507 | self._checker.check_optional_native_library('libclang_rt.hwasan*') |
| 508 | self._checker.check_optional_native_library('libclang_rt.ubsan*') |
| 509 | |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 510 | |
Andreas Gampe | 9dc4b05 | 2019-01-30 13:47:25 -0800 | [diff] [blame] | 511 | class ReleaseTargetChecker: |
| 512 | def __init__(self, checker): |
| 513 | self._checker = checker |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 514 | |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 515 | def __str__(self): |
| 516 | return 'Release (Target) Checker' |
| 517 | |
| 518 | def run(self): |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 519 | # Check the APEX package scripts. |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 520 | self._checker.check_executable('art_postinstall_hook') |
| 521 | self._checker.check_executable('art_preinstall_hook') |
| 522 | self._checker.check_executable('art_preinstall_hook_boot') |
| 523 | self._checker.check_executable('art_preinstall_hook_system_server') |
| 524 | self._checker.check_executable('art_prepostinstall_utils') |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 525 | |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 526 | # Check binaries for ART. |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 527 | self._checker.check_executable('oatdump') |
| 528 | |
| 529 | # Check internal libraries for ART. |
| 530 | self._checker.check_prefer64_library('libart-disassembler') |
| 531 | |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 532 | # Check exported native libraries for Managed Core Library. |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 533 | self._checker.check_native_library('libandroidicu') |
| 534 | self._checker.check_native_library('libandroidio') |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 535 | |
| 536 | # Check internal native library dependencies. |
| 537 | self._checker.check_native_library('libcrypto') |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 538 | self._checker.check_native_library('libexpat') |
| 539 | self._checker.check_native_library('libicui18n') |
| 540 | self._checker.check_native_library('libicuuc') |
| 541 | self._checker.check_native_library('libpac') |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 542 | self._checker.check_native_library('libz') |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 543 | |
Martin Stjernholm | ec2db5f | 2019-09-04 20:54:57 +0100 | [diff] [blame^] | 544 | # TODO(b/139046641): Fix proper 2nd arch checks. For now, just ignore these |
| 545 | # directories. |
| 546 | self._checker.ignore_path('bin/arm') |
| 547 | self._checker.ignore_path('lib/arm') |
| 548 | self._checker.ignore_path('lib64/arm') |
| 549 | |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 550 | |
Andreas Gampe | 9dc4b05 | 2019-01-30 13:47:25 -0800 | [diff] [blame] | 551 | class ReleaseHostChecker: |
| 552 | def __init__(self, checker): |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 553 | self._checker = checker |
| 554 | |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 555 | def __str__(self): |
| 556 | return 'Release (Host) Checker' |
| 557 | |
| 558 | def run(self): |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 559 | # Check binaries for ART. |
| 560 | self._checker.check_executable('hprof-conv') |
| 561 | self._checker.check_symlinked_multilib_executable('dex2oatd') |
| 562 | |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 563 | # Check exported native libraries for Managed Core Library. |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 564 | self._checker.check_native_library('libandroidicu-host') |
| 565 | self._checker.check_native_library('libandroidio') |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 566 | |
| 567 | # Check internal libraries for Managed Core Library. |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 568 | self._checker.check_native_library('libexpat-host') |
| 569 | self._checker.check_native_library('libicui18n-host') |
| 570 | self._checker.check_native_library('libicuuc-host') |
| 571 | self._checker.check_native_library('libz-host') |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 572 | |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 573 | |
Andreas Gampe | 9dc4b05 | 2019-01-30 13:47:25 -0800 | [diff] [blame] | 574 | class DebugChecker: |
| 575 | def __init__(self, checker): |
| 576 | self._checker = checker |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 577 | |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 578 | def __str__(self): |
| 579 | return 'Debug Checker' |
| 580 | |
| 581 | def run(self): |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 582 | # Check binaries for ART. |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 583 | self._checker.check_executable('dexdiag') |
Roland Levillain | 6dd6212 | 2019-06-18 19:10:21 +0100 | [diff] [blame] | 584 | self._checker.check_executable('dexanalyze') |
| 585 | self._checker.check_executable('dexlayout') |
| 586 | self._checker.check_symlinked_multilib_executable('imgdiag') |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 587 | |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 588 | # Check debug binaries for ART. |
Roland Levillain | 6dd6212 | 2019-06-18 19:10:21 +0100 | [diff] [blame] | 589 | self._checker.check_executable('dexlayoutd') |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 590 | self._checker.check_executable('dexoptanalyzerd') |
Roland Levillain | 6dd6212 | 2019-06-18 19:10:21 +0100 | [diff] [blame] | 591 | self._checker.check_symlinked_multilib_executable('imgdiagd') |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 592 | self._checker.check_executable('profmand') |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 593 | |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 594 | # Check internal libraries for ART. |
| 595 | self._checker.check_native_library('libadbconnectiond') |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 596 | self._checker.check_native_library('libartbased') |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 597 | self._checker.check_native_library('libartd') |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 598 | self._checker.check_native_library('libartd-compiler') |
| 599 | self._checker.check_native_library('libartd-dexlayout') |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 600 | self._checker.check_native_library('libdexfiled') |
| 601 | self._checker.check_native_library('libopenjdkjvmd') |
| 602 | self._checker.check_native_library('libopenjdkjvmtid') |
| 603 | self._checker.check_native_library('libprofiled') |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 604 | |
| 605 | # Check internal libraries for Managed Core Library. |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 606 | self._checker.check_native_library('libopenjdkd') |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 607 | |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 608 | |
Andreas Gampe | 9dc4b05 | 2019-01-30 13:47:25 -0800 | [diff] [blame] | 609 | class DebugTargetChecker: |
| 610 | def __init__(self, checker): |
| 611 | self._checker = checker |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 612 | |
Andreas Gampe | a0242cf | 2019-01-29 13:01:23 -0800 | [diff] [blame] | 613 | def __str__(self): |
| 614 | return 'Debug (Target) Checker' |
| 615 | |
| 616 | def run(self): |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 617 | # Check ART debug binaries. |
Roland Levillain | 9a45d01 | 2019-06-05 13:54:02 +0100 | [diff] [blame] | 618 | self._checker.check_executable('dex2oatd') |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 619 | self._checker.check_executable('oatdumpd') |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 620 | |
| 621 | # Check ART internal libraries. |
Martin Stjernholm | 356864a | 2019-04-30 16:22:17 +0100 | [diff] [blame] | 622 | self._checker.check_native_library('libdexfiled_external') |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 623 | self._checker.check_prefer64_library('libartd-disassembler') |
Andreas Gampe | a0242cf | 2019-01-29 13:01:23 -0800 | [diff] [blame] | 624 | |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 625 | # Check internal native library dependencies. |
| 626 | # |
| 627 | # Like in the release package, we check that we don't get other dependencies |
| 628 | # besides those listed here. In this case the concern is not bloat, but |
| 629 | # rather that we don't get behavioural differences between user (release) |
| 630 | # and userdebug/eng builds, which could happen if the debug package has |
| 631 | # duplicate library instances where releases don't. In other words, it's |
| 632 | # uncontroversial to add debug-only dependencies, as long as they don't make |
| 633 | # assumptions on having a single global state (ideally they should have |
| 634 | # double_loadable:true, cf. go/double_loadable). Also, like in the release |
| 635 | # package we need to look out for dependencies that should go through |
| 636 | # exported library stubs (until b/128708192 is fixed). |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 637 | self._checker.check_optional_native_library('libvixld') # Only on ARM/ARM64 |
Martin Stjernholm | 77f1766 | 2019-04-03 17:08:21 +0100 | [diff] [blame] | 638 | self._checker.check_prefer64_library('libmeminfo') |
| 639 | self._checker.check_prefer64_library('libprocinfo') |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 640 | |
| 641 | |
Roland Levillain | 61f0716 | 2019-06-26 12:44:04 +0100 | [diff] [blame] | 642 | class TestingTargetChecker: |
| 643 | def __init__(self, checker): |
| 644 | self._checker = checker |
| 645 | |
| 646 | def __str__(self): |
| 647 | return 'Testing (Target) Checker' |
| 648 | |
| 649 | def run(self): |
| 650 | # Check cmdline tests. |
| 651 | self._checker.check_optional_art_test_executable('cmdline_parser_test') |
| 652 | |
| 653 | # Check compiler tests. |
| 654 | self._checker.check_art_test_executable('atomic_dex_ref_map_test') |
| 655 | self._checker.check_art_test_executable('bounds_check_elimination_test') |
| 656 | self._checker.check_art_test_executable('codegen_test') |
| 657 | self._checker.check_art_test_executable('compiled_method_storage_test') |
| 658 | self._checker.check_art_test_executable('data_type_test') |
| 659 | self._checker.check_art_test_executable('dedupe_set_test') |
| 660 | self._checker.check_art_test_executable('dominator_test') |
| 661 | self._checker.check_art_test_executable('dwarf_test') |
| 662 | self._checker.check_art_test_executable('exception_test') |
| 663 | self._checker.check_art_test_executable('find_loops_test') |
| 664 | self._checker.check_art_test_executable('graph_checker_test') |
| 665 | self._checker.check_art_test_executable('graph_test') |
| 666 | self._checker.check_art_test_executable('gvn_test') |
| 667 | self._checker.check_art_test_executable('induction_var_analysis_test') |
| 668 | self._checker.check_art_test_executable('induction_var_range_test') |
| 669 | self._checker.check_art_test_executable('jni_cfi_test') |
| 670 | self._checker.check_art_test_executable('jni_compiler_test') |
| 671 | self._checker.check_art_test_executable('licm_test') |
| 672 | self._checker.check_art_test_executable('linker_patch_test') |
| 673 | self._checker.check_art_test_executable('live_interval_test') |
| 674 | self._checker.check_art_test_executable('load_store_analysis_test') |
| 675 | self._checker.check_art_test_executable('loop_optimization_test') |
| 676 | self._checker.check_art_test_executable('nodes_test') |
| 677 | self._checker.check_art_test_executable('nodes_vector_test') |
| 678 | self._checker.check_art_test_executable('optimizing_cfi_test') |
| 679 | self._checker.check_art_test_executable('output_stream_test') |
| 680 | self._checker.check_art_test_executable('parallel_move_test') |
| 681 | self._checker.check_art_test_executable('pretty_printer_test') |
| 682 | self._checker.check_art_test_executable('reference_type_propagation_test') |
| 683 | self._checker.check_art_test_executable('scheduler_test') |
| 684 | self._checker.check_art_test_executable('select_generator_test') |
| 685 | self._checker.check_art_test_executable('side_effects_test') |
| 686 | self._checker.check_art_test_executable('src_map_elem_test') |
| 687 | self._checker.check_art_test_executable('ssa_liveness_analysis_test') |
| 688 | self._checker.check_art_test_executable('ssa_test') |
| 689 | self._checker.check_art_test_executable('stack_map_test') |
| 690 | self._checker.check_art_test_executable('superblock_cloner_test') |
| 691 | self._checker.check_art_test_executable('suspend_check_test') |
| 692 | self._checker.check_art_test_executable('swap_space_test') |
| 693 | # These tests depend on a specific code generator and are conditionally included. |
| 694 | self._checker.check_optional_art_test_executable('constant_folding_test') |
| 695 | self._checker.check_optional_art_test_executable('dead_code_elimination_test') |
| 696 | self._checker.check_optional_art_test_executable('linearize_test') |
| 697 | self._checker.check_optional_art_test_executable('live_ranges_test') |
| 698 | self._checker.check_optional_art_test_executable('liveness_test') |
| 699 | self._checker.check_optional_art_test_executable('managed_register_arm64_test') |
| 700 | self._checker.check_optional_art_test_executable('managed_register_arm_test') |
| 701 | self._checker.check_optional_art_test_executable('managed_register_mips64_test') |
| 702 | self._checker.check_optional_art_test_executable('managed_register_x86_64_test') |
| 703 | self._checker.check_optional_art_test_executable('managed_register_x86_test') |
| 704 | self._checker.check_optional_art_test_executable('register_allocator_test') |
| 705 | |
| 706 | # Check dex2oat tests. |
| 707 | self._checker.check_art_test_executable('compiler_driver_test') |
| 708 | self._checker.check_art_test_executable('dex2oat_image_test') |
| 709 | self._checker.check_art_test_executable('dex2oat_test') |
| 710 | self._checker.check_art_test_executable('dex_to_dex_decompiler_test') |
| 711 | self._checker.check_art_test_executable('elf_writer_test') |
| 712 | self._checker.check_art_test_executable('image_test') |
| 713 | self._checker.check_art_test_executable('image_write_read_test') |
| 714 | self._checker.check_art_test_executable('index_bss_mapping_encoder_test') |
| 715 | self._checker.check_art_test_executable('multi_oat_relative_patcher_test') |
| 716 | self._checker.check_art_test_executable('oat_writer_test') |
| 717 | self._checker.check_art_test_executable('verifier_deps_test') |
| 718 | # These tests depend on a specific code generator and are conditionally included. |
| 719 | self._checker.check_optional_art_test_executable('relative_patcher_arm64_test') |
| 720 | self._checker.check_optional_art_test_executable('relative_patcher_mips32r6_test') |
| 721 | self._checker.check_optional_art_test_executable('relative_patcher_mips64_test') |
| 722 | self._checker.check_optional_art_test_executable('relative_patcher_mips_test') |
| 723 | self._checker.check_optional_art_test_executable('relative_patcher_thumb2_test') |
| 724 | self._checker.check_optional_art_test_executable('relative_patcher_x86_64_test') |
| 725 | self._checker.check_optional_art_test_executable('relative_patcher_x86_test') |
| 726 | |
| 727 | # Check dexanalyze tests. |
| 728 | self._checker.check_optional_art_test_executable('dexanalyze_test') |
| 729 | |
| 730 | # Check dexdiag tests. |
| 731 | self._checker.check_optional_art_test_executable('dexdiag_test') |
| 732 | |
| 733 | # Check dexdump tests. |
| 734 | self._checker.check_art_test_executable('dexdump_test') |
| 735 | |
| 736 | # Check dexlayout tests. |
| 737 | self._checker.check_optional_art_test_executable('dexlayout_test') |
| 738 | |
| 739 | # Check dexlist tests. |
| 740 | self._checker.check_art_test_executable('dexlist_test') |
| 741 | |
| 742 | # Check dexoptanalyzer tests. |
| 743 | self._checker.check_art_test_executable('dexoptanalyzer_test') |
| 744 | |
| 745 | # Check imgdiag tests. |
| 746 | self._checker.check_art_test_executable('imgdiag_test') |
| 747 | |
| 748 | # Check libartbase tests. |
| 749 | self._checker.check_art_test_executable('arena_allocator_test') |
| 750 | self._checker.check_art_test_executable('bit_field_test') |
| 751 | self._checker.check_art_test_executable('bit_memory_region_test') |
| 752 | self._checker.check_art_test_executable('bit_string_test') |
| 753 | self._checker.check_art_test_executable('bit_struct_test') |
| 754 | self._checker.check_art_test_executable('bit_table_test') |
| 755 | self._checker.check_art_test_executable('bit_utils_test') |
| 756 | self._checker.check_art_test_executable('bit_vector_test') |
| 757 | self._checker.check_art_test_executable('fd_file_test') |
| 758 | self._checker.check_art_test_executable('file_utils_test') |
| 759 | self._checker.check_art_test_executable('hash_set_test') |
| 760 | self._checker.check_art_test_executable('hex_dump_test') |
| 761 | self._checker.check_art_test_executable('histogram_test') |
| 762 | self._checker.check_art_test_executable('indenter_test') |
| 763 | self._checker.check_art_test_executable('instruction_set_test') |
| 764 | self._checker.check_art_test_executable('intrusive_forward_list_test') |
| 765 | self._checker.check_art_test_executable('leb128_test') |
| 766 | self._checker.check_art_test_executable('logging_test') |
| 767 | self._checker.check_art_test_executable('mem_map_test') |
| 768 | self._checker.check_art_test_executable('membarrier_test') |
| 769 | self._checker.check_art_test_executable('memfd_test') |
| 770 | self._checker.check_art_test_executable('memory_region_test') |
| 771 | self._checker.check_art_test_executable('memory_type_table_test') |
| 772 | self._checker.check_art_test_executable('safe_copy_test') |
| 773 | self._checker.check_art_test_executable('scoped_flock_test') |
| 774 | self._checker.check_art_test_executable('time_utils_test') |
| 775 | self._checker.check_art_test_executable('transform_array_ref_test') |
| 776 | self._checker.check_art_test_executable('transform_iterator_test') |
| 777 | self._checker.check_art_test_executable('utils_test') |
| 778 | self._checker.check_art_test_executable('variant_map_test') |
| 779 | self._checker.check_art_test_executable('zip_archive_test') |
| 780 | |
| 781 | # Check libartpalette tests. |
| 782 | self._checker.check_art_test_executable('palette_test') |
| 783 | |
| 784 | # Check libdexfile tests. |
| 785 | self._checker.check_art_test_executable('art_dex_file_loader_test') |
| 786 | self._checker.check_art_test_executable('art_libdexfile_support_tests') |
| 787 | self._checker.check_art_test_executable('class_accessor_test') |
| 788 | self._checker.check_art_test_executable('code_item_accessors_test') |
| 789 | self._checker.check_art_test_executable('compact_dex_file_test') |
| 790 | self._checker.check_art_test_executable('compact_offset_table_test') |
| 791 | self._checker.check_art_test_executable('descriptors_names_test') |
| 792 | self._checker.check_art_test_executable('dex_file_loader_test') |
| 793 | self._checker.check_art_test_executable('dex_file_verifier_test') |
| 794 | self._checker.check_art_test_executable('dex_instruction_test') |
| 795 | self._checker.check_art_test_executable('primitive_test') |
| 796 | self._checker.check_art_test_executable('string_reference_test') |
| 797 | self._checker.check_art_test_executable('test_dex_file_builder_test') |
| 798 | self._checker.check_art_test_executable('type_lookup_table_test') |
| 799 | self._checker.check_art_test_executable('utf_test') |
| 800 | |
| 801 | # Check libprofile tests. |
| 802 | self._checker.check_optional_art_test_executable('profile_boot_info_test') |
| 803 | self._checker.check_optional_art_test_executable('profile_compilation_info_test') |
| 804 | |
| 805 | # Check oatdump tests. |
| 806 | self._checker.check_art_test_executable('oatdump_app_test') |
| 807 | self._checker.check_art_test_executable('oatdump_image_test') |
| 808 | self._checker.check_art_test_executable('oatdump_test') |
| 809 | |
| 810 | # Check profman tests. |
| 811 | self._checker.check_art_test_executable('profile_assistant_test') |
| 812 | |
| 813 | # Check runtime compiler tests. |
| 814 | self._checker.check_art_test_executable('module_exclusion_test') |
| 815 | self._checker.check_art_test_executable('reflection_test') |
| 816 | |
| 817 | # Check runtime tests. |
| 818 | self._checker.check_art_test_executable('arch_test') |
| 819 | self._checker.check_art_test_executable('barrier_test') |
| 820 | self._checker.check_art_test_executable('card_table_test') |
| 821 | self._checker.check_art_test_executable('cha_test') |
| 822 | self._checker.check_art_test_executable('class_linker_test') |
| 823 | self._checker.check_art_test_executable('class_loader_context_test') |
| 824 | self._checker.check_art_test_executable('class_table_test') |
| 825 | self._checker.check_art_test_executable('compiler_filter_test') |
| 826 | self._checker.check_art_test_executable('dex_cache_test') |
| 827 | self._checker.check_art_test_executable('dlmalloc_space_random_test') |
| 828 | self._checker.check_art_test_executable('dlmalloc_space_static_test') |
| 829 | self._checker.check_art_test_executable('entrypoints_order_test') |
| 830 | self._checker.check_art_test_executable('exec_utils_test') |
| 831 | self._checker.check_art_test_executable('gtest_test') |
| 832 | self._checker.check_art_test_executable('handle_scope_test') |
| 833 | self._checker.check_art_test_executable('heap_test') |
| 834 | self._checker.check_art_test_executable('heap_verification_test') |
| 835 | self._checker.check_art_test_executable('hidden_api_test') |
| 836 | self._checker.check_art_test_executable('image_space_test') |
| 837 | self._checker.check_art_test_executable('immune_spaces_test') |
| 838 | self._checker.check_art_test_executable('imtable_test') |
| 839 | self._checker.check_art_test_executable('indirect_reference_table_test') |
| 840 | self._checker.check_art_test_executable('instruction_set_features_arm64_test') |
| 841 | self._checker.check_art_test_executable('instruction_set_features_arm_test') |
| 842 | self._checker.check_art_test_executable('instruction_set_features_mips64_test') |
| 843 | self._checker.check_art_test_executable('instruction_set_features_mips_test') |
| 844 | self._checker.check_art_test_executable('instruction_set_features_test') |
| 845 | self._checker.check_art_test_executable('instruction_set_features_x86_64_test') |
| 846 | self._checker.check_art_test_executable('instruction_set_features_x86_test') |
| 847 | self._checker.check_art_test_executable('instrumentation_test') |
| 848 | self._checker.check_art_test_executable('intern_table_test') |
| 849 | self._checker.check_art_test_executable('java_vm_ext_test') |
| 850 | self._checker.check_art_test_executable('jdwp_options_test') |
| 851 | self._checker.check_art_test_executable('jit_memory_region_test') |
| 852 | self._checker.check_art_test_executable('jni_internal_test') |
| 853 | self._checker.check_art_test_executable('large_object_space_test') |
| 854 | self._checker.check_art_test_executable('math_entrypoints_test') |
| 855 | self._checker.check_art_test_executable('memcmp16_test') |
| 856 | self._checker.check_art_test_executable('method_handles_test') |
| 857 | self._checker.check_art_test_executable('method_type_test') |
| 858 | self._checker.check_art_test_executable('method_verifier_test') |
| 859 | self._checker.check_art_test_executable('mod_union_table_test') |
| 860 | self._checker.check_art_test_executable('monitor_pool_test') |
| 861 | self._checker.check_art_test_executable('monitor_test') |
| 862 | self._checker.check_art_test_executable('mutex_test') |
| 863 | self._checker.check_art_test_executable('oat_file_assistant_test') |
| 864 | self._checker.check_art_test_executable('oat_file_test') |
| 865 | self._checker.check_art_test_executable('object_test') |
| 866 | self._checker.check_art_test_executable('parsed_options_test') |
| 867 | self._checker.check_art_test_executable('prebuilt_tools_test') |
| 868 | self._checker.check_art_test_executable('profiling_info_test') |
| 869 | self._checker.check_art_test_executable('proxy_test') |
| 870 | self._checker.check_art_test_executable('quick_trampoline_entrypoints_test') |
| 871 | self._checker.check_art_test_executable('reference_queue_test') |
| 872 | self._checker.check_art_test_executable('reference_table_test') |
| 873 | self._checker.check_art_test_executable('reg_type_test') |
| 874 | self._checker.check_art_test_executable('rosalloc_space_random_test') |
| 875 | self._checker.check_art_test_executable('rosalloc_space_static_test') |
| 876 | self._checker.check_art_test_executable('runtime_callbacks_test') |
| 877 | self._checker.check_art_test_executable('runtime_test') |
| 878 | self._checker.check_art_test_executable('safe_math_test') |
| 879 | self._checker.check_art_test_executable('space_bitmap_test') |
| 880 | self._checker.check_art_test_executable('space_create_test') |
| 881 | self._checker.check_art_test_executable('stub_test') |
| 882 | self._checker.check_art_test_executable('subtype_check_info_test') |
| 883 | self._checker.check_art_test_executable('subtype_check_test') |
| 884 | self._checker.check_art_test_executable('system_weak_test') |
| 885 | self._checker.check_art_test_executable('task_processor_test') |
| 886 | self._checker.check_art_test_executable('thread_pool_test') |
| 887 | self._checker.check_art_test_executable('timing_logger_test') |
| 888 | self._checker.check_art_test_executable('transaction_test') |
| 889 | self._checker.check_art_test_executable('two_runtimes_test') |
| 890 | self._checker.check_art_test_executable('unstarted_runtime_test') |
| 891 | self._checker.check_art_test_executable('var_handle_test') |
| 892 | self._checker.check_art_test_executable('vdex_file_test') |
| 893 | |
| 894 | # Check sigchainlib tests. |
| 895 | self._checker.check_art_test_executable('sigchain_test') |
| 896 | |
| 897 | # Check ART test (internal) libraries. |
| 898 | self._checker.check_native_library('libart-gtest') |
| 899 | self._checker.check_native_library('libartd-disassembler') |
| 900 | self._checker.check_native_library('libartd-simulator-container') |
| 901 | |
| 902 | |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 903 | class NoSuperfluousBinariesChecker: |
| 904 | def __init__(self, checker): |
| 905 | self._checker = checker |
| 906 | |
| 907 | def __str__(self): |
| 908 | return 'No superfluous binaries checker' |
| 909 | |
| 910 | def run(self): |
| 911 | self._checker.check_no_superfluous_files('bin') |
| 912 | |
| 913 | |
| 914 | class NoSuperfluousLibrariesChecker: |
| 915 | def __init__(self, checker): |
| 916 | self._checker = checker |
| 917 | |
| 918 | def __str__(self): |
| 919 | return 'No superfluous libraries checker' |
| 920 | |
| 921 | def run(self): |
| 922 | self._checker.check_no_superfluous_files('javalib') |
| 923 | self._checker.check_no_superfluous_files('lib') |
| 924 | self._checker.check_no_superfluous_files('lib/bionic') |
| 925 | self._checker.check_no_superfluous_files('lib64') |
| 926 | self._checker.check_no_superfluous_files('lib64/bionic') |
| 927 | |
Andreas Gampe | b1d5567 | 2019-01-29 22:17:02 +0000 | [diff] [blame] | 928 | |
Roland Levillain | 61f0716 | 2019-06-26 12:44:04 +0100 | [diff] [blame] | 929 | class NoSuperfluousArtTestsChecker: |
| 930 | def __init__(self, checker): |
| 931 | self._checker = checker |
| 932 | |
| 933 | def __str__(self): |
| 934 | return 'No superfluous ART tests checker' |
| 935 | |
| 936 | def run(self): |
| 937 | for arch in archs: |
| 938 | self._checker.check_no_superfluous_files('%s/%s' % (art_test_dir, arch)) |
| 939 | |
| 940 | |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 941 | class List: |
Roland Levillain | 77251f9 | 2019-08-09 15:00:04 +0100 | [diff] [blame] | 942 | def __init__(self, provider, print_size=False): |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 943 | self._provider = provider |
Roland Levillain | e91d787 | 2019-07-25 18:56:06 +0100 | [diff] [blame] | 944 | self._print_size = print_size |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 945 | |
| 946 | def print_list(self): |
Roland Levillain | 09744ac | 2019-06-06 18:23:02 +0100 | [diff] [blame] | 947 | |
| 948 | def print_list_rec(path): |
| 949 | apex_map = self._provider.read_dir(path) |
| 950 | if apex_map is None: |
| 951 | return |
| 952 | apex_map = dict(apex_map) |
| 953 | if '.' in apex_map: |
| 954 | del apex_map['.'] |
| 955 | if '..' in apex_map: |
| 956 | del apex_map['..'] |
| 957 | for (_, val) in sorted(apex_map.items()): |
| 958 | val_path = os.path.join(path, val.name) |
Roland Levillain | e91d787 | 2019-07-25 18:56:06 +0100 | [diff] [blame] | 959 | if self._print_size: |
| 960 | if val.size < 0: |
| 961 | print('[ n/a ] %s' % val_path) |
| 962 | else: |
| 963 | print('[%11d] %s' % (val.size, val_path)) |
| 964 | else: |
| 965 | print(val_path) |
Roland Levillain | 09744ac | 2019-06-06 18:23:02 +0100 | [diff] [blame] | 966 | if val.is_dir: |
| 967 | print_list_rec(val_path) |
| 968 | |
| 969 | print_list_rec('') |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 970 | |
| 971 | |
| 972 | class Tree: |
Roland Levillain | 77251f9 | 2019-08-09 15:00:04 +0100 | [diff] [blame] | 973 | def __init__(self, provider, title, print_size=False): |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 974 | print('%s' % title) |
| 975 | self._provider = provider |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 976 | self._has_next_list = [] |
Roland Levillain | 88e5569 | 2019-07-25 15:57:06 +0100 | [diff] [blame] | 977 | self._print_size = print_size |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 978 | |
| 979 | @staticmethod |
| 980 | def get_vertical(has_next_list): |
| 981 | string = '' |
| 982 | for v in has_next_list: |
| 983 | string += '%s ' % ('│' if v else ' ') |
| 984 | return string |
| 985 | |
| 986 | @staticmethod |
| 987 | def get_last_vertical(last): |
| 988 | return '└── ' if last else '├── ' |
| 989 | |
| 990 | def print_tree(self): |
Roland Levillain | 09744ac | 2019-06-06 18:23:02 +0100 | [diff] [blame] | 991 | |
| 992 | def print_tree_rec(path): |
| 993 | apex_map = self._provider.read_dir(path) |
| 994 | if apex_map is None: |
| 995 | return |
| 996 | apex_map = dict(apex_map) |
| 997 | if '.' in apex_map: |
| 998 | del apex_map['.'] |
| 999 | if '..' in apex_map: |
| 1000 | del apex_map['..'] |
| 1001 | key_list = list(sorted(apex_map.keys())) |
| 1002 | for i, key in enumerate(key_list): |
| 1003 | prev = self.get_vertical(self._has_next_list) |
| 1004 | last = self.get_last_vertical(i == len(key_list) - 1) |
| 1005 | val = apex_map[key] |
Roland Levillain | 88e5569 | 2019-07-25 15:57:06 +0100 | [diff] [blame] | 1006 | if self._print_size: |
| 1007 | if val.size < 0: |
| 1008 | print('%s%s[ n/a ] %s' % (prev, last, val.name)) |
| 1009 | else: |
| 1010 | print('%s%s[%11d] %s' % (prev, last, val.size, val.name)) |
| 1011 | else: |
| 1012 | print('%s%s%s' % (prev, last, val.name)) |
Roland Levillain | 09744ac | 2019-06-06 18:23:02 +0100 | [diff] [blame] | 1013 | if val.is_dir: |
| 1014 | self._has_next_list.append(i < len(key_list) - 1) |
| 1015 | val_path = os.path.join(path, val.name) |
| 1016 | print_tree_rec(val_path) |
| 1017 | self._has_next_list.pop() |
| 1018 | |
| 1019 | print_tree_rec('') |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1020 | |
Andreas Gampe | b1d5567 | 2019-01-29 22:17:02 +0000 | [diff] [blame] | 1021 | |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1022 | # Note: do not sys.exit early, for __del__ cleanup. |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1023 | def art_apex_test_main(test_args): |
Roland Levillain | dd20d00 | 2019-07-19 16:09:47 +0100 | [diff] [blame] | 1024 | if test_args.host and test_args.flattened: |
| 1025 | logging.error("Both of --host and --flattened set") |
| 1026 | return 1 |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1027 | if test_args.tree and test_args.debug: |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 1028 | logging.error("Both of --tree and --debug set") |
Andreas Gampe | b1d5567 | 2019-01-29 22:17:02 +0000 | [diff] [blame] | 1029 | return 1 |
Roland Levillain | 61f0716 | 2019-06-26 12:44:04 +0100 | [diff] [blame] | 1030 | if test_args.tree and test_args.testing: |
| 1031 | logging.error("Both of --tree and --testing set") |
| 1032 | return 1 |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1033 | if test_args.list and test_args.debug: |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 1034 | logging.error("Both of --list and --debug set") |
Andreas Gampe | b1d5567 | 2019-01-29 22:17:02 +0000 | [diff] [blame] | 1035 | return 1 |
Roland Levillain | 61f0716 | 2019-06-26 12:44:04 +0100 | [diff] [blame] | 1036 | if test_args.list and test_args.testing: |
| 1037 | logging.error("Both of --list and --testing set") |
| 1038 | return 1 |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1039 | if test_args.list and test_args.tree: |
Andreas Gampe | b1d5567 | 2019-01-29 22:17:02 +0000 | [diff] [blame] | 1040 | logging.error("Both of --list and --tree set") |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1041 | return 1 |
Roland Levillain | e91d787 | 2019-07-25 18:56:06 +0100 | [diff] [blame] | 1042 | if test_args.size and not (test_args.list or test_args.tree): |
| 1043 | logging.error("--size set but neither --list nor --tree set") |
Roland Levillain | 88e5569 | 2019-07-25 15:57:06 +0100 | [diff] [blame] | 1044 | return 1 |
Roland Levillain | 61f0716 | 2019-06-26 12:44:04 +0100 | [diff] [blame] | 1045 | if test_args.host and test_args.testing: |
| 1046 | logging.error("Both of --host and --testing set") |
| 1047 | return 1 |
Martin Stjernholm | 3cb59a4 | 2019-08-07 17:18:29 +0100 | [diff] [blame] | 1048 | if not test_args.flattened and not test_args.tmpdir: |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1049 | logging.error("Need a tmpdir.") |
| 1050 | return 1 |
Martin Stjernholm | 3cb59a4 | 2019-08-07 17:18:29 +0100 | [diff] [blame] | 1051 | if not test_args.flattened and not test_args.host and not test_args.debugfs: |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1052 | logging.error("Need debugfs.") |
| 1053 | return 1 |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1054 | if test_args.bitness not in ['32', '64', 'multilib', 'auto']: |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 1055 | logging.error('--bitness needs to be one of 32|64|multilib|auto') |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1056 | |
| 1057 | try: |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1058 | if test_args.host: |
| 1059 | apex_provider = HostApexProvider(test_args.apex, test_args.tmpdir) |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 1060 | else: |
Roland Levillain | dd20d00 | 2019-07-19 16:09:47 +0100 | [diff] [blame] | 1061 | if test_args.flattened: |
| 1062 | apex_provider = TargetFlattenedApexProvider(test_args.apex) |
| 1063 | else: |
| 1064 | apex_provider = TargetApexProvider(test_args.apex, test_args.tmpdir, test_args.debugfs) |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1065 | except (zipfile.BadZipFile, zipfile.LargeZipFile) as e: |
Andreas Gampe | a0242cf | 2019-01-29 13:01:23 -0800 | [diff] [blame] | 1066 | logging.error('Failed to create provider: %s', e) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1067 | return 1 |
| 1068 | |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1069 | if test_args.tree: |
Roland Levillain | 88e5569 | 2019-07-25 15:57:06 +0100 | [diff] [blame] | 1070 | Tree(apex_provider, test_args.apex, test_args.size).print_tree() |
Andreas Gampe | b1d5567 | 2019-01-29 22:17:02 +0000 | [diff] [blame] | 1071 | return 0 |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1072 | if test_args.list: |
Roland Levillain | e91d787 | 2019-07-25 18:56:06 +0100 | [diff] [blame] | 1073 | List(apex_provider, test_args.size).print_list() |
Andreas Gampe | b1d5567 | 2019-01-29 22:17:02 +0000 | [diff] [blame] | 1074 | return 0 |
| 1075 | |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1076 | checkers = [] |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1077 | if test_args.bitness == 'auto': |
| 1078 | logging.warning('--bitness=auto, trying to autodetect. This may be incorrect!') |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 1079 | has_32 = apex_provider.get('lib') is not None |
| 1080 | has_64 = apex_provider.get('lib64') is not None |
| 1081 | if has_32 and has_64: |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1082 | logging.warning(' Detected multilib') |
| 1083 | test_args.bitness = 'multilib' |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 1084 | elif has_32: |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1085 | logging.warning(' Detected 32-only') |
| 1086 | test_args.bitness = '32' |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 1087 | elif has_64: |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1088 | logging.warning(' Detected 64-only') |
| 1089 | test_args.bitness = '64' |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 1090 | else: |
| 1091 | logging.error(' Could not detect bitness, neither lib nor lib64 contained.') |
Roland Levillain | 77251f9 | 2019-08-09 15:00:04 +0100 | [diff] [blame] | 1092 | List(apex_provider).print_list() |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 1093 | return 1 |
| 1094 | |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1095 | if test_args.bitness == '32': |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 1096 | base_checker = Arch32Checker(apex_provider) |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1097 | elif test_args.bitness == '64': |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 1098 | base_checker = Arch64Checker(apex_provider) |
| 1099 | else: |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1100 | assert test_args.bitness == 'multilib' |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 1101 | base_checker = MultilibChecker(apex_provider) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1102 | |
Andreas Gampe | 9dc4b05 | 2019-01-30 13:47:25 -0800 | [diff] [blame] | 1103 | checkers.append(ReleaseChecker(base_checker)) |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1104 | if test_args.host: |
Andreas Gampe | 9dc4b05 | 2019-01-30 13:47:25 -0800 | [diff] [blame] | 1105 | checkers.append(ReleaseHostChecker(base_checker)) |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 1106 | else: |
Andreas Gampe | 9dc4b05 | 2019-01-30 13:47:25 -0800 | [diff] [blame] | 1107 | checkers.append(ReleaseTargetChecker(base_checker)) |
Roland Levillain | 61f0716 | 2019-06-26 12:44:04 +0100 | [diff] [blame] | 1108 | if test_args.debug or test_args.testing: |
Andreas Gampe | 9dc4b05 | 2019-01-30 13:47:25 -0800 | [diff] [blame] | 1109 | checkers.append(DebugChecker(base_checker)) |
Roland Levillain | 61f0716 | 2019-06-26 12:44:04 +0100 | [diff] [blame] | 1110 | if not test_args.host: |
| 1111 | checkers.append(DebugTargetChecker(base_checker)) |
| 1112 | if test_args.testing: |
| 1113 | checkers.append(TestingTargetChecker(base_checker)) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1114 | |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 1115 | # These checkers must be last. |
| 1116 | checkers.append(NoSuperfluousBinariesChecker(base_checker)) |
Roland Levillain | 61f0716 | 2019-06-26 12:44:04 +0100 | [diff] [blame] | 1117 | checkers.append(NoSuperfluousArtTestsChecker(base_checker)) |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 1118 | if not test_args.host: |
| 1119 | # We only care about superfluous libraries on target, where their absence |
| 1120 | # can be vital to ensure they get picked up from the right package. |
| 1121 | checkers.append(NoSuperfluousLibrariesChecker(base_checker)) |
| 1122 | |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1123 | failed = False |
| 1124 | for checker in checkers: |
| 1125 | logging.info('%s...', checker) |
| 1126 | checker.run() |
Andreas Gampe | 9dc4b05 | 2019-01-30 13:47:25 -0800 | [diff] [blame] | 1127 | if base_checker.error_count() > 0: |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1128 | logging.error('%s FAILED', checker) |
| 1129 | failed = True |
| 1130 | else: |
| 1131 | logging.info('%s SUCCEEDED', checker) |
Andreas Gampe | 9dc4b05 | 2019-01-30 13:47:25 -0800 | [diff] [blame] | 1132 | base_checker.reset_errors() |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1133 | |
| 1134 | return 1 if failed else 0 |
| 1135 | |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1136 | |
| 1137 | def art_apex_test_default(test_parser): |
| 1138 | if 'ANDROID_PRODUCT_OUT' not in os.environ: |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1139 | logging.error('No-argument use requires ANDROID_PRODUCT_OUT') |
| 1140 | sys.exit(1) |
| 1141 | product_out = os.environ['ANDROID_PRODUCT_OUT'] |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1142 | if 'ANDROID_HOST_OUT' not in os.environ: |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1143 | logging.error('No-argument use requires ANDROID_HOST_OUT') |
| 1144 | sys.exit(1) |
| 1145 | host_out = os.environ['ANDROID_HOST_OUT'] |
| 1146 | |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1147 | test_args = test_parser.parse_args(['dummy']) # For consistency. |
| 1148 | test_args.debugfs = '%s/bin/debugfs' % host_out |
| 1149 | test_args.tmpdir = '.' |
| 1150 | test_args.tree = False |
| 1151 | test_args.list = False |
| 1152 | test_args.bitness = 'auto' |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1153 | failed = False |
| 1154 | |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1155 | if not os.path.exists(test_args.debugfs): |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1156 | logging.error("Cannot find debugfs (default path %s). Please build it, e.g., m debugfs", |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1157 | test_args.debugfs) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1158 | sys.exit(1) |
| 1159 | |
| 1160 | # TODO: Add host support |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1161 | configs = [ |
Martin Stjernholm | fb3a94b | 2019-07-05 22:27:36 +0100 | [diff] [blame] | 1162 | {'name': 'com.android.art.release', 'debug': False, 'testing': False, 'host': False}, |
| 1163 | {'name': 'com.android.art.debug', 'debug': True, 'testing': False, 'host': False}, |
| 1164 | {'name': 'com.android.art.testing', 'debug': False, 'testing': True, 'host': False}, |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1165 | ] |
| 1166 | |
| 1167 | for config in configs: |
| 1168 | logging.info(config['name']) |
| 1169 | # TODO: Host will need different path. |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1170 | test_args.apex = '%s/system/apex/%s.apex' % (product_out, config['name']) |
| 1171 | if not os.path.exists(test_args.apex): |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1172 | failed = True |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1173 | logging.error("Cannot find APEX %s. Please build it first.", test_args.apex) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1174 | continue |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1175 | test_args.debug = config['debug'] |
Roland Levillain | 61f0716 | 2019-06-26 12:44:04 +0100 | [diff] [blame] | 1176 | test_args.testing = config['testing'] |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1177 | test_args.host = config['host'] |
| 1178 | failed = art_apex_test_main(test_args) != 0 |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1179 | |
| 1180 | if failed: |
| 1181 | sys.exit(1) |
| 1182 | |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1183 | |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1184 | if __name__ == "__main__": |
| 1185 | parser = argparse.ArgumentParser(description='Check integrity of a Runtime APEX.') |
| 1186 | |
| 1187 | parser.add_argument('apex', help='apex file input') |
| 1188 | |
| 1189 | parser.add_argument('--host', help='Check as host apex', action='store_true') |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 1190 | |
Roland Levillain | dd20d00 | 2019-07-19 16:09:47 +0100 | [diff] [blame] | 1191 | parser.add_argument('--flattened', help='Check as flattened (target) apex', action='store_true') |
| 1192 | |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1193 | parser.add_argument('--debug', help='Check as debug apex', action='store_true') |
Roland Levillain | 61f0716 | 2019-06-26 12:44:04 +0100 | [diff] [blame] | 1194 | parser.add_argument('--testing', help='Check as testing apex', action='store_true') |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1195 | |
Andreas Gampe | b1d5567 | 2019-01-29 22:17:02 +0000 | [diff] [blame] | 1196 | parser.add_argument('--list', help='List all files', action='store_true') |
| 1197 | parser.add_argument('--tree', help='Print directory tree', action='store_true') |
Roland Levillain | e91d787 | 2019-07-25 18:56:06 +0100 | [diff] [blame] | 1198 | parser.add_argument('--size', help='Print file sizes', action='store_true') |
Andreas Gampe | b1d5567 | 2019-01-29 22:17:02 +0000 | [diff] [blame] | 1199 | |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1200 | parser.add_argument('--tmpdir', help='Directory for temp files') |
| 1201 | parser.add_argument('--debugfs', help='Path to debugfs') |
| 1202 | |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 1203 | parser.add_argument('--bitness', help='Bitness to check, 32|64|multilib|auto', default='auto') |
| 1204 | |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1205 | if len(sys.argv) == 1: |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1206 | art_apex_test_default(parser) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1207 | else: |
| 1208 | args = parser.parse_args() |
| 1209 | |
| 1210 | if args is None: |
| 1211 | sys.exit(1) |
| 1212 | |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1213 | exit_code = art_apex_test_main(args) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1214 | sys.exit(exit_code) |