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 | |
Orion Hodson | af3ed62 | 2019-10-03 16:30:54 +0100 | [diff] [blame] | 30 | # Flavors of ART APEX package. |
| 31 | FLAVOR_RELEASE = 'release' |
| 32 | FLAVOR_DEBUG = 'debug' |
| 33 | FLAVOR_TESTING = 'testing' |
| 34 | FLAVOR_AUTO = 'auto' |
| 35 | FLAVORS_ALL = [FLAVOR_RELEASE, FLAVOR_DEBUG, FLAVOR_TESTING, FLAVOR_AUTO] |
| 36 | |
| 37 | # Bitness options for APEX package |
| 38 | BITNESS_32 = '32' |
| 39 | BITNESS_64 = '64' |
| 40 | BITNESS_MULTILIB = 'multilib' |
| 41 | BITNESS_AUTO = 'auto' |
| 42 | BITNESS_ALL = [BITNESS_32, BITNESS_64, BITNESS_MULTILIB, BITNESS_AUTO] |
| 43 | |
Roland Levillain | 61f0716 | 2019-06-26 12:44:04 +0100 | [diff] [blame] | 44 | # Architectures supported by APEX packages. |
Orion Hodson | af3ed62 | 2019-10-03 16:30:54 +0100 | [diff] [blame] | 45 | ARCHS = ["arm", "arm64", "x86", "x86_64"] |
| 46 | |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 47 | # Directory containing ART tests within an ART APEX (if the package includes |
Roland Levillain | 61f0716 | 2019-06-26 12:44:04 +0100 | [diff] [blame] | 48 | # any). ART test executables are installed in `bin/art/<arch>`. Segregating |
| 49 | # tests by architecture is useful on devices supporting more than one |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 50 | # architecture, as it permits testing all of them using a single ART APEX |
Roland Levillain | 61f0716 | 2019-06-26 12:44:04 +0100 | [diff] [blame] | 51 | # package. |
Orion Hodson | af3ed62 | 2019-10-03 16:30:54 +0100 | [diff] [blame] | 52 | ART_TEST_DIR = 'bin/art' |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 53 | |
Ulya Trafimovich | 7b0df59 | 2020-01-03 13:29:00 +0000 | [diff] [blame] | 54 | |
| 55 | # Test if a given variable is set to a string "true". |
| 56 | def isEnvTrue(var): |
| 57 | return var in os.environ and os.environ[var] == 'true' |
| 58 | |
| 59 | |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 60 | class FSObject: |
Roland Levillain | 88e5569 | 2019-07-25 15:57:06 +0100 | [diff] [blame] | 61 | def __init__(self, name, is_dir, is_exec, is_symlink, size): |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 62 | self.name = name |
| 63 | self.is_dir = is_dir |
| 64 | self.is_exec = is_exec |
| 65 | self.is_symlink = is_symlink |
Roland Levillain | 88e5569 | 2019-07-25 15:57:06 +0100 | [diff] [blame] | 66 | self.size = size |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 67 | |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 68 | def __str__(self): |
Roland Levillain | 88e5569 | 2019-07-25 15:57:06 +0100 | [diff] [blame] | 69 | return '%s(dir=%r,exec=%r,symlink=%r,size=%d)' \ |
| 70 | % (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] | 71 | |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 72 | |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 73 | class TargetApexProvider: |
| 74 | def __init__(self, apex, tmpdir, debugfs): |
| 75 | self._tmpdir = tmpdir |
| 76 | self._debugfs = debugfs |
| 77 | self._folder_cache = {} |
| 78 | self._payload = os.path.join(self._tmpdir, 'apex_payload.img') |
| 79 | # Extract payload to tmpdir. |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 80 | apex_zip = zipfile.ZipFile(apex) |
| 81 | apex_zip.extract('apex_payload.img', tmpdir) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 82 | |
| 83 | def __del__(self): |
| 84 | # Delete temps. |
| 85 | if os.path.exists(self._payload): |
| 86 | os.remove(self._payload) |
| 87 | |
| 88 | def get(self, path): |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 89 | apex_dir, name = os.path.split(path) |
| 90 | if not apex_dir: |
| 91 | apex_dir = '.' |
| 92 | apex_map = self.read_dir(apex_dir) |
| 93 | return apex_map[name] if name in apex_map else None |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 94 | |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 95 | def read_dir(self, apex_dir): |
| 96 | if apex_dir in self._folder_cache: |
| 97 | return self._folder_cache[apex_dir] |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 98 | # Cannot use check_output as it will annoy with stderr. |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 99 | 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] | 100 | stdout=subprocess.PIPE, stderr=subprocess.PIPE, |
| 101 | universal_newlines=True) |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 102 | stdout, _ = process.communicate() |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 103 | res = str(stdout) |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 104 | apex_map = {} |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 105 | # Debugfs output looks like this: |
| 106 | # debugfs 1.44.4 (18-Aug-2018) |
| 107 | # /12/040755/0/2000/.// |
| 108 | # /2/040755/1000/1000/..// |
| 109 | # /13/100755/0/2000/dalvikvm32/28456/ |
| 110 | # /14/100755/0/2000/dexoptanalyzer/20396/ |
| 111 | # /15/100755/0/2000/linker/1152724/ |
| 112 | # /16/100755/0/2000/dex2oat/563508/ |
| 113 | # /17/100755/0/2000/linker64/1605424/ |
| 114 | # /18/100755/0/2000/profman/85304/ |
| 115 | # /19/100755/0/2000/dalvikvm64/28576/ |
| 116 | # | | | | | | |
| 117 | # | | | #- gid #- name #- size |
| 118 | # | | #- uid |
| 119 | # | #- type and permission bits |
| 120 | # #- inode nr (?) |
| 121 | # |
| 122 | # Note: could break just on '/' to avoid names with newlines. |
| 123 | for line in res.split("\n"): |
| 124 | if not line: |
| 125 | continue |
| 126 | comps = line.split('/') |
| 127 | if len(comps) != 8: |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 128 | logging.warning('Could not break and parse line \'%s\'', line) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 129 | continue |
| 130 | bits = comps[2] |
| 131 | name = comps[5] |
Roland Levillain | 88e5569 | 2019-07-25 15:57:06 +0100 | [diff] [blame] | 132 | size_str = comps[6] |
| 133 | # Use a negative value as an indicator of undefined/unknown size. |
| 134 | size = int(size_str) if size_str != '' else -1 |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 135 | if len(bits) != 6: |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 136 | logging.warning('Dont understand bits \'%s\'', bits) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 137 | continue |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 138 | is_dir = bits[1] == '4' |
| 139 | |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 140 | def is_exec_bit(ch): |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 141 | return int(ch) & 1 == 1 |
| 142 | |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 143 | 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] | 144 | is_symlink = bits[1] == '2' |
Roland Levillain | 88e5569 | 2019-07-25 15:57:06 +0100 | [diff] [blame] | 145 | apex_map[name] = FSObject(name, is_dir, is_exec, is_symlink, size) |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 146 | self._folder_cache[apex_dir] = apex_map |
| 147 | return apex_map |
| 148 | |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 149 | |
Roland Levillain | dd20d00 | 2019-07-19 16:09:47 +0100 | [diff] [blame] | 150 | class TargetFlattenedApexProvider: |
| 151 | def __init__(self, apex): |
| 152 | self._folder_cache = {} |
| 153 | self._apex = apex |
| 154 | |
| 155 | def get(self, path): |
| 156 | apex_dir, name = os.path.split(path) |
| 157 | if not apex_dir: |
| 158 | apex_dir = '.' |
| 159 | apex_map = self.read_dir(apex_dir) |
| 160 | return apex_map[name] if name in apex_map else None |
| 161 | |
| 162 | def read_dir(self, apex_dir): |
| 163 | if apex_dir in self._folder_cache: |
| 164 | return self._folder_cache[apex_dir] |
| 165 | apex_map = {} |
| 166 | dirname = os.path.join(self._apex, apex_dir) |
| 167 | if os.path.exists(dirname): |
| 168 | for basename in os.listdir(dirname): |
| 169 | filepath = os.path.join(dirname, basename) |
| 170 | is_dir = os.path.isdir(filepath) |
| 171 | is_exec = os.access(filepath, os.X_OK) |
| 172 | is_symlink = os.path.islink(filepath) |
Roland Levillain | 3cd802e | 2020-02-20 15:31:20 +0000 | [diff] [blame] | 173 | if is_symlink: |
| 174 | # Report the length of the symlink's target's path as file size, like `ls`. |
| 175 | size = len(os.readlink(filepath)) |
| 176 | else: |
| 177 | size = os.path.getsize(filepath) |
Roland Levillain | 88e5569 | 2019-07-25 15:57:06 +0100 | [diff] [blame] | 178 | apex_map[basename] = FSObject(basename, is_dir, is_exec, is_symlink, size) |
Roland Levillain | dd20d00 | 2019-07-19 16:09:47 +0100 | [diff] [blame] | 179 | self._folder_cache[apex_dir] = apex_map |
| 180 | return apex_map |
| 181 | |
| 182 | |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 183 | class HostApexProvider: |
| 184 | def __init__(self, apex, tmpdir): |
| 185 | self._tmpdir = tmpdir |
Roland Levillain | 77251f9 | 2019-08-09 15:00:04 +0100 | [diff] [blame] | 186 | self._folder_cache = {} |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 187 | self._payload = os.path.join(self._tmpdir, 'apex_payload.zip') |
| 188 | # Extract payload to tmpdir. |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 189 | apex_zip = zipfile.ZipFile(apex) |
| 190 | apex_zip.extract('apex_payload.zip', tmpdir) |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 191 | |
| 192 | def __del__(self): |
| 193 | # Delete temps. |
| 194 | if os.path.exists(self._payload): |
| 195 | os.remove(self._payload) |
| 196 | |
| 197 | def get(self, path): |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 198 | apex_dir, name = os.path.split(path) |
| 199 | if not apex_dir: |
| 200 | apex_dir = '' |
| 201 | apex_map = self.read_dir(apex_dir) |
| 202 | return apex_map[name] if name in apex_map else None |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 203 | |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 204 | def read_dir(self, apex_dir): |
Roland Levillain | 77251f9 | 2019-08-09 15:00:04 +0100 | [diff] [blame] | 205 | if apex_dir in self._folder_cache: |
| 206 | return self._folder_cache[apex_dir] |
| 207 | if not self._folder_cache: |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 208 | self.parse_zip() |
Roland Levillain | 77251f9 | 2019-08-09 15:00:04 +0100 | [diff] [blame] | 209 | if apex_dir in self._folder_cache: |
| 210 | return self._folder_cache[apex_dir] |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 211 | return {} |
| 212 | |
| 213 | def parse_zip(self): |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 214 | apex_zip = zipfile.ZipFile(self._payload) |
| 215 | infos = apex_zip.infolist() |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 216 | for zipinfo in infos: |
| 217 | path = zipinfo.filename |
| 218 | |
| 219 | # Assume no empty file is stored. |
| 220 | assert path |
| 221 | |
| 222 | def get_octal(val, index): |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 223 | return (val >> (index * 3)) & 0x7 |
| 224 | |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 225 | def bits_is_exec(val): |
| 226 | # TODO: Enforce group/other, too? |
| 227 | return get_octal(val, 2) & 1 == 1 |
| 228 | |
| 229 | is_zipinfo = True |
| 230 | while path: |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 231 | apex_dir, base = os.path.split(path) |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 232 | # TODO: If directories are stored, base will be empty. |
| 233 | |
Roland Levillain | 77251f9 | 2019-08-09 15:00:04 +0100 | [diff] [blame] | 234 | if apex_dir not in self._folder_cache: |
| 235 | self._folder_cache[apex_dir] = {} |
| 236 | dir_map = self._folder_cache[apex_dir] |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 237 | if base not in dir_map: |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 238 | if is_zipinfo: |
| 239 | bits = (zipinfo.external_attr >> 16) & 0xFFFF |
| 240 | is_dir = get_octal(bits, 4) == 4 |
| 241 | is_symlink = get_octal(bits, 4) == 2 |
| 242 | is_exec = bits_is_exec(bits) |
Roland Levillain | 88e5569 | 2019-07-25 15:57:06 +0100 | [diff] [blame] | 243 | size = zipinfo.file_size |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 244 | else: |
| 245 | is_exec = False # Seems we can't get this easily? |
| 246 | is_symlink = False |
| 247 | is_dir = True |
Roland Levillain | 88e5569 | 2019-07-25 15:57:06 +0100 | [diff] [blame] | 248 | # Use a negative value as an indicator of undefined/unknown size. |
| 249 | size = -1 |
| 250 | dir_map[base] = FSObject(base, is_dir, is_exec, is_symlink, size) |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 251 | is_zipinfo = False |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 252 | path = apex_dir |
| 253 | |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 254 | |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 255 | # DO NOT USE DIRECTLY! This is an "abstract" base class. |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 256 | class Checker: |
| 257 | def __init__(self, provider): |
| 258 | self._provider = provider |
| 259 | self._errors = 0 |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 260 | self._expected_file_globs = set() |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 261 | |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 262 | def fail(self, msg, *fail_args): |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 263 | self._errors += 1 |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 264 | logging.error(msg, *fail_args) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 265 | |
| 266 | def error_count(self): |
| 267 | return self._errors |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 268 | |
Andreas Gampe | 9dc4b05 | 2019-01-30 13:47:25 -0800 | [diff] [blame] | 269 | def reset_errors(self): |
| 270 | self._errors = 0 |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 271 | |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 272 | def is_file(self, path): |
| 273 | fs_object = self._provider.get(path) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 274 | if fs_object is None: |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 275 | return False, 'Could not find %s' |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 276 | if fs_object.is_dir: |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 277 | return False, '%s is a directory' |
| 278 | return True, '' |
Andreas Gampe | a0242cf | 2019-01-29 13:01:23 -0800 | [diff] [blame] | 279 | |
Ulyana Trafimovich | 7a20cbd | 2019-11-08 11:27:31 +0000 | [diff] [blame] | 280 | def is_dir(self, path): |
| 281 | fs_object = self._provider.get(path) |
| 282 | if fs_object is None: |
| 283 | return False, 'Could not find %s' |
| 284 | if not fs_object.is_dir: |
| 285 | return False, '%s is not a directory' |
| 286 | return True, '' |
| 287 | |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 288 | def check_file(self, path): |
| 289 | ok, msg = self.is_file(path) |
| 290 | if not ok: |
| 291 | self.fail(msg, path) |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 292 | self._expected_file_globs.add(path) |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 293 | return ok |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 294 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 295 | def check_executable(self, filename): |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 296 | path = 'bin/%s' % filename |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 297 | if not self.check_file(path): |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 298 | return |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 299 | if not self._provider.get(path).is_exec: |
| 300 | self.fail('%s is not executable', path) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 301 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 302 | def check_executable_symlink(self, filename): |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 303 | path = 'bin/%s' % filename |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 304 | fs_object = self._provider.get(path) |
| 305 | if fs_object is None: |
| 306 | self.fail('Could not find %s', path) |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 307 | return |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 308 | if fs_object.is_dir: |
| 309 | self.fail('%s is a directory', path) |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 310 | return |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 311 | if not fs_object.is_symlink: |
| 312 | self.fail('%s is not a symlink', path) |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 313 | self._expected_file_globs.add(path) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 314 | |
Ulyana Trafimovich | 7a20cbd | 2019-11-08 11:27:31 +0000 | [diff] [blame] | 315 | def arch_dirs_for_path(self, path): |
| 316 | # Look for target-specific subdirectories for the given directory path. |
| 317 | # This is needed because the list of build targets is not propagated |
| 318 | # to this script. |
Ulyana Trafimovich | 0f7c792 | 2019-11-07 16:12:09 +0000 | [diff] [blame] | 319 | # |
Roland Levillain | 4813618 | 2019-11-15 13:39:03 +0000 | [diff] [blame] | 320 | # TODO(b/123602136): Pass build target information to this script and fix |
| 321 | # all places where this function in used (or similar workarounds). |
Ulyana Trafimovich | 7a20cbd | 2019-11-08 11:27:31 +0000 | [diff] [blame] | 322 | dirs = [] |
Ulyana Trafimovich | 0f7c792 | 2019-11-07 16:12:09 +0000 | [diff] [blame] | 323 | for arch in ARCHS: |
Ulyana Trafimovich | 7a20cbd | 2019-11-08 11:27:31 +0000 | [diff] [blame] | 324 | dir = '%s/%s' % (path, arch) |
| 325 | found, _ = self.is_dir(dir) |
| 326 | if found: |
| 327 | dirs.append(dir) |
| 328 | return dirs |
| 329 | |
| 330 | def check_art_test_executable(self, filename): |
| 331 | dirs = self.arch_dirs_for_path(ART_TEST_DIR) |
| 332 | if not dirs: |
Roland Levillain | 61f0716 | 2019-06-26 12:44:04 +0100 | [diff] [blame] | 333 | self.fail('ART test binary missing: %s', filename) |
Ulyana Trafimovich | 7a20cbd | 2019-11-08 11:27:31 +0000 | [diff] [blame] | 334 | for dir in dirs: |
| 335 | test_path = '%s/%s' % (dir, filename) |
| 336 | self._expected_file_globs.add(test_path) |
| 337 | if not self._provider.get(test_path).is_exec: |
| 338 | self.fail('%s is not executable', test_path) |
Roland Levillain | 61f0716 | 2019-06-26 12:44:04 +0100 | [diff] [blame] | 339 | |
David Srbecky | 4a88a5a | 2020-05-05 16:21:57 +0100 | [diff] [blame] | 340 | def check_art_test_data(self, filename): |
| 341 | dirs = self.arch_dirs_for_path(ART_TEST_DIR) |
| 342 | if not dirs: |
| 343 | self.fail('ART test data missing: %s', filename) |
| 344 | for dir in dirs: |
| 345 | if not self.check_file('%s/%s' % (dir, filename)): |
| 346 | return |
| 347 | |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 348 | def check_single_library(self, filename): |
| 349 | lib_path = 'lib/%s' % filename |
| 350 | lib64_path = 'lib64/%s' % filename |
| 351 | lib_is_file, _ = self.is_file(lib_path) |
| 352 | if lib_is_file: |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 353 | self._expected_file_globs.add(lib_path) |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 354 | lib64_is_file, _ = self.is_file(lib64_path) |
| 355 | if lib64_is_file: |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 356 | self._expected_file_globs.add(lib64_path) |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 357 | if not lib_is_file and not lib64_is_file: |
| 358 | self.fail('Library missing: %s', filename) |
Andreas Gampe | a0242cf | 2019-01-29 13:01:23 -0800 | [diff] [blame] | 359 | |
Ulyana Trafimovich | 7a20cbd | 2019-11-08 11:27:31 +0000 | [diff] [blame] | 360 | def check_dexpreopt(self, basename): |
| 361 | dirs = self.arch_dirs_for_path('javalib') |
Ulyana Trafimovich | 7a20cbd | 2019-11-08 11:27:31 +0000 | [diff] [blame] | 362 | for dir in dirs: |
Tim Joines | be50bc3 | 2020-03-18 18:00:41 +0000 | [diff] [blame] | 363 | for ext in ['art', 'oat', 'vdex']: |
Ulyana Trafimovich | 7a20cbd | 2019-11-08 11:27:31 +0000 | [diff] [blame] | 364 | self.check_file('%s/%s.%s' % (dir, basename, ext)) |
| 365 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 366 | def check_java_library(self, basename): |
| 367 | return self.check_file('javalib/%s.jar' % basename) |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 368 | |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 369 | def ignore_path(self, path_glob): |
| 370 | self._expected_file_globs.add(path_glob) |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 371 | |
Roland Levillain | 61f0716 | 2019-06-26 12:44:04 +0100 | [diff] [blame] | 372 | def check_optional_art_test_executable(self, filename): |
Orion Hodson | af3ed62 | 2019-10-03 16:30:54 +0100 | [diff] [blame] | 373 | for arch in ARCHS: |
| 374 | self.ignore_path('%s/%s/%s' % (ART_TEST_DIR, arch, filename)) |
Roland Levillain | 61f0716 | 2019-06-26 12:44:04 +0100 | [diff] [blame] | 375 | |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 376 | def check_no_superfluous_files(self, dir_path): |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 377 | paths = [] |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 378 | for name in sorted(self._provider.read_dir(dir_path).keys()): |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 379 | if name not in ('.', '..'): |
| 380 | paths.append(os.path.join(dir_path, name)) |
| 381 | expected_paths = set() |
| 382 | dir_prefix = dir_path + '/' |
| 383 | for path_glob in self._expected_file_globs: |
| 384 | expected_paths |= set(fnmatch.filter(paths, path_glob)) |
| 385 | # If there are globs in subdirectories of dir_path we want to match their |
| 386 | # path segments at this directory level. |
| 387 | if path_glob.startswith(dir_prefix): |
| 388 | subpath = path_glob[len(dir_prefix):] |
| 389 | subpath_first_segment, _, _ = subpath.partition('/') |
| 390 | expected_paths |= set(fnmatch.filter(paths, dir_prefix + subpath_first_segment)) |
| 391 | for unexpected_path in set(paths) - expected_paths: |
| 392 | self.fail('Unexpected file \'%s\'', unexpected_path) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 393 | |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 394 | # Just here for docs purposes, even if it isn't good Python style. |
| 395 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 396 | def check_symlinked_multilib_executable(self, filename): |
| 397 | """Check bin/filename32, and/or bin/filename64, with symlink bin/filename.""" |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 398 | raise NotImplementedError |
| 399 | |
Nicolas Geoffray | d68580e | 2020-04-15 16:52:32 +0100 | [diff] [blame] | 400 | def check_symlinked_first_executable(self, filename): |
| 401 | """Check bin/filename32, and/or bin/filename64, with symlink bin/filename.""" |
| 402 | raise NotImplementedError |
| 403 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 404 | def check_multilib_executable(self, filename): |
| 405 | """Check bin/filename for 32 bit, and/or bin/filename64.""" |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 406 | raise NotImplementedError |
| 407 | |
Nicolas Geoffray | d68580e | 2020-04-15 16:52:32 +0100 | [diff] [blame] | 408 | def check_first_executable(self, filename): |
| 409 | """Check bin/filename for 32 bit, and/or bin/filename64.""" |
| 410 | raise NotImplementedError |
| 411 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 412 | def check_native_library(self, basename): |
| 413 | """Check lib/basename.so, and/or lib64/basename.so.""" |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 414 | raise NotImplementedError |
| 415 | |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 416 | def check_optional_native_library(self, basename_glob): |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 417 | """Allow lib/basename.so and/or lib64/basename.so to exist.""" |
Martin Stjernholm | b81fe23 | 2019-03-25 17:38:04 +0000 | [diff] [blame] | 418 | raise NotImplementedError |
| 419 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 420 | def check_prefer64_library(self, basename): |
| 421 | """Check lib64/basename.so, or lib/basename.so on 32 bit only.""" |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 422 | raise NotImplementedError |
| 423 | |
| 424 | |
| 425 | class Arch32Checker(Checker): |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 426 | def check_symlinked_multilib_executable(self, filename): |
| 427 | self.check_executable('%s32' % filename) |
| 428 | self.check_executable_symlink(filename) |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 429 | |
Nicolas Geoffray | d68580e | 2020-04-15 16:52:32 +0100 | [diff] [blame] | 430 | def check_symlinked_first_executable(self, filename): |
| 431 | self.check_executable('%s32' % filename) |
| 432 | self.check_executable_symlink(filename) |
| 433 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 434 | def check_multilib_executable(self, filename): |
Nicolas Geoffray | d68580e | 2020-04-15 16:52:32 +0100 | [diff] [blame] | 435 | self.check_executable('%s32' % filename) |
| 436 | |
| 437 | def check_first_executable(self, filename): |
| 438 | self.check_executable('%s32' % filename) |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 439 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 440 | def check_native_library(self, basename): |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 441 | # TODO: Use $TARGET_ARCH (e.g. check whether it is "arm" or "arm64") to improve |
| 442 | # the precision of this test? |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 443 | self.check_file('lib/%s.so' % basename) |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 444 | |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 445 | def check_optional_native_library(self, basename_glob): |
| 446 | self.ignore_path('lib/%s.so' % basename_glob) |
Martin Stjernholm | b81fe23 | 2019-03-25 17:38:04 +0000 | [diff] [blame] | 447 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 448 | def check_prefer64_library(self, basename): |
| 449 | self.check_native_library(basename) |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 450 | |
| 451 | |
| 452 | class Arch64Checker(Checker): |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 453 | def check_symlinked_multilib_executable(self, filename): |
| 454 | self.check_executable('%s64' % filename) |
| 455 | self.check_executable_symlink(filename) |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 456 | |
Nicolas Geoffray | d68580e | 2020-04-15 16:52:32 +0100 | [diff] [blame] | 457 | def check_symlinked_first_executable(self, filename): |
| 458 | self.check_executable('%s64' % filename) |
| 459 | self.check_executable_symlink(filename) |
| 460 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 461 | def check_multilib_executable(self, filename): |
| 462 | self.check_executable('%s64' % filename) |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 463 | |
Nicolas Geoffray | d68580e | 2020-04-15 16:52:32 +0100 | [diff] [blame] | 464 | def check_first_executable(self, filename): |
| 465 | self.check_executable('%s64' % filename) |
| 466 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 467 | def check_native_library(self, basename): |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 468 | # TODO: Use $TARGET_ARCH (e.g. check whether it is "arm" or "arm64") to improve |
| 469 | # the precision of this test? |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 470 | self.check_file('lib64/%s.so' % basename) |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 471 | |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 472 | def check_optional_native_library(self, basename_glob): |
| 473 | self.ignore_path('lib64/%s.so' % basename_glob) |
Martin Stjernholm | b81fe23 | 2019-03-25 17:38:04 +0000 | [diff] [blame] | 474 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 475 | def check_prefer64_library(self, basename): |
| 476 | self.check_native_library(basename) |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 477 | |
| 478 | |
| 479 | class MultilibChecker(Checker): |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 480 | def check_symlinked_multilib_executable(self, filename): |
| 481 | self.check_executable('%s32' % filename) |
| 482 | self.check_executable('%s64' % filename) |
| 483 | self.check_executable_symlink(filename) |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 484 | |
Nicolas Geoffray | d68580e | 2020-04-15 16:52:32 +0100 | [diff] [blame] | 485 | def check_symlinked_first_executable(self, filename): |
| 486 | self.check_executable('%s64' % filename) |
| 487 | self.check_executable_symlink(filename) |
| 488 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 489 | def check_multilib_executable(self, filename): |
| 490 | self.check_executable('%s64' % filename) |
Nicolas Geoffray | d68580e | 2020-04-15 16:52:32 +0100 | [diff] [blame] | 491 | self.check_executable('%s32' % filename) |
| 492 | |
| 493 | def check_first_executable(self, filename): |
| 494 | self.check_executable('%s64' % filename) |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 495 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 496 | def check_native_library(self, basename): |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 497 | # TODO: Use $TARGET_ARCH (e.g. check whether it is "arm" or "arm64") to improve |
| 498 | # the precision of this test? |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 499 | self.check_file('lib/%s.so' % basename) |
| 500 | self.check_file('lib64/%s.so' % basename) |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 501 | |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 502 | def check_optional_native_library(self, basename_glob): |
| 503 | self.ignore_path('lib/%s.so' % basename_glob) |
| 504 | self.ignore_path('lib64/%s.so' % basename_glob) |
Martin Stjernholm | b81fe23 | 2019-03-25 17:38:04 +0000 | [diff] [blame] | 505 | |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 506 | def check_prefer64_library(self, basename): |
| 507 | self.check_file('lib64/%s.so' % basename) |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 508 | |
| 509 | |
Andreas Gampe | 9dc4b05 | 2019-01-30 13:47:25 -0800 | [diff] [blame] | 510 | class ReleaseChecker: |
| 511 | def __init__(self, checker): |
| 512 | self._checker = checker |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 513 | |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 514 | def __str__(self): |
| 515 | return 'Release Checker' |
| 516 | |
| 517 | def run(self): |
Roland Levillain | df66de0 | 2019-11-11 23:22:15 +0000 | [diff] [blame] | 518 | # Check the Protocol Buffers APEX manifest. |
| 519 | self._checker.check_file('apex_manifest.pb') |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 520 | |
Martin Stjernholm | 77f1766 | 2019-04-03 17:08:21 +0100 | [diff] [blame] | 521 | # Check binaries for ART. |
Nicolas Geoffray | d68580e | 2020-04-15 16:52:32 +0100 | [diff] [blame] | 522 | self._checker.check_first_executable('dex2oat') |
Martin Stjernholm | 77f1766 | 2019-04-03 17:08:21 +0100 | [diff] [blame] | 523 | self._checker.check_executable('dexdump') |
| 524 | self._checker.check_executable('dexlist') |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 525 | self._checker.check_executable('dexoptanalyzer') |
| 526 | self._checker.check_executable('profman') |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 527 | self._checker.check_symlinked_multilib_executable('dalvikvm') |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 528 | |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 529 | # Check exported libraries for ART. |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 530 | self._checker.check_native_library('libdexfile_external') |
| 531 | self._checker.check_native_library('libnativebridge') |
| 532 | self._checker.check_native_library('libnativehelper') |
| 533 | self._checker.check_native_library('libnativeloader') |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 534 | |
| 535 | # Check internal libraries for ART. |
| 536 | self._checker.check_native_library('libadbconnection') |
| 537 | self._checker.check_native_library('libart') |
| 538 | self._checker.check_native_library('libart-compiler') |
| 539 | self._checker.check_native_library('libart-dexlayout') |
Roland Levillain | 5b76889 | 2020-02-19 15:49:02 +0000 | [diff] [blame] | 540 | self._checker.check_native_library('libart-disassembler') |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 541 | self._checker.check_native_library('libartbase') |
| 542 | self._checker.check_native_library('libartpalette') |
| 543 | self._checker.check_native_library('libdexfile') |
| 544 | self._checker.check_native_library('libdexfile_support') |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 545 | self._checker.check_native_library('libopenjdkjvm') |
| 546 | self._checker.check_native_library('libopenjdkjvmti') |
| 547 | self._checker.check_native_library('libprofile') |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 548 | self._checker.check_native_library('libsigchain') |
| 549 | |
| 550 | # Check java libraries for Managed Core Library. |
| 551 | self._checker.check_java_library('apache-xml') |
| 552 | self._checker.check_java_library('bouncycastle') |
| 553 | self._checker.check_java_library('core-libart') |
| 554 | self._checker.check_java_library('core-oj') |
| 555 | self._checker.check_java_library('okhttp') |
Ulya Trafimovich | 7b0df59 | 2020-01-03 13:29:00 +0000 | [diff] [blame] | 556 | if isEnvTrue('EMMA_INSTRUMENT_FRAMEWORK'): |
| 557 | # In coverage builds jacoco is added to the list of ART apex jars. |
| 558 | self._checker.check_java_library('jacocoagent') |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 559 | |
| 560 | # Check internal native libraries for Managed Core Library. |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 561 | self._checker.check_native_library('libjavacore') |
| 562 | self._checker.check_native_library('libopenjdk') |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 563 | |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 564 | # Check internal native library dependencies. |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 565 | # |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 566 | # Any internal dependency not listed here will cause a failure in |
| 567 | # NoSuperfluousLibrariesChecker. Internal dependencies are generally just |
| 568 | # implementation details, but in the release package we want to track them |
| 569 | # because a) they add to the package size and the RAM usage (in particular |
| 570 | # if the library is also present in /system or another APEX and hence might |
| 571 | # get loaded twice through linker namespace separation), and b) we need to |
| 572 | # catch invalid dependencies on /system or other APEXes that should go |
| 573 | # through an exported library with stubs (b/128708192 tracks implementing a |
| 574 | # better approach for that). |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 575 | self._checker.check_native_library('libbacktrace') |
| 576 | self._checker.check_native_library('libbase') |
| 577 | self._checker.check_native_library('libc++') |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 578 | self._checker.check_native_library('libdt_fd_forward') |
| 579 | self._checker.check_native_library('libdt_socket') |
| 580 | self._checker.check_native_library('libjdwp') |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 581 | self._checker.check_native_library('liblzma') |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 582 | self._checker.check_native_library('libnpt') |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 583 | self._checker.check_native_library('libunwindstack') |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 584 | self._checker.check_native_library('libziparchive') |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 585 | self._checker.check_optional_native_library('libvixl') # Only on ARM/ARM64 |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 586 | |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 587 | # Allow extra dependencies that appear in ASAN builds. |
| 588 | self._checker.check_optional_native_library('libclang_rt.asan*') |
| 589 | self._checker.check_optional_native_library('libclang_rt.hwasan*') |
| 590 | self._checker.check_optional_native_library('libclang_rt.ubsan*') |
| 591 | |
Ulya Trafimovich | 7b0df59 | 2020-01-03 13:29:00 +0000 | [diff] [blame] | 592 | # Check dexpreopt files for libcore bootclasspath jars. |
| 593 | self._checker.check_dexpreopt('boot') |
| 594 | self._checker.check_dexpreopt('boot-apache-xml') |
| 595 | self._checker.check_dexpreopt('boot-bouncycastle') |
Ulya Trafimovich | 7b0df59 | 2020-01-03 13:29:00 +0000 | [diff] [blame] | 596 | self._checker.check_dexpreopt('boot-core-libart') |
| 597 | self._checker.check_dexpreopt('boot-okhttp') |
| 598 | if isEnvTrue('EMMA_INSTRUMENT_FRAMEWORK'): |
| 599 | # In coverage builds the ART boot image includes jacoco. |
| 600 | self._checker.check_dexpreopt('boot-jacocoagent') |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 601 | |
Andreas Gampe | 9dc4b05 | 2019-01-30 13:47:25 -0800 | [diff] [blame] | 602 | class ReleaseTargetChecker: |
| 603 | def __init__(self, checker): |
| 604 | self._checker = checker |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 605 | |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 606 | def __str__(self): |
| 607 | return 'Release (Target) Checker' |
| 608 | |
| 609 | def run(self): |
Roland Levillain | df66de0 | 2019-11-11 23:22:15 +0000 | [diff] [blame] | 610 | # We don't check for the presence of the JSON APEX manifest (file |
| 611 | # `apex_manifest.json`, only present in target APEXes), as it is only |
| 612 | # included for compatibility reasons with Android Q and will likely be |
| 613 | # removed in Android R. |
| 614 | |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 615 | # Check binaries for ART. |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 616 | self._checker.check_executable('oatdump') |
Nicolas Geoffray | d68580e | 2020-04-15 16:52:32 +0100 | [diff] [blame] | 617 | self._checker.check_multilib_executable('dex2oat') |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 618 | |
| 619 | # Check internal libraries for ART. |
| 620 | self._checker.check_prefer64_library('libart-disassembler') |
Florian Mayer | 07710c5 | 2019-09-16 15:53:38 +0000 | [diff] [blame] | 621 | self._checker.check_native_library('libperfetto_hprof') |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 622 | |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 623 | # Check exported native libraries for Managed Core Library. |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 624 | self._checker.check_native_library('libandroidio') |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 625 | |
| 626 | # Check internal native library dependencies. |
| 627 | self._checker.check_native_library('libcrypto') |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 628 | self._checker.check_native_library('libexpat') |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 629 | |
Martin Stjernholm | ec2db5f | 2019-09-04 20:54:57 +0100 | [diff] [blame] | 630 | # TODO(b/139046641): Fix proper 2nd arch checks. For now, just ignore these |
| 631 | # directories. |
| 632 | self._checker.ignore_path('bin/arm') |
| 633 | self._checker.ignore_path('lib/arm') |
| 634 | self._checker.ignore_path('lib64/arm') |
| 635 | |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 636 | |
Andreas Gampe | 9dc4b05 | 2019-01-30 13:47:25 -0800 | [diff] [blame] | 637 | class ReleaseHostChecker: |
| 638 | def __init__(self, checker): |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 639 | self._checker = checker |
| 640 | |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 641 | def __str__(self): |
| 642 | return 'Release (Host) Checker' |
| 643 | |
| 644 | def run(self): |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 645 | # Check binaries for ART. |
| 646 | self._checker.check_executable('hprof-conv') |
Nicolas Geoffray | d68580e | 2020-04-15 16:52:32 +0100 | [diff] [blame] | 647 | self._checker.check_symlinked_first_executable('dex2oatd') |
| 648 | self._checker.check_symlinked_first_executable('dex2oat') |
Martin Stjernholm | 84a32cd | 2019-03-29 16:39:46 +0000 | [diff] [blame] | 649 | |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 650 | # Check exported native libraries for Managed Core Library. |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 651 | self._checker.check_native_library('libandroidicu-host') |
| 652 | self._checker.check_native_library('libandroidio') |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 653 | |
| 654 | # Check internal libraries for Managed Core Library. |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 655 | self._checker.check_native_library('libexpat-host') |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 656 | self._checker.check_native_library('libz-host') |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 657 | |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 658 | |
Andreas Gampe | 9dc4b05 | 2019-01-30 13:47:25 -0800 | [diff] [blame] | 659 | class DebugChecker: |
| 660 | def __init__(self, checker): |
| 661 | self._checker = checker |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 662 | |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 663 | def __str__(self): |
| 664 | return 'Debug Checker' |
| 665 | |
| 666 | def run(self): |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 667 | # Check binaries for ART. |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 668 | self._checker.check_executable('dexdiag') |
Roland Levillain | 6dd6212 | 2019-06-18 19:10:21 +0100 | [diff] [blame] | 669 | self._checker.check_executable('dexanalyze') |
| 670 | self._checker.check_executable('dexlayout') |
| 671 | self._checker.check_symlinked_multilib_executable('imgdiag') |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 672 | |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 673 | # Check debug binaries for ART. |
Roland Levillain | 6dd6212 | 2019-06-18 19:10:21 +0100 | [diff] [blame] | 674 | self._checker.check_executable('dexlayoutd') |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 675 | self._checker.check_executable('dexoptanalyzerd') |
Roland Levillain | 6dd6212 | 2019-06-18 19:10:21 +0100 | [diff] [blame] | 676 | self._checker.check_symlinked_multilib_executable('imgdiagd') |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 677 | self._checker.check_executable('profmand') |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 678 | |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 679 | # Check internal libraries for ART. |
| 680 | self._checker.check_native_library('libadbconnectiond') |
Roland Levillain | 4d6f24d | 2019-10-02 16:47:36 +0100 | [diff] [blame] | 681 | self._checker.check_native_library('libart-disassembler') |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 682 | self._checker.check_native_library('libartbased') |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 683 | self._checker.check_native_library('libartd') |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 684 | self._checker.check_native_library('libartd-compiler') |
| 685 | self._checker.check_native_library('libartd-dexlayout') |
Roland Levillain | 4d6f24d | 2019-10-02 16:47:36 +0100 | [diff] [blame] | 686 | self._checker.check_native_library('libartd-disassembler') |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 687 | self._checker.check_native_library('libdexfiled') |
| 688 | self._checker.check_native_library('libopenjdkjvmd') |
| 689 | self._checker.check_native_library('libopenjdkjvmtid') |
| 690 | self._checker.check_native_library('libprofiled') |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 691 | |
| 692 | # Check internal libraries for Managed Core Library. |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 693 | self._checker.check_native_library('libopenjdkd') |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 694 | |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 695 | |
Andreas Gampe | 9dc4b05 | 2019-01-30 13:47:25 -0800 | [diff] [blame] | 696 | class DebugTargetChecker: |
| 697 | def __init__(self, checker): |
| 698 | self._checker = checker |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 699 | |
Andreas Gampe | a0242cf | 2019-01-29 13:01:23 -0800 | [diff] [blame] | 700 | def __str__(self): |
| 701 | return 'Debug (Target) Checker' |
| 702 | |
| 703 | def run(self): |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 704 | # Check ART debug binaries. |
Nicolas Geoffray | d68580e | 2020-04-15 16:52:32 +0100 | [diff] [blame] | 705 | self._checker.check_multilib_executable('dex2oatd') |
| 706 | self._checker.check_multilib_executable('dex2oat') |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 707 | self._checker.check_executable('oatdumpd') |
Martin Stjernholm | 023c218 | 2019-03-28 15:52:32 +0000 | [diff] [blame] | 708 | |
| 709 | # Check ART internal libraries. |
Martin Stjernholm | 356864a | 2019-04-30 16:22:17 +0100 | [diff] [blame] | 710 | self._checker.check_native_library('libdexfiled_external') |
Florian Mayer | 07710c5 | 2019-09-16 15:53:38 +0000 | [diff] [blame] | 711 | self._checker.check_native_library('libperfetto_hprofd') |
Andreas Gampe | a0242cf | 2019-01-29 13:01:23 -0800 | [diff] [blame] | 712 | |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 713 | # Check internal native library dependencies. |
| 714 | # |
| 715 | # Like in the release package, we check that we don't get other dependencies |
| 716 | # besides those listed here. In this case the concern is not bloat, but |
| 717 | # rather that we don't get behavioural differences between user (release) |
| 718 | # and userdebug/eng builds, which could happen if the debug package has |
| 719 | # duplicate library instances where releases don't. In other words, it's |
| 720 | # uncontroversial to add debug-only dependencies, as long as they don't make |
| 721 | # assumptions on having a single global state (ideally they should have |
| 722 | # double_loadable:true, cf. go/double_loadable). Also, like in the release |
| 723 | # package we need to look out for dependencies that should go through |
| 724 | # exported library stubs (until b/128708192 is fixed). |
Martin Stjernholm | c17ace2 | 2019-03-18 21:47:31 +0000 | [diff] [blame] | 725 | self._checker.check_optional_native_library('libvixld') # Only on ARM/ARM64 |
Martin Stjernholm | 77f1766 | 2019-04-03 17:08:21 +0100 | [diff] [blame] | 726 | self._checker.check_prefer64_library('libmeminfo') |
| 727 | self._checker.check_prefer64_library('libprocinfo') |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 728 | |
| 729 | |
Roland Levillain | 61f0716 | 2019-06-26 12:44:04 +0100 | [diff] [blame] | 730 | class TestingTargetChecker: |
| 731 | def __init__(self, checker): |
| 732 | self._checker = checker |
| 733 | |
| 734 | def __str__(self): |
| 735 | return 'Testing (Target) Checker' |
| 736 | |
| 737 | def run(self): |
David Srbecky | 883c134 | 2020-05-11 23:30:29 +0000 | [diff] [blame] | 738 | # Check ART test binaries. |
| 739 | self._checker.check_art_test_executable('art_cmdline_tests') |
| 740 | self._checker.check_art_test_executable('art_compiler_tests') |
| 741 | self._checker.check_art_test_executable('art_dex2oat_tests') |
| 742 | self._checker.check_art_test_executable('art_dexanalyze_tests') |
| 743 | self._checker.check_art_test_executable('art_dexdiag_tests') |
| 744 | self._checker.check_art_test_executable('art_dexdump_tests') |
| 745 | self._checker.check_art_test_executable('art_dexlayout_tests') |
| 746 | self._checker.check_art_test_executable('art_dexlist_tests') |
| 747 | self._checker.check_art_test_executable('art_dexoptanalyzer_tests') |
| 748 | self._checker.check_art_test_executable('art_imgdiag_tests') |
| 749 | self._checker.check_art_test_executable('art_libartbase_tests') |
| 750 | self._checker.check_art_test_executable('art_libartpalette_tests') |
Roland Levillain | 61f0716 | 2019-06-26 12:44:04 +0100 | [diff] [blame] | 751 | self._checker.check_art_test_executable('art_libdexfile_support_tests') |
David Srbecky | 883c134 | 2020-05-11 23:30:29 +0000 | [diff] [blame] | 752 | self._checker.check_art_test_executable('art_libdexfile_tests') |
| 753 | self._checker.check_art_test_executable('art_libprofile_tests') |
| 754 | self._checker.check_art_test_executable('art_oatdump_tests') |
| 755 | self._checker.check_art_test_executable('art_profman_tests') |
| 756 | self._checker.check_art_test_executable('art_runtime_compiler_tests') |
| 757 | self._checker.check_art_test_executable('art_runtime_tests') |
| 758 | self._checker.check_art_test_executable('art_sigchain_tests') |
Roland Levillain | 61f0716 | 2019-06-26 12:44:04 +0100 | [diff] [blame] | 759 | |
| 760 | # Check ART test (internal) libraries. |
| 761 | self._checker.check_native_library('libart-gtest') |
Ulyana Trafimovich | 3060bb9 | 2020-07-16 14:17:11 +0000 | [diff] [blame^] | 762 | self._checker.check_native_library('libartd-simulator-container') |
Roland Levillain | 61f0716 | 2019-06-26 12:44:04 +0100 | [diff] [blame] | 763 | |
Andreas Gampe | 816a552 | 2019-09-11 11:29:49 -0700 | [diff] [blame] | 764 | # Check ART test tools. |
| 765 | self._checker.check_executable('signal_dumper') |
| 766 | |
David Srbecky | 4a88a5a | 2020-05-05 16:21:57 +0100 | [diff] [blame] | 767 | # Check ART jar files which are needed for gtests. |
| 768 | self._checker.check_art_test_data('art-gtest-jars-AbstractMethod.jar') |
| 769 | self._checker.check_art_test_data('art-gtest-jars-MyClassNatives.jar') |
| 770 | self._checker.check_art_test_data('art-gtest-jars-Main.jar') |
| 771 | self._checker.check_art_test_data('art-gtest-jars-ProtoCompare.jar') |
| 772 | self._checker.check_art_test_data('art-gtest-jars-Transaction.jar') |
David Srbecky | edda3ca | 2020-07-08 00:41:08 +0100 | [diff] [blame] | 773 | self._checker.check_art_test_data('art-gtest-jars-VerifierDepsMulti.dex') |
David Srbecky | 4a88a5a | 2020-05-05 16:21:57 +0100 | [diff] [blame] | 774 | self._checker.check_art_test_data('art-gtest-jars-Nested.jar') |
| 775 | self._checker.check_art_test_data('art-gtest-jars-MyClass.jar') |
| 776 | self._checker.check_art_test_data('art-gtest-jars-ManyMethods.jar') |
| 777 | self._checker.check_art_test_data('art-gtest-jars-GetMethodSignature.jar') |
| 778 | self._checker.check_art_test_data('art-gtest-jars-Lookup.jar') |
| 779 | self._checker.check_art_test_data('art-gtest-jars-Instrumentation.jar') |
| 780 | self._checker.check_art_test_data('art-gtest-jars-MainUncompressedAligned.jar') |
| 781 | self._checker.check_art_test_data('art-gtest-jars-ForClassLoaderD.jar') |
| 782 | self._checker.check_art_test_data('art-gtest-jars-ForClassLoaderC.jar') |
| 783 | self._checker.check_art_test_data('art-gtest-jars-ErroneousA.jar') |
| 784 | self._checker.check_art_test_data('art-gtest-jars-DexToDexDecompiler.jar') |
| 785 | self._checker.check_art_test_data('art-gtest-jars-HiddenApiSignatures.jar') |
| 786 | self._checker.check_art_test_data('art-gtest-jars-ForClassLoaderB.jar') |
David Srbecky | edda3ca | 2020-07-08 00:41:08 +0100 | [diff] [blame] | 787 | self._checker.check_art_test_data('art-gtest-jars-LinkageTest.dex') |
David Srbecky | 4a88a5a | 2020-05-05 16:21:57 +0100 | [diff] [blame] | 788 | self._checker.check_art_test_data('art-gtest-jars-MethodTypes.jar') |
| 789 | self._checker.check_art_test_data('art-gtest-jars-ErroneousInit.jar') |
David Srbecky | edda3ca | 2020-07-08 00:41:08 +0100 | [diff] [blame] | 790 | self._checker.check_art_test_data('art-gtest-jars-VerifierDeps.dex') |
David Srbecky | 4a88a5a | 2020-05-05 16:21:57 +0100 | [diff] [blame] | 791 | self._checker.check_art_test_data('art-gtest-jars-StringLiterals.jar') |
| 792 | self._checker.check_art_test_data('art-gtest-jars-XandY.jar') |
| 793 | self._checker.check_art_test_data('art-gtest-jars-ExceptionHandle.jar') |
| 794 | self._checker.check_art_test_data('art-gtest-jars-ImageLayoutB.jar') |
| 795 | self._checker.check_art_test_data('art-gtest-jars-Interfaces.jar') |
| 796 | self._checker.check_art_test_data('art-gtest-jars-IMTB.jar') |
| 797 | self._checker.check_art_test_data('art-gtest-jars-Extension2.jar') |
| 798 | self._checker.check_art_test_data('art-gtest-jars-Extension1.jar') |
| 799 | self._checker.check_art_test_data('art-gtest-jars-MainEmptyUncompressedAligned.jar') |
| 800 | self._checker.check_art_test_data('art-gtest-jars-ErroneousB.jar') |
| 801 | self._checker.check_art_test_data('art-gtest-jars-MultiDexModifiedSecondary.jar') |
| 802 | self._checker.check_art_test_data('art-gtest-jars-NonStaticLeafMethods.jar') |
| 803 | self._checker.check_art_test_data('art-gtest-jars-DefaultMethods.jar') |
| 804 | self._checker.check_art_test_data('art-gtest-jars-MultiDexUncompressedAligned.jar') |
| 805 | self._checker.check_art_test_data('art-gtest-jars-StaticsFromCode.jar') |
| 806 | self._checker.check_art_test_data('art-gtest-jars-ProfileTestMultiDex.jar') |
David Srbecky | edda3ca | 2020-07-08 00:41:08 +0100 | [diff] [blame] | 807 | self._checker.check_art_test_data('art-gtest-jars-VerifySoftFailDuringClinit.dex') |
David Srbecky | 4a88a5a | 2020-05-05 16:21:57 +0100 | [diff] [blame] | 808 | self._checker.check_art_test_data('art-gtest-jars-MainStripped.jar') |
| 809 | self._checker.check_art_test_data('art-gtest-jars-ForClassLoaderA.jar') |
| 810 | self._checker.check_art_test_data('art-gtest-jars-StaticLeafMethods.jar') |
| 811 | self._checker.check_art_test_data('art-gtest-jars-MultiDex.jar') |
| 812 | self._checker.check_art_test_data('art-gtest-jars-Packages.jar') |
| 813 | self._checker.check_art_test_data('art-gtest-jars-ProtoCompare2.jar') |
| 814 | self._checker.check_art_test_data('art-gtest-jars-Statics.jar') |
| 815 | self._checker.check_art_test_data('art-gtest-jars-AllFields.jar') |
| 816 | self._checker.check_art_test_data('art-gtest-jars-IMTA.jar') |
| 817 | self._checker.check_art_test_data('art-gtest-jars-ImageLayoutA.jar') |
| 818 | self._checker.check_art_test_data('art-gtest-jars-MainEmptyUncompressed.jar') |
| 819 | |
Roland Levillain | 61f0716 | 2019-06-26 12:44:04 +0100 | [diff] [blame] | 820 | |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 821 | class NoSuperfluousBinariesChecker: |
| 822 | def __init__(self, checker): |
| 823 | self._checker = checker |
| 824 | |
| 825 | def __str__(self): |
| 826 | return 'No superfluous binaries checker' |
| 827 | |
| 828 | def run(self): |
| 829 | self._checker.check_no_superfluous_files('bin') |
| 830 | |
| 831 | |
| 832 | class NoSuperfluousLibrariesChecker: |
| 833 | def __init__(self, checker): |
| 834 | self._checker = checker |
| 835 | |
| 836 | def __str__(self): |
| 837 | return 'No superfluous libraries checker' |
| 838 | |
| 839 | def run(self): |
| 840 | self._checker.check_no_superfluous_files('javalib') |
| 841 | self._checker.check_no_superfluous_files('lib') |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 842 | self._checker.check_no_superfluous_files('lib64') |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 843 | |
Andreas Gampe | b1d5567 | 2019-01-29 22:17:02 +0000 | [diff] [blame] | 844 | |
Roland Levillain | 61f0716 | 2019-06-26 12:44:04 +0100 | [diff] [blame] | 845 | class NoSuperfluousArtTestsChecker: |
| 846 | def __init__(self, checker): |
| 847 | self._checker = checker |
| 848 | |
| 849 | def __str__(self): |
| 850 | return 'No superfluous ART tests checker' |
| 851 | |
| 852 | def run(self): |
Orion Hodson | af3ed62 | 2019-10-03 16:30:54 +0100 | [diff] [blame] | 853 | for arch in ARCHS: |
| 854 | self._checker.check_no_superfluous_files('%s/%s' % (ART_TEST_DIR, arch)) |
Roland Levillain | 61f0716 | 2019-06-26 12:44:04 +0100 | [diff] [blame] | 855 | |
| 856 | |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 857 | class List: |
Roland Levillain | 77251f9 | 2019-08-09 15:00:04 +0100 | [diff] [blame] | 858 | def __init__(self, provider, print_size=False): |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 859 | self._provider = provider |
Roland Levillain | e91d787 | 2019-07-25 18:56:06 +0100 | [diff] [blame] | 860 | self._print_size = print_size |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 861 | |
| 862 | def print_list(self): |
Roland Levillain | 09744ac | 2019-06-06 18:23:02 +0100 | [diff] [blame] | 863 | |
| 864 | def print_list_rec(path): |
| 865 | apex_map = self._provider.read_dir(path) |
| 866 | if apex_map is None: |
| 867 | return |
| 868 | apex_map = dict(apex_map) |
| 869 | if '.' in apex_map: |
| 870 | del apex_map['.'] |
| 871 | if '..' in apex_map: |
| 872 | del apex_map['..'] |
| 873 | for (_, val) in sorted(apex_map.items()): |
| 874 | val_path = os.path.join(path, val.name) |
Roland Levillain | e91d787 | 2019-07-25 18:56:06 +0100 | [diff] [blame] | 875 | if self._print_size: |
| 876 | if val.size < 0: |
| 877 | print('[ n/a ] %s' % val_path) |
| 878 | else: |
| 879 | print('[%11d] %s' % (val.size, val_path)) |
| 880 | else: |
| 881 | print(val_path) |
Roland Levillain | 09744ac | 2019-06-06 18:23:02 +0100 | [diff] [blame] | 882 | if val.is_dir: |
| 883 | print_list_rec(val_path) |
| 884 | |
| 885 | print_list_rec('') |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 886 | |
| 887 | |
| 888 | class Tree: |
Roland Levillain | 77251f9 | 2019-08-09 15:00:04 +0100 | [diff] [blame] | 889 | def __init__(self, provider, title, print_size=False): |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 890 | print('%s' % title) |
| 891 | self._provider = provider |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 892 | self._has_next_list = [] |
Roland Levillain | 88e5569 | 2019-07-25 15:57:06 +0100 | [diff] [blame] | 893 | self._print_size = print_size |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 894 | |
| 895 | @staticmethod |
| 896 | def get_vertical(has_next_list): |
| 897 | string = '' |
| 898 | for v in has_next_list: |
| 899 | string += '%s ' % ('│' if v else ' ') |
| 900 | return string |
| 901 | |
| 902 | @staticmethod |
| 903 | def get_last_vertical(last): |
| 904 | return '└── ' if last else '├── ' |
| 905 | |
| 906 | def print_tree(self): |
Roland Levillain | 09744ac | 2019-06-06 18:23:02 +0100 | [diff] [blame] | 907 | |
| 908 | def print_tree_rec(path): |
| 909 | apex_map = self._provider.read_dir(path) |
| 910 | if apex_map is None: |
| 911 | return |
| 912 | apex_map = dict(apex_map) |
| 913 | if '.' in apex_map: |
| 914 | del apex_map['.'] |
| 915 | if '..' in apex_map: |
| 916 | del apex_map['..'] |
| 917 | key_list = list(sorted(apex_map.keys())) |
| 918 | for i, key in enumerate(key_list): |
| 919 | prev = self.get_vertical(self._has_next_list) |
| 920 | last = self.get_last_vertical(i == len(key_list) - 1) |
| 921 | val = apex_map[key] |
Roland Levillain | 88e5569 | 2019-07-25 15:57:06 +0100 | [diff] [blame] | 922 | if self._print_size: |
| 923 | if val.size < 0: |
| 924 | print('%s%s[ n/a ] %s' % (prev, last, val.name)) |
| 925 | else: |
| 926 | print('%s%s[%11d] %s' % (prev, last, val.size, val.name)) |
| 927 | else: |
| 928 | print('%s%s%s' % (prev, last, val.name)) |
Roland Levillain | 09744ac | 2019-06-06 18:23:02 +0100 | [diff] [blame] | 929 | if val.is_dir: |
| 930 | self._has_next_list.append(i < len(key_list) - 1) |
| 931 | val_path = os.path.join(path, val.name) |
| 932 | print_tree_rec(val_path) |
| 933 | self._has_next_list.pop() |
| 934 | |
| 935 | print_tree_rec('') |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 936 | |
Andreas Gampe | b1d5567 | 2019-01-29 22:17:02 +0000 | [diff] [blame] | 937 | |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 938 | # Note: do not sys.exit early, for __del__ cleanup. |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 939 | def art_apex_test_main(test_args): |
Roland Levillain | dd20d00 | 2019-07-19 16:09:47 +0100 | [diff] [blame] | 940 | if test_args.host and test_args.flattened: |
| 941 | logging.error("Both of --host and --flattened set") |
| 942 | return 1 |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 943 | if test_args.list and test_args.tree: |
Andreas Gampe | b1d5567 | 2019-01-29 22:17:02 +0000 | [diff] [blame] | 944 | logging.error("Both of --list and --tree set") |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 945 | return 1 |
Roland Levillain | e91d787 | 2019-07-25 18:56:06 +0100 | [diff] [blame] | 946 | if test_args.size and not (test_args.list or test_args.tree): |
| 947 | logging.error("--size set but neither --list nor --tree set") |
Roland Levillain | 88e5569 | 2019-07-25 15:57:06 +0100 | [diff] [blame] | 948 | return 1 |
Martin Stjernholm | 3cb59a4 | 2019-08-07 17:18:29 +0100 | [diff] [blame] | 949 | if not test_args.flattened and not test_args.tmpdir: |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 950 | logging.error("Need a tmpdir.") |
| 951 | return 1 |
Martin Stjernholm | 3cb59a4 | 2019-08-07 17:18:29 +0100 | [diff] [blame] | 952 | 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] | 953 | logging.error("Need debugfs.") |
| 954 | return 1 |
| 955 | |
Roland Levillain | fdbe207 | 2019-11-11 15:52:45 +0000 | [diff] [blame] | 956 | if test_args.host: |
| 957 | # Host APEX. |
| 958 | if test_args.flavor not in [FLAVOR_DEBUG, FLAVOR_AUTO]: |
| 959 | logging.error("Using option --host with non-Debug APEX") |
Roland Levillain | dbd6a14 | 2019-10-03 15:08:28 +0100 | [diff] [blame] | 960 | return 1 |
Roland Levillain | fdbe207 | 2019-11-11 15:52:45 +0000 | [diff] [blame] | 961 | # Host APEX is always a debug flavor (for now). |
| 962 | test_args.flavor = FLAVOR_DEBUG |
| 963 | else: |
| 964 | # Device APEX. |
| 965 | if test_args.flavor == FLAVOR_AUTO: |
| 966 | logging.warning('--flavor=auto, trying to autodetect. This may be incorrect!') |
| 967 | for flavor in [ FLAVOR_RELEASE, FLAVOR_DEBUG, FLAVOR_TESTING ]: |
| 968 | flavor_pattern = '*.%s*' % flavor |
| 969 | if fnmatch.fnmatch(test_args.apex, flavor_pattern): |
| 970 | test_args.flavor = flavor |
| 971 | break |
| 972 | if test_args.flavor == FLAVOR_AUTO: |
| 973 | logging.error(' Could not detect APEX flavor, neither \'%s\', \'%s\' nor \'%s\' in \'%s\'', |
| 974 | FLAVOR_RELEASE, FLAVOR_DEBUG, FLAVOR_TESTING, test_args.apex) |
| 975 | return 1 |
Roland Levillain | dbd6a14 | 2019-10-03 15:08:28 +0100 | [diff] [blame] | 976 | |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 977 | try: |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 978 | if test_args.host: |
| 979 | apex_provider = HostApexProvider(test_args.apex, test_args.tmpdir) |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 980 | else: |
Roland Levillain | dd20d00 | 2019-07-19 16:09:47 +0100 | [diff] [blame] | 981 | if test_args.flattened: |
| 982 | apex_provider = TargetFlattenedApexProvider(test_args.apex) |
| 983 | else: |
| 984 | apex_provider = TargetApexProvider(test_args.apex, test_args.tmpdir, test_args.debugfs) |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 985 | except (zipfile.BadZipFile, zipfile.LargeZipFile) as e: |
Andreas Gampe | a0242cf | 2019-01-29 13:01:23 -0800 | [diff] [blame] | 986 | logging.error('Failed to create provider: %s', e) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 987 | return 1 |
| 988 | |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 989 | if test_args.tree: |
Roland Levillain | 88e5569 | 2019-07-25 15:57:06 +0100 | [diff] [blame] | 990 | Tree(apex_provider, test_args.apex, test_args.size).print_tree() |
Andreas Gampe | b1d5567 | 2019-01-29 22:17:02 +0000 | [diff] [blame] | 991 | return 0 |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 992 | if test_args.list: |
Roland Levillain | e91d787 | 2019-07-25 18:56:06 +0100 | [diff] [blame] | 993 | List(apex_provider, test_args.size).print_list() |
Andreas Gampe | b1d5567 | 2019-01-29 22:17:02 +0000 | [diff] [blame] | 994 | return 0 |
| 995 | |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 996 | checkers = [] |
Orion Hodson | af3ed62 | 2019-10-03 16:30:54 +0100 | [diff] [blame] | 997 | if test_args.bitness == BITNESS_AUTO: |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 998 | logging.warning('--bitness=auto, trying to autodetect. This may be incorrect!') |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 999 | has_32 = apex_provider.get('lib') is not None |
| 1000 | has_64 = apex_provider.get('lib64') is not None |
| 1001 | if has_32 and has_64: |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1002 | logging.warning(' Detected multilib') |
Orion Hodson | af3ed62 | 2019-10-03 16:30:54 +0100 | [diff] [blame] | 1003 | test_args.bitness = BITNESS_MULTILIB |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 1004 | elif has_32: |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1005 | logging.warning(' Detected 32-only') |
Orion Hodson | af3ed62 | 2019-10-03 16:30:54 +0100 | [diff] [blame] | 1006 | test_args.bitness = BITNESS_32 |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 1007 | elif has_64: |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1008 | logging.warning(' Detected 64-only') |
Orion Hodson | af3ed62 | 2019-10-03 16:30:54 +0100 | [diff] [blame] | 1009 | test_args.bitness = BITNESS_64 |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 1010 | else: |
| 1011 | logging.error(' Could not detect bitness, neither lib nor lib64 contained.') |
Roland Levillain | 77251f9 | 2019-08-09 15:00:04 +0100 | [diff] [blame] | 1012 | List(apex_provider).print_list() |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 1013 | return 1 |
| 1014 | |
Orion Hodson | af3ed62 | 2019-10-03 16:30:54 +0100 | [diff] [blame] | 1015 | if test_args.bitness == BITNESS_32: |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 1016 | base_checker = Arch32Checker(apex_provider) |
Orion Hodson | af3ed62 | 2019-10-03 16:30:54 +0100 | [diff] [blame] | 1017 | elif test_args.bitness == BITNESS_64: |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 1018 | base_checker = Arch64Checker(apex_provider) |
| 1019 | else: |
Orion Hodson | af3ed62 | 2019-10-03 16:30:54 +0100 | [diff] [blame] | 1020 | assert test_args.bitness == BITNESS_MULTILIB |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 1021 | base_checker = MultilibChecker(apex_provider) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1022 | |
Andreas Gampe | 9dc4b05 | 2019-01-30 13:47:25 -0800 | [diff] [blame] | 1023 | checkers.append(ReleaseChecker(base_checker)) |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1024 | if test_args.host: |
Andreas Gampe | 9dc4b05 | 2019-01-30 13:47:25 -0800 | [diff] [blame] | 1025 | checkers.append(ReleaseHostChecker(base_checker)) |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 1026 | else: |
Andreas Gampe | 9dc4b05 | 2019-01-30 13:47:25 -0800 | [diff] [blame] | 1027 | checkers.append(ReleaseTargetChecker(base_checker)) |
Orion Hodson | af3ed62 | 2019-10-03 16:30:54 +0100 | [diff] [blame] | 1028 | if test_args.flavor == FLAVOR_DEBUG or test_args.flavor == FLAVOR_TESTING: |
Andreas Gampe | 9dc4b05 | 2019-01-30 13:47:25 -0800 | [diff] [blame] | 1029 | checkers.append(DebugChecker(base_checker)) |
Roland Levillain | 61f0716 | 2019-06-26 12:44:04 +0100 | [diff] [blame] | 1030 | if not test_args.host: |
| 1031 | checkers.append(DebugTargetChecker(base_checker)) |
Orion Hodson | af3ed62 | 2019-10-03 16:30:54 +0100 | [diff] [blame] | 1032 | if test_args.flavor == FLAVOR_TESTING: |
Roland Levillain | 61f0716 | 2019-06-26 12:44:04 +0100 | [diff] [blame] | 1033 | checkers.append(TestingTargetChecker(base_checker)) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1034 | |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 1035 | # These checkers must be last. |
| 1036 | checkers.append(NoSuperfluousBinariesChecker(base_checker)) |
Roland Levillain | 61f0716 | 2019-06-26 12:44:04 +0100 | [diff] [blame] | 1037 | checkers.append(NoSuperfluousArtTestsChecker(base_checker)) |
Martin Stjernholm | 2babede | 2019-03-18 21:04:49 +0000 | [diff] [blame] | 1038 | if not test_args.host: |
| 1039 | # We only care about superfluous libraries on target, where their absence |
| 1040 | # can be vital to ensure they get picked up from the right package. |
| 1041 | checkers.append(NoSuperfluousLibrariesChecker(base_checker)) |
| 1042 | |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1043 | failed = False |
| 1044 | for checker in checkers: |
| 1045 | logging.info('%s...', checker) |
| 1046 | checker.run() |
Andreas Gampe | 9dc4b05 | 2019-01-30 13:47:25 -0800 | [diff] [blame] | 1047 | if base_checker.error_count() > 0: |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1048 | logging.error('%s FAILED', checker) |
| 1049 | failed = True |
| 1050 | else: |
| 1051 | logging.info('%s SUCCEEDED', checker) |
Andreas Gampe | 9dc4b05 | 2019-01-30 13:47:25 -0800 | [diff] [blame] | 1052 | base_checker.reset_errors() |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1053 | |
| 1054 | return 1 if failed else 0 |
| 1055 | |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1056 | |
| 1057 | def art_apex_test_default(test_parser): |
| 1058 | if 'ANDROID_PRODUCT_OUT' not in os.environ: |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1059 | logging.error('No-argument use requires ANDROID_PRODUCT_OUT') |
| 1060 | sys.exit(1) |
| 1061 | product_out = os.environ['ANDROID_PRODUCT_OUT'] |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1062 | if 'ANDROID_HOST_OUT' not in os.environ: |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1063 | logging.error('No-argument use requires ANDROID_HOST_OUT') |
| 1064 | sys.exit(1) |
| 1065 | host_out = os.environ['ANDROID_HOST_OUT'] |
| 1066 | |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1067 | test_args = test_parser.parse_args(['dummy']) # For consistency. |
| 1068 | test_args.debugfs = '%s/bin/debugfs' % host_out |
| 1069 | test_args.tmpdir = '.' |
| 1070 | test_args.tree = False |
| 1071 | test_args.list = False |
Orion Hodson | af3ed62 | 2019-10-03 16:30:54 +0100 | [diff] [blame] | 1072 | test_args.bitness = BITNESS_AUTO |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1073 | failed = False |
| 1074 | |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1075 | if not os.path.exists(test_args.debugfs): |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1076 | 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] | 1077 | test_args.debugfs) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1078 | sys.exit(1) |
| 1079 | |
Roland Levillain | d7ea043 | 2019-09-09 16:29:12 +0100 | [diff] [blame] | 1080 | # TODO: Add host support. |
| 1081 | # TODO: Add support for flattened APEX packages. |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1082 | configs = [ |
Orion Hodson | af3ed62 | 2019-10-03 16:30:54 +0100 | [diff] [blame] | 1083 | {'name': 'com.android.art.release', 'flavor': FLAVOR_RELEASE, 'host': False}, |
| 1084 | {'name': 'com.android.art.debug', 'flavor': FLAVOR_DEBUG, 'host': False}, |
| 1085 | {'name': 'com.android.art.testing', 'flavor': FLAVOR_TESTING, 'host': False}, |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1086 | ] |
| 1087 | |
| 1088 | for config in configs: |
| 1089 | logging.info(config['name']) |
| 1090 | # TODO: Host will need different path. |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1091 | test_args.apex = '%s/system/apex/%s.apex' % (product_out, config['name']) |
| 1092 | if not os.path.exists(test_args.apex): |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1093 | failed = True |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1094 | 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] | 1095 | continue |
Roland Levillain | d7ea043 | 2019-09-09 16:29:12 +0100 | [diff] [blame] | 1096 | test_args.flavor = config['flavor'] |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1097 | test_args.host = config['host'] |
| 1098 | failed = art_apex_test_main(test_args) != 0 |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1099 | |
| 1100 | if failed: |
| 1101 | sys.exit(1) |
| 1102 | |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1103 | |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1104 | if __name__ == "__main__": |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 1105 | parser = argparse.ArgumentParser(description='Check integrity of an ART APEX.') |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1106 | |
Roland Levillain | d7ea043 | 2019-09-09 16:29:12 +0100 | [diff] [blame] | 1107 | parser.add_argument('apex', help='APEX file input') |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1108 | |
Roland Levillain | d7ea043 | 2019-09-09 16:29:12 +0100 | [diff] [blame] | 1109 | parser.add_argument('--host', help='Check as host APEX', action='store_true') |
Andreas Gampe | 0912395 | 2019-01-30 13:17:02 -0800 | [diff] [blame] | 1110 | |
Roland Levillain | d7ea043 | 2019-09-09 16:29:12 +0100 | [diff] [blame] | 1111 | parser.add_argument('--flattened', help='Check as flattened (target) APEX', action='store_true') |
Roland Levillain | dd20d00 | 2019-07-19 16:09:47 +0100 | [diff] [blame] | 1112 | |
Orion Hodson | af3ed62 | 2019-10-03 16:30:54 +0100 | [diff] [blame] | 1113 | parser.add_argument('--flavor', help='Check as FLAVOR APEX', choices=FLAVORS_ALL, |
| 1114 | default=FLAVOR_AUTO) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1115 | |
Andreas Gampe | b1d5567 | 2019-01-29 22:17:02 +0000 | [diff] [blame] | 1116 | parser.add_argument('--list', help='List all files', action='store_true') |
| 1117 | parser.add_argument('--tree', help='Print directory tree', action='store_true') |
Roland Levillain | e91d787 | 2019-07-25 18:56:06 +0100 | [diff] [blame] | 1118 | parser.add_argument('--size', help='Print file sizes', action='store_true') |
Andreas Gampe | b1d5567 | 2019-01-29 22:17:02 +0000 | [diff] [blame] | 1119 | |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1120 | parser.add_argument('--tmpdir', help='Directory for temp files') |
| 1121 | parser.add_argument('--debugfs', help='Path to debugfs') |
| 1122 | |
Orion Hodson | af3ed62 | 2019-10-03 16:30:54 +0100 | [diff] [blame] | 1123 | parser.add_argument('--bitness', help='Bitness to check', choices=BITNESS_ALL, |
| 1124 | default=BITNESS_AUTO) |
Andreas Gampe | eb555b8 | 2019-01-30 14:47:49 -0800 | [diff] [blame] | 1125 | |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1126 | if len(sys.argv) == 1: |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1127 | art_apex_test_default(parser) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1128 | else: |
| 1129 | args = parser.parse_args() |
| 1130 | |
| 1131 | if args is None: |
| 1132 | sys.exit(1) |
| 1133 | |
Luca Stefani | 4e91ee9 | 2019-03-06 15:08:16 +0100 | [diff] [blame] | 1134 | exit_code = art_apex_test_main(args) |
Andreas Gampe | 2c846cd | 2019-01-29 22:06:46 +0000 | [diff] [blame] | 1135 | sys.exit(exit_code) |