| Shubham Ajmera | fe79349 | 2017-03-16 13:31:35 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 2 | # |
| 3 | # Copyright 2017, The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | """ART Run-Test TestRunner |
| 18 | |
| 19 | The testrunner runs the ART run-tests by simply invoking the script. |
| 20 | It fetches the list of eligible tests from art/test directory, and list of |
| 21 | disabled tests from art/test/knownfailures.json. It runs the tests by |
| 22 | invoking art/test/run-test script and checks the exit value to decide if the |
| 23 | test passed or failed. |
| 24 | |
| 25 | Before invoking the script, first build all the tests dependencies. |
| 26 | There are two major build targets for building target and host tests |
| 27 | dependencies: |
| 28 | 1) test-art-host-run-test |
| 29 | 2) test-art-target-run-test |
| 30 | |
| 31 | There are various options to invoke the script which are: |
| 32 | -t: Either the test name as in art/test or the test name including the variant |
| 33 | information. Eg, "-t 001-HelloWorld", |
| 34 | "-t test-art-host-run-test-debug-prebuild-optimizing-relocate-ntrace-cms-checkjni-picimage-npictest-ndebuggable-001-HelloWorld32" |
| 35 | -j: Number of thread workers to be used. Eg - "-j64" |
| 36 | --dry-run: Instead of running the test name, just print its name. |
| 37 | --verbose |
| 38 | -b / --build-dependencies: to build the dependencies before running the test |
| 39 | |
| 40 | To specify any specific variants for the test, use --<<variant-name>>. |
| 41 | For eg, for compiler type as optimizing, use --optimizing. |
| 42 | |
| 43 | |
| 44 | In the end, the script will print the failed and skipped tests if any. |
| 45 | |
| 46 | """ |
| Alex Light | 7a1ccf8 | 2017-02-21 09:52:34 -0800 | [diff] [blame] | 47 | import argparse |
| Shubham Ajmera | 8585395 | 2017-08-29 16:26:21 -0700 | [diff] [blame] | 48 | import collections |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 49 | import fnmatch |
| 50 | import itertools |
| 51 | import json |
| Shubham Ajmera | 4a5a162 | 2017-03-22 10:07:19 -0700 | [diff] [blame] | 52 | import multiprocessing |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 53 | import os |
| 54 | import re |
| 55 | import subprocess |
| 56 | import sys |
| Shubham Ajmera | 29f8968 | 2017-03-24 14:44:10 -0700 | [diff] [blame] | 57 | import tempfile |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 58 | import threading |
| 59 | import time |
| 60 | |
| 61 | import env |
| Shubham Ajmera | b9d09ca | 2017-03-07 10:45:05 -0800 | [diff] [blame] | 62 | from target_config import target_config |
| Alex Light | 3412a00 | 2017-10-20 13:44:40 +0000 | [diff] [blame] | 63 | from device_config import device_config |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 64 | |
| Shubham Ajmera | 186d321 | 2017-07-21 01:20:57 +0000 | [diff] [blame] | 65 | # timeout for individual tests. |
| 66 | # TODO: make it adjustable per tests and for buildbots |
| 67 | timeout = 3000 # 50 minutes |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 68 | |
| 69 | # DISABLED_TEST_CONTAINER holds information about the disabled tests. It is a map |
| 70 | # that has key as the test name (like 001-HelloWorld), and value as set of |
| 71 | # variants that the test is disabled for. |
| 72 | DISABLED_TEST_CONTAINER = {} |
| 73 | |
| 74 | # The Dict contains the list of all possible variants for a given type. For example, |
| 75 | # for key TARGET, the value would be target and host. The list is used to parse |
| 76 | # the test name given as the argument to run. |
| 77 | VARIANT_TYPE_DICT = {} |
| 78 | |
| 79 | # The set contains all the variants of each time. |
| 80 | TOTAL_VARIANTS_SET = set() |
| 81 | |
| 82 | # The colors are used in the output. When a test passes, COLOR_PASS is used, |
| 83 | # and so on. |
| 84 | COLOR_ERROR = '\033[91m' |
| 85 | COLOR_PASS = '\033[92m' |
| 86 | COLOR_SKIP = '\033[93m' |
| 87 | COLOR_NORMAL = '\033[0m' |
| 88 | |
| 89 | # The mutex object is used by the threads for exclusive access of test_count |
| 90 | # to make any changes in its value. |
| 91 | test_count_mutex = threading.Lock() |
| Shubham Ajmera | 14d340c | 2017-02-15 18:49:10 +0000 | [diff] [blame] | 92 | |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 93 | # The set contains the list of all the possible run tests that are in art/test |
| 94 | # directory. |
| 95 | RUN_TEST_SET = set() |
| Shubham Ajmera | 14d340c | 2017-02-15 18:49:10 +0000 | [diff] [blame] | 96 | |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 97 | # The semaphore object is used by the testrunner to limit the number of |
| 98 | # threads to the user requested concurrency value. |
| 99 | semaphore = threading.Semaphore(1) |
| Shubham Ajmera | 14d340c | 2017-02-15 18:49:10 +0000 | [diff] [blame] | 100 | |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 101 | # The mutex object is used to provide exclusive access to a thread to print |
| 102 | # its output. |
| 103 | print_mutex = threading.Lock() |
| 104 | failed_tests = [] |
| 105 | skipped_tests = [] |
| 106 | |
| 107 | # Flags |
| Shubham Ajmera | 4a5a162 | 2017-03-22 10:07:19 -0700 | [diff] [blame] | 108 | n_thread = -1 |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 109 | test_count = 0 |
| 110 | total_test_count = 0 |
| 111 | verbose = False |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 112 | dry_run = False |
| Alex Light | 42242dd | 2018-02-16 09:23:57 -0800 | [diff] [blame] | 113 | ignore_skips = False |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 114 | build = False |
| 115 | gdb = False |
| 116 | gdb_arg = '' |
| Vladimir Marko | 41b1f0e | 2018-03-21 11:17:12 +0000 | [diff] [blame] | 117 | runtime_option = '' |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 118 | stop_testrunner = False |
| Shubham Ajmera | 981d99c | 2017-08-17 14:11:08 -0700 | [diff] [blame] | 119 | dex2oat_jobs = -1 # -1 corresponds to default threads for dex2oat |
| Shubham Ajmera | 42ea83b | 2017-09-25 21:05:57 -0700 | [diff] [blame] | 120 | run_all_configs = False |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 121 | |
| Alex Light | 3412a00 | 2017-10-20 13:44:40 +0000 | [diff] [blame] | 122 | # Dict containing extra arguments |
| 123 | extra_arguments = { "host" : [], "target" : [] } |
| 124 | |
| Shubham Ajmera | 8585395 | 2017-08-29 16:26:21 -0700 | [diff] [blame] | 125 | # Dict to store user requested test variants. |
| 126 | # key: variant_type. |
| 127 | # value: set of variants user wants to run of type <key>. |
| 128 | _user_input_variants = collections.defaultdict(set) |
| 129 | |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 130 | def gather_test_info(): |
| 131 | """The method gathers test information about the test to be run which includes |
| 132 | generating the list of total tests from the art/test directory and the list |
| 133 | of disabled test. It also maps various variants to types. |
| 134 | """ |
| 135 | global TOTAL_VARIANTS_SET |
| 136 | global DISABLED_TEST_CONTAINER |
| 137 | # TODO: Avoid duplication of the variant names in different lists. |
| 138 | VARIANT_TYPE_DICT['pictest'] = {'pictest', 'npictest'} |
| 139 | VARIANT_TYPE_DICT['run'] = {'ndebug', 'debug'} |
| Igor Murashkin | bab1506 | 2018-02-23 14:53:24 -0800 | [diff] [blame] | 140 | VARIANT_TYPE_DICT['target'] = {'target', 'host', 'jvm'} |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 141 | VARIANT_TYPE_DICT['trace'] = {'trace', 'ntrace', 'stream'} |
| Richard Uhler | bb00f81 | 2017-02-16 14:21:10 +0000 | [diff] [blame] | 142 | VARIANT_TYPE_DICT['image'] = {'picimage', 'no-image', 'multipicimage'} |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 143 | VARIANT_TYPE_DICT['debuggable'] = {'ndebuggable', 'debuggable'} |
| 144 | VARIANT_TYPE_DICT['gc'] = {'gcstress', 'gcverify', 'cms'} |
| 145 | VARIANT_TYPE_DICT['prebuild'] = {'no-prebuild', 'no-dex2oat', 'prebuild'} |
| Mathieu Chartier | dcd56c9 | 2017-11-20 20:30:24 -0800 | [diff] [blame] | 146 | VARIANT_TYPE_DICT['cdex_level'] = {'cdex-none', 'cdex-fast'} |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 147 | VARIANT_TYPE_DICT['relocate'] = {'relocate-npatchoat', 'relocate', 'no-relocate'} |
| 148 | VARIANT_TYPE_DICT['jni'] = {'jni', 'forcecopy', 'checkjni'} |
| 149 | VARIANT_TYPE_DICT['address_sizes'] = {'64', '32'} |
| Alex Light | 43e935d | 2017-06-19 15:40:40 -0700 | [diff] [blame] | 150 | VARIANT_TYPE_DICT['jvmti'] = {'no-jvmti', 'jvmti-stress', 'redefine-stress', 'trace-stress', |
| Alex Light | c38c369 | 2017-06-27 15:45:14 -0700 | [diff] [blame] | 151 | 'field-stress', 'step-stress'} |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 152 | VARIANT_TYPE_DICT['compiler'] = {'interp-ac', 'interpreter', 'jit', 'optimizing', |
| Shubham Ajmera | 8585395 | 2017-08-29 16:26:21 -0700 | [diff] [blame] | 153 | 'regalloc_gc', 'speed-profile'} |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 154 | |
| 155 | for v_type in VARIANT_TYPE_DICT: |
| 156 | TOTAL_VARIANTS_SET = TOTAL_VARIANTS_SET.union(VARIANT_TYPE_DICT.get(v_type)) |
| 157 | |
| 158 | test_dir = env.ANDROID_BUILD_TOP + '/art/test' |
| 159 | for f in os.listdir(test_dir): |
| 160 | if fnmatch.fnmatch(f, '[0-9]*'): |
| 161 | RUN_TEST_SET.add(f) |
| 162 | DISABLED_TEST_CONTAINER = get_disabled_test_info() |
| 163 | |
| 164 | |
| 165 | def setup_test_env(): |
| 166 | """The method sets default value for the various variants of the tests if they |
| 167 | are already not set. |
| 168 | """ |
| 169 | if env.ART_TEST_BISECTION: |
| 170 | env.ART_TEST_RUN_TEST_NO_PREBUILD = True |
| 171 | env.ART_TEST_RUN_TEST_PREBUILD = False |
| 172 | # Bisection search writes to standard output. |
| 173 | env.ART_TEST_QUIET = False |
| 174 | |
| Shubham Ajmera | 42ea83b | 2017-09-25 21:05:57 -0700 | [diff] [blame] | 175 | global _user_input_variants |
| 176 | global run_all_configs |
| Alex Light | a90c68c | 2018-03-26 14:50:24 -0700 | [diff] [blame] | 177 | # These are the default variant-options we will use if nothing in the group is specified. |
| 178 | default_variants = { |
| 179 | 'target': {'host', 'target'}, |
| 180 | 'pictest': {'npictest'}, |
| 181 | 'prebuild': {'prebuild'}, |
| 182 | 'cdex_level': {'cdex-fast'}, |
| 183 | 'jvmti': { 'no-jvmti'}, |
| 184 | 'compiler': {'optimizing', |
| 185 | 'jit', |
| 186 | 'interpreter', |
| 187 | 'interp-ac', |
| 188 | 'speed-profile'}, |
| 189 | 'relocate': {'no-relocate'}, |
| 190 | 'trace': {'ntrace'}, |
| 191 | 'gc': {'cms'}, |
| 192 | 'jni': {'checkjni'}, |
| 193 | 'image': {'picimage'}, |
| 194 | 'pictest': {'pictest'}, |
| 195 | 'debuggable': {'ndebuggable'}, |
| 196 | 'run': {'debug'}, |
| 197 | # address_sizes_target depends on the target so it is dealt with below. |
| 198 | } |
| 199 | # We want to pull these early since the full VARIANT_TYPE_DICT has a few additional ones we don't |
| 200 | # want to pick up if we pass --all. |
| 201 | default_variants_keys = default_variants.keys() |
| Shubham Ajmera | 42ea83b | 2017-09-25 21:05:57 -0700 | [diff] [blame] | 202 | if run_all_configs: |
| Alex Light | a90c68c | 2018-03-26 14:50:24 -0700 | [diff] [blame] | 203 | default_variants = VARIANT_TYPE_DICT |
| Shubham Ajmera | 42ea83b | 2017-09-25 21:05:57 -0700 | [diff] [blame] | 204 | |
| Alex Light | a90c68c | 2018-03-26 14:50:24 -0700 | [diff] [blame] | 205 | for key in default_variants_keys: |
| 206 | if not _user_input_variants[key]: |
| 207 | _user_input_variants[key] = default_variants[key] |
| Shubham Ajmera | d0358f8 | 2017-09-25 20:57:32 -0700 | [diff] [blame] | 208 | |
| Shubham Ajmera | 8585395 | 2017-08-29 16:26:21 -0700 | [diff] [blame] | 209 | _user_input_variants['address_sizes_target'] = collections.defaultdict(set) |
| 210 | if not _user_input_variants['address_sizes']: |
| 211 | _user_input_variants['address_sizes_target']['target'].add( |
| 212 | env.ART_PHONY_TEST_TARGET_SUFFIX) |
| 213 | _user_input_variants['address_sizes_target']['host'].add( |
| 214 | env.ART_PHONY_TEST_HOST_SUFFIX) |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 215 | if env.ART_TEST_RUN_TEST_2ND_ARCH: |
| Shubham Ajmera | 8585395 | 2017-08-29 16:26:21 -0700 | [diff] [blame] | 216 | _user_input_variants['address_sizes_target']['host'].add( |
| 217 | env.ART_2ND_PHONY_TEST_HOST_SUFFIX) |
| 218 | _user_input_variants['address_sizes_target']['target'].add( |
| 219 | env.ART_2ND_PHONY_TEST_TARGET_SUFFIX) |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 220 | else: |
| Shubham Ajmera | 8585395 | 2017-08-29 16:26:21 -0700 | [diff] [blame] | 221 | _user_input_variants['address_sizes_target']['host'] = _user_input_variants['address_sizes'] |
| 222 | _user_input_variants['address_sizes_target']['target'] = _user_input_variants['address_sizes'] |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 223 | |
| Shubham Ajmera | 4a5a162 | 2017-03-22 10:07:19 -0700 | [diff] [blame] | 224 | global n_thread |
| 225 | if n_thread is -1: |
| Shubham Ajmera | 8585395 | 2017-08-29 16:26:21 -0700 | [diff] [blame] | 226 | if 'target' in _user_input_variants['target']: |
| Shubham Ajmera | 4a5a162 | 2017-03-22 10:07:19 -0700 | [diff] [blame] | 227 | n_thread = get_default_threads('target') |
| 228 | else: |
| 229 | n_thread = get_default_threads('host') |
| Shubham Ajmera | 93857f2 | 2017-10-09 13:47:35 -0700 | [diff] [blame] | 230 | print_text("Concurrency: " + str(n_thread) + "\n") |
| Shubham Ajmera | 4a5a162 | 2017-03-22 10:07:19 -0700 | [diff] [blame] | 231 | |
| Alex Light | 3412a00 | 2017-10-20 13:44:40 +0000 | [diff] [blame] | 232 | global extra_arguments |
| 233 | for target in _user_input_variants['target']: |
| 234 | extra_arguments[target] = find_extra_device_arguments(target) |
| 235 | |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 236 | global semaphore |
| 237 | semaphore = threading.Semaphore(n_thread) |
| 238 | |
| Shubham Ajmera | 22499e2 | 2017-03-22 18:33:37 -0700 | [diff] [blame] | 239 | if not sys.stdout.isatty(): |
| 240 | global COLOR_ERROR |
| 241 | global COLOR_PASS |
| 242 | global COLOR_SKIP |
| 243 | global COLOR_NORMAL |
| 244 | COLOR_ERROR = '' |
| 245 | COLOR_PASS = '' |
| 246 | COLOR_SKIP = '' |
| 247 | COLOR_NORMAL = '' |
| 248 | |
| Alex Light | 3412a00 | 2017-10-20 13:44:40 +0000 | [diff] [blame] | 249 | def find_extra_device_arguments(target): |
| 250 | """ |
| 251 | Gets any extra arguments from the device_config. |
| 252 | """ |
| Igor Murashkin | bab1506 | 2018-02-23 14:53:24 -0800 | [diff] [blame] | 253 | device_name = target |
| 254 | if target == 'target': |
| 255 | device_name = get_device_name() |
| 256 | return device_config.get(device_name, { 'run-test-args' : [] })['run-test-args'] |
| Alex Light | 3412a00 | 2017-10-20 13:44:40 +0000 | [diff] [blame] | 257 | |
| 258 | def get_device_name(): |
| 259 | """ |
| 260 | Gets the value of ro.product.name from remote device. |
| 261 | """ |
| 262 | proc = subprocess.Popen(['adb', 'shell', 'getprop', 'ro.product.name'], |
| 263 | stderr=subprocess.STDOUT, |
| 264 | stdout = subprocess.PIPE, |
| 265 | universal_newlines=True) |
| 266 | # only wait 2 seconds. |
| 267 | output = proc.communicate(timeout = 2)[0] |
| 268 | success = not proc.wait() |
| 269 | if success: |
| 270 | return output.strip() |
| 271 | else: |
| 272 | print_text("Unable to determine device type!\n") |
| 273 | print_text("Continuing anyway.\n") |
| 274 | return "UNKNOWN_TARGET" |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 275 | |
| 276 | def run_tests(tests): |
| 277 | """Creates thread workers to run the tests. |
| 278 | |
| 279 | The method generates command and thread worker to run the tests. Depending on |
| 280 | the user input for the number of threads to be used, the method uses a |
| 281 | semaphore object to keep a count in control for the thread workers. When a new |
| 282 | worker is created, it acquires the semaphore object, and when the number of |
| 283 | workers reaches the maximum allowed concurrency, the method wait for an |
| 284 | existing thread worker to release the semaphore object. Worker releases the |
| 285 | semaphore object when they finish printing the output. |
| 286 | |
| 287 | Args: |
| 288 | tests: The set of tests to be run. |
| 289 | """ |
| 290 | options_all = '' |
| Igor Murashkin | bab1506 | 2018-02-23 14:53:24 -0800 | [diff] [blame] | 291 | |
| 292 | # jvm does not run with all these combinations, |
| 293 | # or at least it doesn't make sense for most of them. |
| 294 | # TODO: support some jvm variants like jvmti ? |
| 295 | target_input_variants = _user_input_variants['target'] |
| 296 | uncombinated_target_input_variants = [] |
| 297 | if 'jvm' in target_input_variants: |
| 298 | _user_input_variants['target'].remove('jvm') |
| 299 | uncombinated_target_input_variants.append('jvm') |
| 300 | |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 301 | global total_test_count |
| 302 | total_test_count = len(tests) |
| Igor Murashkin | bab1506 | 2018-02-23 14:53:24 -0800 | [diff] [blame] | 303 | if target_input_variants: |
| 304 | for variant_type in VARIANT_TYPE_DICT: |
| 305 | if not (variant_type == 'target' or 'address_sizes' in variant_type): |
| 306 | total_test_count *= len(_user_input_variants[variant_type]) |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 307 | target_address_combinations = 0 |
| Igor Murashkin | bab1506 | 2018-02-23 14:53:24 -0800 | [diff] [blame] | 308 | for target in target_input_variants: |
| Shubham Ajmera | 8585395 | 2017-08-29 16:26:21 -0700 | [diff] [blame] | 309 | for address_size in _user_input_variants['address_sizes_target'][target]: |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 310 | target_address_combinations += 1 |
| Igor Murashkin | bab1506 | 2018-02-23 14:53:24 -0800 | [diff] [blame] | 311 | target_address_combinations += len(uncombinated_target_input_variants) |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 312 | total_test_count *= target_address_combinations |
| 313 | |
| 314 | if env.ART_TEST_WITH_STRACE: |
| 315 | options_all += ' --strace' |
| 316 | |
| 317 | if env.ART_TEST_RUN_TEST_ALWAYS_CLEAN: |
| 318 | options_all += ' --always-clean' |
| 319 | |
| 320 | if env.ART_TEST_BISECTION: |
| 321 | options_all += ' --bisection-search' |
| 322 | |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 323 | if gdb: |
| 324 | options_all += ' --gdb' |
| 325 | if gdb_arg: |
| 326 | options_all += ' --gdb-arg ' + gdb_arg |
| 327 | |
| Vladimir Marko | 41b1f0e | 2018-03-21 11:17:12 +0000 | [diff] [blame] | 328 | if runtime_option: |
| 329 | for opt in runtime_option: |
| 330 | options_all += ' --runtime-option ' + opt |
| 331 | |
| Shubham Ajmera | 981d99c | 2017-08-17 14:11:08 -0700 | [diff] [blame] | 332 | if dex2oat_jobs != -1: |
| 333 | options_all += ' --dex2oat-jobs ' + str(dex2oat_jobs) |
| 334 | |
| Igor Murashkin | bab1506 | 2018-02-23 14:53:24 -0800 | [diff] [blame] | 335 | def iter_config(tests, input_variants, user_input_variants): |
| 336 | config = itertools.product(tests, input_variants, user_input_variants['run'], |
| 337 | user_input_variants['prebuild'], user_input_variants['compiler'], |
| 338 | user_input_variants['relocate'], user_input_variants['trace'], |
| 339 | user_input_variants['gc'], user_input_variants['jni'], |
| 340 | user_input_variants['image'], user_input_variants['pictest'], |
| 341 | user_input_variants['debuggable'], user_input_variants['jvmti'], |
| 342 | user_input_variants['cdex_level']) |
| 343 | return config |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 344 | |
| Igor Murashkin | bab1506 | 2018-02-23 14:53:24 -0800 | [diff] [blame] | 345 | # [--host, --target] combines with all the other user input variants. |
| 346 | config = iter_config(tests, target_input_variants, _user_input_variants) |
| 347 | # [--jvm] currently combines with nothing else. most of the extra flags we'd insert |
| 348 | # would be unrecognizable by the 'java' binary, so avoid inserting any extra flags for now. |
| 349 | uncombinated_config = iter_config(tests, uncombinated_target_input_variants, { 'run': [''], |
| 350 | 'prebuild': [''], 'compiler': [''], |
| 351 | 'relocate': [''], 'trace': [''], |
| 352 | 'gc': [''], 'jni': [''], |
| 353 | 'image': [''], 'pictest': [''], |
| 354 | 'debuggable': [''], 'jvmti': [''], |
| 355 | 'cdex_level': ['']}) |
| 356 | |
| 357 | def start_combination(config_tuple, address_size): |
| 358 | test, target, run, prebuild, compiler, relocate, trace, gc, \ |
| 359 | jni, image, pictest, debuggable, jvmti, cdex_level = config_tuple |
| 360 | |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 361 | if stop_testrunner: |
| 362 | # When ART_TEST_KEEP_GOING is set to false, then as soon as a test |
| 363 | # fails, stop_testrunner is set to True. When this happens, the method |
| 364 | # stops creating any any thread and wait for all the exising threads |
| 365 | # to end. |
| 366 | while threading.active_count() > 2: |
| 367 | time.sleep(0.1) |
| 368 | return |
| Orion Hodson | 75a58dc | 2018-02-05 14:37:31 +0000 | [diff] [blame] | 369 | # NB The order of components here should match the order of |
| 370 | # components in the regex parser in parse_test_name. |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 371 | test_name = 'test-art-' |
| 372 | test_name += target + '-run-test-' |
| 373 | test_name += run + '-' |
| 374 | test_name += prebuild + '-' |
| 375 | test_name += compiler + '-' |
| 376 | test_name += relocate + '-' |
| 377 | test_name += trace + '-' |
| 378 | test_name += gc + '-' |
| 379 | test_name += jni + '-' |
| 380 | test_name += image + '-' |
| 381 | test_name += pictest + '-' |
| 382 | test_name += debuggable + '-' |
| Alex Light | 8f2c6d4 | 2017-04-10 16:27:35 -0700 | [diff] [blame] | 383 | test_name += jvmti + '-' |
| Orion Hodson | 75a58dc | 2018-02-05 14:37:31 +0000 | [diff] [blame] | 384 | test_name += cdex_level + '-' |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 385 | test_name += test |
| 386 | test_name += address_size |
| 387 | |
| 388 | variant_set = {target, run, prebuild, compiler, relocate, trace, gc, jni, |
| Mathieu Chartier | dcd56c9 | 2017-11-20 20:30:24 -0800 | [diff] [blame] | 389 | image, pictest, debuggable, jvmti, cdex_level, address_size} |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 390 | |
| 391 | options_test = options_all |
| 392 | |
| 393 | if target == 'host': |
| 394 | options_test += ' --host' |
| Igor Murashkin | bab1506 | 2018-02-23 14:53:24 -0800 | [diff] [blame] | 395 | elif target == 'jvm': |
| 396 | options_test += ' --jvm' |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 397 | |
| Roland Levillain | b0633b2 | 2018-05-24 15:59:18 +0100 | [diff] [blame^] | 398 | # Honor ART_TEST_CHROOT and ART_TEST_ANDROID_ROOT, but only for target tests. |
| 399 | if target == 'target': |
| 400 | if env.ART_TEST_CHROOT: |
| 401 | options_test += ' --chroot ' + env.ART_TEST_CHROOT |
| 402 | if env.ART_TEST_ANDROID_ROOT: |
| 403 | options_test += ' --android-root ' + env.ART_TEST_ANDROID_ROOT |
| 404 | |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 405 | if run == 'ndebug': |
| 406 | options_test += ' -O' |
| 407 | |
| 408 | if prebuild == 'prebuild': |
| 409 | options_test += ' --prebuild' |
| 410 | elif prebuild == 'no-prebuild': |
| 411 | options_test += ' --no-prebuild' |
| 412 | elif prebuild == 'no-dex2oat': |
| 413 | options_test += ' --no-prebuild --no-dex2oat' |
| 414 | |
| Mathieu Chartier | dcd56c9 | 2017-11-20 20:30:24 -0800 | [diff] [blame] | 415 | # Add option and remove the cdex- prefix. |
| 416 | options_test += ' --compact-dex-level ' + cdex_level.replace('cdex-','') |
| 417 | |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 418 | if compiler == 'optimizing': |
| 419 | options_test += ' --optimizing' |
| 420 | elif compiler == 'regalloc_gc': |
| 421 | options_test += ' --optimizing -Xcompiler-option --register-allocation-strategy=graph-color' |
| 422 | elif compiler == 'interpreter': |
| 423 | options_test += ' --interpreter' |
| 424 | elif compiler == 'interp-ac': |
| 425 | options_test += ' --interpreter --verify-soft-fail' |
| 426 | elif compiler == 'jit': |
| 427 | options_test += ' --jit' |
| Jeff Hao | 002b931 | 2017-03-27 16:23:08 -0700 | [diff] [blame] | 428 | elif compiler == 'speed-profile': |
| 429 | options_test += ' --random-profile' |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 430 | |
| 431 | if relocate == 'relocate': |
| 432 | options_test += ' --relocate' |
| 433 | elif relocate == 'no-relocate': |
| 434 | options_test += ' --no-relocate' |
| 435 | elif relocate == 'relocate-npatchoat': |
| 436 | options_test += ' --relocate --no-patchoat' |
| 437 | |
| 438 | if trace == 'trace': |
| 439 | options_test += ' --trace' |
| 440 | elif trace == 'stream': |
| 441 | options_test += ' --trace --stream' |
| 442 | |
| 443 | if gc == 'gcverify': |
| 444 | options_test += ' --gcverify' |
| 445 | elif gc == 'gcstress': |
| 446 | options_test += ' --gcstress' |
| 447 | |
| 448 | if jni == 'forcecopy': |
| 449 | options_test += ' --runtime-option -Xjniopts:forcecopy' |
| 450 | elif jni == 'checkjni': |
| 451 | options_test += ' --runtime-option -Xcheck:jni' |
| 452 | |
| 453 | if image == 'no-image': |
| 454 | options_test += ' --no-image' |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 455 | elif image == 'multipicimage': |
| 456 | options_test += ' --multi-image' |
| 457 | |
| 458 | if pictest == 'pictest': |
| 459 | options_test += ' --pic-test' |
| 460 | |
| 461 | if debuggable == 'debuggable': |
| 462 | options_test += ' --debuggable' |
| 463 | |
| Alex Light | 8f2c6d4 | 2017-04-10 16:27:35 -0700 | [diff] [blame] | 464 | if jvmti == 'jvmti-stress': |
| Alex Light | 43e935d | 2017-06-19 15:40:40 -0700 | [diff] [blame] | 465 | options_test += ' --jvmti-trace-stress --jvmti-redefine-stress --jvmti-field-stress' |
| 466 | elif jvmti == 'field-stress': |
| 467 | options_test += ' --jvmti-field-stress' |
| Alex Light | b7edcda | 2017-04-27 13:20:31 -0700 | [diff] [blame] | 468 | elif jvmti == 'trace-stress': |
| 469 | options_test += ' --jvmti-trace-stress' |
| 470 | elif jvmti == 'redefine-stress': |
| 471 | options_test += ' --jvmti-redefine-stress' |
| Alex Light | c38c369 | 2017-06-27 15:45:14 -0700 | [diff] [blame] | 472 | elif jvmti == 'step-stress': |
| 473 | options_test += ' --jvmti-step-stress' |
| Alex Light | 8f2c6d4 | 2017-04-10 16:27:35 -0700 | [diff] [blame] | 474 | |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 475 | if address_size == '64': |
| 476 | options_test += ' --64' |
| 477 | |
| 478 | if env.DEX2OAT_HOST_INSTRUCTION_SET_FEATURES: |
| 479 | options_test += ' --instruction-set-features' + env.DEX2OAT_HOST_INSTRUCTION_SET_FEATURES |
| 480 | |
| 481 | elif address_size == '32': |
| 482 | if env.HOST_2ND_ARCH_PREFIX_DEX2OAT_HOST_INSTRUCTION_SET_FEATURES: |
| 483 | options_test += ' --instruction-set-features ' + \ |
| 484 | env.HOST_2ND_ARCH_PREFIX_DEX2OAT_HOST_INSTRUCTION_SET_FEATURES |
| 485 | |
| Shubham Ajmera | 29f8968 | 2017-03-24 14:44:10 -0700 | [diff] [blame] | 486 | # TODO(http://36039166): This is a temporary solution to |
| 487 | # fix build breakages. |
| 488 | options_test = (' --output-path %s') % ( |
| 489 | tempfile.mkdtemp(dir=env.ART_HOST_TEST_DIR)) + options_test |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 490 | |
| 491 | run_test_sh = env.ANDROID_BUILD_TOP + '/art/test/run-test' |
| Alex Light | 3412a00 | 2017-10-20 13:44:40 +0000 | [diff] [blame] | 492 | command = ' '.join((run_test_sh, options_test, ' '.join(extra_arguments[target]), test)) |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 493 | |
| 494 | semaphore.acquire() |
| 495 | worker = threading.Thread(target=run_test, args=(command, test, variant_set, test_name)) |
| 496 | worker.daemon = True |
| 497 | worker.start() |
| 498 | |
| Igor Murashkin | bab1506 | 2018-02-23 14:53:24 -0800 | [diff] [blame] | 499 | for config_tuple in config: |
| 500 | target = config_tuple[1] |
| 501 | for address_size in _user_input_variants['address_sizes_target'][target]: |
| 502 | start_combination(config_tuple, address_size) |
| 503 | |
| 504 | for config_tuple in uncombinated_config: |
| 505 | start_combination(config_tuple, "") # no address size |
| 506 | |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 507 | while threading.active_count() > 2: |
| 508 | time.sleep(0.1) |
| 509 | |
| 510 | |
| 511 | def run_test(command, test, test_variant, test_name): |
| 512 | """Runs the test. |
| 513 | |
| 514 | It invokes art/test/run-test script to run the test. The output of the script |
| 515 | is checked, and if it ends with "Succeeded!", it assumes that the tests |
| 516 | passed, otherwise, put it in the list of failed test. Before actually running |
| 517 | the test, it also checks if the test is placed in the list of disabled tests, |
| 518 | and if yes, it skips running it, and adds the test in the list of skipped |
| 519 | tests. The method uses print_text method to actually print the output. After |
| 520 | successfully running and capturing the output for the test, it releases the |
| 521 | semaphore object. |
| 522 | |
| 523 | Args: |
| 524 | command: The command to be used to invoke the script |
| 525 | test: The name of the test without the variant information. |
| 526 | test_variant: The set of variant for the test. |
| 527 | test_name: The name of the test along with the variants. |
| 528 | """ |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 529 | global stop_testrunner |
| Shubham Ajmera | bbd8433 | 2017-02-17 00:41:10 +0000 | [diff] [blame] | 530 | try: |
| 531 | if is_test_disabled(test, test_variant): |
| 532 | test_skipped = True |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 533 | else: |
| Shubham Ajmera | bbd8433 | 2017-02-17 00:41:10 +0000 | [diff] [blame] | 534 | test_skipped = False |
| Shubham Ajmera | b4949f5 | 2017-05-08 13:52:46 -0700 | [diff] [blame] | 535 | if gdb: |
| 536 | proc = subprocess.Popen(command.split(), stderr=subprocess.STDOUT, universal_newlines=True) |
| 537 | else: |
| 538 | proc = subprocess.Popen(command.split(), stderr=subprocess.STDOUT, stdout = subprocess.PIPE, |
| 539 | universal_newlines=True) |
| Shubham Ajmera | 186d321 | 2017-07-21 01:20:57 +0000 | [diff] [blame] | 540 | script_output = proc.communicate(timeout=timeout)[0] |
| Shubham Ajmera | bbd8433 | 2017-02-17 00:41:10 +0000 | [diff] [blame] | 541 | test_passed = not proc.wait() |
| 542 | |
| 543 | if not test_skipped: |
| 544 | if test_passed: |
| 545 | print_test_info(test_name, 'PASS') |
| 546 | else: |
| Alex Light | 1ebe614 | 2017-10-03 15:00:10 -0700 | [diff] [blame] | 547 | failed_tests.append((test_name, str(command) + "\n" + script_output)) |
| Shubham Ajmera | bbd8433 | 2017-02-17 00:41:10 +0000 | [diff] [blame] | 548 | if not env.ART_TEST_KEEP_GOING: |
| 549 | stop_testrunner = True |
| 550 | print_test_info(test_name, 'FAIL', ('%s\n%s') % ( |
| 551 | command, script_output)) |
| 552 | elif not dry_run: |
| 553 | print_test_info(test_name, 'SKIP') |
| 554 | skipped_tests.append(test_name) |
| 555 | else: |
| 556 | print_test_info(test_name, '') |
| Shubham Ajmera | fe79349 | 2017-03-16 13:31:35 -0700 | [diff] [blame] | 557 | except subprocess.TimeoutExpired as e: |
| Shubham Ajmera | 186d321 | 2017-07-21 01:20:57 +0000 | [diff] [blame] | 558 | failed_tests.append((test_name, 'Timed out in %d seconds' % timeout)) |
| Shubham Ajmera | 3092c6e | 2017-03-24 16:19:48 -0700 | [diff] [blame] | 559 | print_test_info(test_name, 'TIMEOUT', 'Timed out in %d seconds\n%s' % ( |
| Shubham Ajmera | 186d321 | 2017-07-21 01:20:57 +0000 | [diff] [blame] | 560 | timeout, command)) |
| Shubham Ajmera | fe79349 | 2017-03-16 13:31:35 -0700 | [diff] [blame] | 561 | except Exception as e: |
| Shubham Ajmera | 3092c6e | 2017-03-24 16:19:48 -0700 | [diff] [blame] | 562 | failed_tests.append((test_name, str(e))) |
| 563 | print_test_info(test_name, 'FAIL', |
| 564 | ('%s\n%s\n\n') % (command, str(e))) |
| Shubham Ajmera | bbd8433 | 2017-02-17 00:41:10 +0000 | [diff] [blame] | 565 | finally: |
| 566 | semaphore.release() |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 567 | |
| 568 | |
| Shubham Ajmera | 14d340c | 2017-02-15 18:49:10 +0000 | [diff] [blame] | 569 | def print_test_info(test_name, result, failed_test_info=""): |
| 570 | """Print the continous test information |
| 571 | |
| 572 | If verbose is set to True, it continuously prints test status information |
| 573 | on a new line. |
| 574 | If verbose is set to False, it keeps on erasing test |
| 575 | information by overriding it with the latest test information. Also, |
| 576 | in this case it stictly makes sure that the information length doesn't |
| 577 | exceed the console width. It does so by shortening the test_name. |
| 578 | |
| 579 | When a test fails, it prints the output of the run-test script and |
| 580 | command used to invoke the script. It doesn't override the failing |
| 581 | test information in either of the cases. |
| 582 | """ |
| Shubham Ajmera | bbd8433 | 2017-02-17 00:41:10 +0000 | [diff] [blame] | 583 | |
| Shubham Ajmera | 14d340c | 2017-02-15 18:49:10 +0000 | [diff] [blame] | 584 | global test_count |
| 585 | info = '' |
| 586 | if not verbose: |
| 587 | # Without --verbose, the testrunner erases passing test info. It |
| 588 | # does that by overriding the printed text with white spaces all across |
| 589 | # the console width. |
| 590 | console_width = int(os.popen('stty size', 'r').read().split()[1]) |
| 591 | info = '\r' + ' ' * console_width + '\r' |
| Shubham Ajmera | bbd8433 | 2017-02-17 00:41:10 +0000 | [diff] [blame] | 592 | try: |
| 593 | print_mutex.acquire() |
| 594 | test_count += 1 |
| 595 | percent = (test_count * 100) / total_test_count |
| 596 | progress_info = ('[ %d%% %d/%d ]') % ( |
| 597 | percent, |
| 598 | test_count, |
| 599 | total_test_count) |
| Shubham Ajmera | 14d340c | 2017-02-15 18:49:10 +0000 | [diff] [blame] | 600 | |
| Shubham Ajmera | fe79349 | 2017-03-16 13:31:35 -0700 | [diff] [blame] | 601 | if result == 'FAIL' or result == 'TIMEOUT': |
| Alex Light | 1ebe614 | 2017-10-03 15:00:10 -0700 | [diff] [blame] | 602 | if not verbose: |
| 603 | info += ('%s %s %s\n') % ( |
| 604 | progress_info, |
| 605 | test_name, |
| 606 | COLOR_ERROR + result + COLOR_NORMAL) |
| 607 | else: |
| 608 | info += ('%s %s %s\n%s\n') % ( |
| 609 | progress_info, |
| 610 | test_name, |
| 611 | COLOR_ERROR + result + COLOR_NORMAL, |
| 612 | failed_test_info) |
| Shubham Ajmera | bbd8433 | 2017-02-17 00:41:10 +0000 | [diff] [blame] | 613 | else: |
| 614 | result_text = '' |
| 615 | if result == 'PASS': |
| 616 | result_text += COLOR_PASS + 'PASS' + COLOR_NORMAL |
| 617 | elif result == 'SKIP': |
| 618 | result_text += COLOR_SKIP + 'SKIP' + COLOR_NORMAL |
| 619 | |
| 620 | if verbose: |
| 621 | info += ('%s %s %s\n') % ( |
| 622 | progress_info, |
| 623 | test_name, |
| 624 | result_text) |
| 625 | else: |
| 626 | total_output_length = 2 # Two spaces |
| 627 | total_output_length += len(progress_info) |
| 628 | total_output_length += len(result) |
| 629 | allowed_test_length = console_width - total_output_length |
| 630 | test_name_len = len(test_name) |
| 631 | if allowed_test_length < test_name_len: |
| Shubham Ajmera | fe79349 | 2017-03-16 13:31:35 -0700 | [diff] [blame] | 632 | test_name = ('...%s') % ( |
| 633 | test_name[-(allowed_test_length - 3):]) |
| Alex Light | c14311c | 2017-02-23 17:02:46 -0800 | [diff] [blame] | 634 | info += ('%s %s %s') % ( |
| 635 | progress_info, |
| 636 | test_name, |
| 637 | result_text) |
| Shubham Ajmera | bbd8433 | 2017-02-17 00:41:10 +0000 | [diff] [blame] | 638 | print_text(info) |
| Shubham Ajmera | fe79349 | 2017-03-16 13:31:35 -0700 | [diff] [blame] | 639 | except Exception as e: |
| Shubham Ajmera | bbd8433 | 2017-02-17 00:41:10 +0000 | [diff] [blame] | 640 | print_text(('%s\n%s\n') % (test_name, str(e))) |
| 641 | failed_tests.append(test_name) |
| 642 | finally: |
| 643 | print_mutex.release() |
| Shubham Ajmera | 14d340c | 2017-02-15 18:49:10 +0000 | [diff] [blame] | 644 | |
| Shubham Ajmera | 14de5c4 | 2017-03-13 10:51:14 -0700 | [diff] [blame] | 645 | def verify_knownfailure_entry(entry): |
| 646 | supported_field = { |
| Shubham Ajmera | fe79349 | 2017-03-16 13:31:35 -0700 | [diff] [blame] | 647 | 'tests' : (list, str), |
| Alex Light | 6fdc1b6 | 2017-09-18 11:33:56 -0700 | [diff] [blame] | 648 | 'test_patterns' : (list,), |
| Shubham Ajmera | fe79349 | 2017-03-16 13:31:35 -0700 | [diff] [blame] | 649 | 'description' : (list, str), |
| 650 | 'bug' : (str,), |
| 651 | 'variant' : (str,), |
| Shubham Ajmera | 14de5c4 | 2017-03-13 10:51:14 -0700 | [diff] [blame] | 652 | 'env_vars' : (dict,), |
| 653 | } |
| 654 | for field in entry: |
| 655 | field_type = type(entry[field]) |
| 656 | if field_type not in supported_field[field]: |
| 657 | raise ValueError('%s is not supported type for %s\n%s' % ( |
| 658 | str(field_type), |
| 659 | field, |
| 660 | str(entry))) |
| 661 | |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 662 | def get_disabled_test_info(): |
| 663 | """Generate set of known failures. |
| 664 | |
| 665 | It parses the art/test/knownfailures.json file to generate the list of |
| 666 | disabled tests. |
| 667 | |
| 668 | Returns: |
| 669 | The method returns a dict of tests mapped to the variants list |
| 670 | for which the test should not be run. |
| 671 | """ |
| 672 | known_failures_file = env.ANDROID_BUILD_TOP + '/art/test/knownfailures.json' |
| 673 | with open(known_failures_file) as known_failures_json: |
| 674 | known_failures_info = json.loads(known_failures_json.read()) |
| 675 | |
| 676 | disabled_test_info = {} |
| 677 | for failure in known_failures_info: |
| Shubham Ajmera | 14de5c4 | 2017-03-13 10:51:14 -0700 | [diff] [blame] | 678 | verify_knownfailure_entry(failure) |
| 679 | tests = failure.get('tests', []) |
| Shubham Ajmera | fe79349 | 2017-03-16 13:31:35 -0700 | [diff] [blame] | 680 | if isinstance(tests, str): |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 681 | tests = [tests] |
| Alex Light | 6fdc1b6 | 2017-09-18 11:33:56 -0700 | [diff] [blame] | 682 | patterns = failure.get("test_patterns", []) |
| 683 | if (not isinstance(patterns, list)): |
| 684 | raise ValueError("test_patters is not a list in %s" % failure) |
| 685 | |
| 686 | tests += [f for f in RUN_TEST_SET if any(re.match(pat, f) is not None for pat in patterns)] |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 687 | variants = parse_variants(failure.get('variant')) |
| 688 | env_vars = failure.get('env_vars') |
| Shubham Ajmera | 14de5c4 | 2017-03-13 10:51:14 -0700 | [diff] [blame] | 689 | |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 690 | if check_env_vars(env_vars): |
| 691 | for test in tests: |
| Shubham Ajmera | 14de5c4 | 2017-03-13 10:51:14 -0700 | [diff] [blame] | 692 | if test not in RUN_TEST_SET: |
| 693 | raise ValueError('%s is not a valid run-test' % ( |
| 694 | test)) |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 695 | if test in disabled_test_info: |
| 696 | disabled_test_info[test] = disabled_test_info[test].union(variants) |
| 697 | else: |
| 698 | disabled_test_info[test] = variants |
| 699 | return disabled_test_info |
| 700 | |
| 701 | |
| 702 | def check_env_vars(env_vars): |
| 703 | """Checks if the env variables are set as required to run the test. |
| 704 | |
| 705 | Returns: |
| 706 | True if all the env variables are set as required, otherwise False. |
| 707 | """ |
| 708 | |
| 709 | if not env_vars: |
| 710 | return True |
| 711 | for key in env_vars: |
| 712 | if env.get_env(key) != env_vars.get(key): |
| 713 | return False |
| 714 | return True |
| 715 | |
| 716 | |
| 717 | def is_test_disabled(test, variant_set): |
| 718 | """Checks if the test along with the variant_set is disabled. |
| 719 | |
| 720 | Args: |
| 721 | test: The name of the test as in art/test directory. |
| 722 | variant_set: Variants to be used for the test. |
| 723 | Returns: |
| 724 | True, if the test is disabled. |
| 725 | """ |
| 726 | if dry_run: |
| 727 | return True |
| Alex Light | bc319b2 | 2017-02-17 14:21:33 -0800 | [diff] [blame] | 728 | if test in env.EXTRA_DISABLED_TESTS: |
| 729 | return True |
| Alex Light | 42242dd | 2018-02-16 09:23:57 -0800 | [diff] [blame] | 730 | if ignore_skips: |
| 731 | return False |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 732 | variants_list = DISABLED_TEST_CONTAINER.get(test, {}) |
| 733 | for variants in variants_list: |
| 734 | variants_present = True |
| 735 | for variant in variants: |
| 736 | if variant not in variant_set: |
| 737 | variants_present = False |
| 738 | break |
| 739 | if variants_present: |
| 740 | return True |
| 741 | return False |
| 742 | |
| 743 | |
| 744 | def parse_variants(variants): |
| 745 | """Parse variants fetched from art/test/knownfailures.json. |
| 746 | """ |
| 747 | if not variants: |
| 748 | variants = '' |
| 749 | for variant in TOTAL_VARIANTS_SET: |
| 750 | variants += variant |
| 751 | variants += '|' |
| 752 | variants = variants[:-1] |
| 753 | variant_list = set() |
| 754 | or_variants = variants.split('|') |
| 755 | for or_variant in or_variants: |
| 756 | and_variants = or_variant.split('&') |
| 757 | variant = set() |
| 758 | for and_variant in and_variants: |
| 759 | and_variant = and_variant.strip() |
| Shubham Ajmera | 14de5c4 | 2017-03-13 10:51:14 -0700 | [diff] [blame] | 760 | if and_variant not in TOTAL_VARIANTS_SET: |
| 761 | raise ValueError('%s is not a valid variant' % ( |
| 762 | and_variant)) |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 763 | variant.add(and_variant) |
| 764 | variant_list.add(frozenset(variant)) |
| 765 | return variant_list |
| 766 | |
| 767 | def print_text(output): |
| 768 | sys.stdout.write(output) |
| 769 | sys.stdout.flush() |
| 770 | |
| 771 | def print_analysis(): |
| 772 | if not verbose: |
| Shubham Ajmera | 14d340c | 2017-02-15 18:49:10 +0000 | [diff] [blame] | 773 | # Without --verbose, the testrunner erases passing test info. It |
| 774 | # does that by overriding the printed text with white spaces all across |
| 775 | # the console width. |
| 776 | console_width = int(os.popen('stty size', 'r').read().split()[1]) |
| 777 | eraser_text = '\r' + ' ' * console_width + '\r' |
| 778 | print_text(eraser_text) |
| Shubham Ajmera | cbf5628 | 2017-03-13 09:54:23 -0700 | [diff] [blame] | 779 | |
| 780 | # Prints information about the total tests run. |
| 781 | # E.g., "2/38 (5%) tests passed". |
| 782 | passed_test_count = total_test_count - len(skipped_tests) - len(failed_tests) |
| 783 | passed_test_information = ('%d/%d (%d%%) %s passed.\n') % ( |
| 784 | passed_test_count, |
| 785 | total_test_count, |
| 786 | (passed_test_count*100)/total_test_count, |
| 787 | 'tests' if passed_test_count > 1 else 'test') |
| 788 | print_text(passed_test_information) |
| 789 | |
| 790 | # Prints the list of skipped tests, if any. |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 791 | if skipped_tests: |
| Shubham Ajmera | 3092c6e | 2017-03-24 16:19:48 -0700 | [diff] [blame] | 792 | print_text(COLOR_SKIP + 'SKIPPED TESTS: ' + COLOR_NORMAL + '\n') |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 793 | for test in skipped_tests: |
| 794 | print_text(test + '\n') |
| 795 | print_text('\n') |
| 796 | |
| Shubham Ajmera | cbf5628 | 2017-03-13 09:54:23 -0700 | [diff] [blame] | 797 | # Prints the list of failed tests, if any. |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 798 | if failed_tests: |
| Shubham Ajmera | 3092c6e | 2017-03-24 16:19:48 -0700 | [diff] [blame] | 799 | print_text(COLOR_ERROR + 'FAILED: ' + COLOR_NORMAL + '\n') |
| 800 | for test_info in failed_tests: |
| 801 | print_text(('%s\n%s\n' % (test_info[0], test_info[1]))) |
| Andreas Gampe | 0dd7e85 | 2017-05-24 21:44:23 -0700 | [diff] [blame] | 802 | print_text(COLOR_ERROR + '----------' + COLOR_NORMAL + '\n') |
| 803 | for failed_test in sorted([test_info[0] for test_info in failed_tests]): |
| 804 | print_text(('%s\n' % (failed_test))) |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 805 | |
| 806 | |
| 807 | def parse_test_name(test_name): |
| 808 | """Parses the testname provided by the user. |
| 809 | It supports two types of test_name: |
| 810 | 1) Like 001-HelloWorld. In this case, it will just verify if the test actually |
| 811 | exists and if it does, it returns the testname. |
| 812 | 2) Like test-art-host-run-test-debug-prebuild-interpreter-no-relocate-ntrace-cms-checkjni-picimage-npictest-ndebuggable-001-HelloWorld32 |
| 813 | In this case, it will parse all the variants and check if they are placed |
| 814 | correctly. If yes, it will set the various VARIANT_TYPES to use the |
| 815 | variants required to run the test. Again, it returns the test_name |
| 816 | without the variant information like 001-HelloWorld. |
| 817 | """ |
| Shubham Ajmera | faf1250 | 2017-02-15 17:19:44 +0000 | [diff] [blame] | 818 | test_set = set() |
| 819 | for test in RUN_TEST_SET: |
| 820 | if test.startswith(test_name): |
| 821 | test_set.add(test) |
| 822 | if test_set: |
| 823 | return test_set |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 824 | |
| 825 | regex = '^test-art-' |
| 826 | regex += '(' + '|'.join(VARIANT_TYPE_DICT['target']) + ')-' |
| 827 | regex += 'run-test-' |
| 828 | regex += '(' + '|'.join(VARIANT_TYPE_DICT['run']) + ')-' |
| 829 | regex += '(' + '|'.join(VARIANT_TYPE_DICT['prebuild']) + ')-' |
| 830 | regex += '(' + '|'.join(VARIANT_TYPE_DICT['compiler']) + ')-' |
| 831 | regex += '(' + '|'.join(VARIANT_TYPE_DICT['relocate']) + ')-' |
| 832 | regex += '(' + '|'.join(VARIANT_TYPE_DICT['trace']) + ')-' |
| 833 | regex += '(' + '|'.join(VARIANT_TYPE_DICT['gc']) + ')-' |
| 834 | regex += '(' + '|'.join(VARIANT_TYPE_DICT['jni']) + ')-' |
| 835 | regex += '(' + '|'.join(VARIANT_TYPE_DICT['image']) + ')-' |
| 836 | regex += '(' + '|'.join(VARIANT_TYPE_DICT['pictest']) + ')-' |
| 837 | regex += '(' + '|'.join(VARIANT_TYPE_DICT['debuggable']) + ')-' |
| Alex Light | 8f2c6d4 | 2017-04-10 16:27:35 -0700 | [diff] [blame] | 838 | regex += '(' + '|'.join(VARIANT_TYPE_DICT['jvmti']) + ')-' |
| Mathieu Chartier | dcd56c9 | 2017-11-20 20:30:24 -0800 | [diff] [blame] | 839 | regex += '(' + '|'.join(VARIANT_TYPE_DICT['cdex_level']) + ')-' |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 840 | regex += '(' + '|'.join(RUN_TEST_SET) + ')' |
| 841 | regex += '(' + '|'.join(VARIANT_TYPE_DICT['address_sizes']) + ')$' |
| 842 | match = re.match(regex, test_name) |
| 843 | if match: |
| Shubham Ajmera | 8585395 | 2017-08-29 16:26:21 -0700 | [diff] [blame] | 844 | _user_input_variants['target'].add(match.group(1)) |
| 845 | _user_input_variants['run'].add(match.group(2)) |
| 846 | _user_input_variants['prebuild'].add(match.group(3)) |
| 847 | _user_input_variants['compiler'].add(match.group(4)) |
| 848 | _user_input_variants['relocate'].add(match.group(5)) |
| 849 | _user_input_variants['trace'].add(match.group(6)) |
| 850 | _user_input_variants['gc'].add(match.group(7)) |
| 851 | _user_input_variants['jni'].add(match.group(8)) |
| 852 | _user_input_variants['image'].add(match.group(9)) |
| 853 | _user_input_variants['pictest'].add(match.group(10)) |
| 854 | _user_input_variants['debuggable'].add(match.group(11)) |
| 855 | _user_input_variants['jvmti'].add(match.group(12)) |
| Mathieu Chartier | dcd56c9 | 2017-11-20 20:30:24 -0800 | [diff] [blame] | 856 | _user_input_variants['cdex_level'].add(match.group(13)) |
| 857 | _user_input_variants['address_sizes'].add(match.group(15)) |
| 858 | return {match.group(14)} |
| Shubham Ajmera | faf1250 | 2017-02-15 17:19:44 +0000 | [diff] [blame] | 859 | raise ValueError(test_name + " is not a valid test") |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 860 | |
| Shubham Ajmera | b9d09ca | 2017-03-07 10:45:05 -0800 | [diff] [blame] | 861 | |
| 862 | def setup_env_for_build_target(build_target, parser, options): |
| 863 | """Setup environment for the build target |
| 864 | |
| 865 | The method setup environment for the master-art-host targets. |
| 866 | """ |
| 867 | os.environ.update(build_target['env']) |
| 868 | os.environ['SOONG_ALLOW_MISSING_DEPENDENCIES'] = 'true' |
| 869 | print_text('%s\n' % (str(os.environ))) |
| 870 | |
| 871 | target_options = vars(parser.parse_args(build_target['flags'])) |
| 872 | target_options['host'] = True |
| 873 | target_options['verbose'] = True |
| 874 | target_options['build'] = True |
| 875 | target_options['n_thread'] = options['n_thread'] |
| 876 | target_options['dry_run'] = options['dry_run'] |
| 877 | |
| 878 | return target_options |
| 879 | |
| Shubham Ajmera | 4a5a162 | 2017-03-22 10:07:19 -0700 | [diff] [blame] | 880 | def get_default_threads(target): |
| 881 | if target is 'target': |
| 882 | adb_command = 'adb shell cat /sys/devices/system/cpu/present' |
| 883 | cpu_info_proc = subprocess.Popen(adb_command.split(), stdout=subprocess.PIPE) |
| 884 | cpu_info = cpu_info_proc.stdout.read() |
| Shubham Ajmera | 8fd2694 | 2017-05-09 11:30:47 -0700 | [diff] [blame] | 885 | if type(cpu_info) is bytes: |
| 886 | cpu_info = cpu_info.decode('utf-8') |
| 887 | cpu_info_regex = '\d*-(\d*)' |
| 888 | match = re.match(cpu_info_regex, cpu_info) |
| 889 | if match: |
| 890 | return int(match.group(1)) |
| 891 | else: |
| 892 | raise ValueError('Unable to predict the concurrency for the target. ' |
| 893 | 'Is device connected?') |
| Shubham Ajmera | 4a5a162 | 2017-03-22 10:07:19 -0700 | [diff] [blame] | 894 | else: |
| 895 | return multiprocessing.cpu_count() |
| 896 | |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 897 | def parse_option(): |
| 898 | global verbose |
| 899 | global dry_run |
| Alex Light | 42242dd | 2018-02-16 09:23:57 -0800 | [diff] [blame] | 900 | global ignore_skips |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 901 | global n_thread |
| 902 | global build |
| 903 | global gdb |
| 904 | global gdb_arg |
| Vladimir Marko | 41b1f0e | 2018-03-21 11:17:12 +0000 | [diff] [blame] | 905 | global runtime_option |
| Shubham Ajmera | fe79349 | 2017-03-16 13:31:35 -0700 | [diff] [blame] | 906 | global timeout |
| Shubham Ajmera | 981d99c | 2017-08-17 14:11:08 -0700 | [diff] [blame] | 907 | global dex2oat_jobs |
| Shubham Ajmera | 42ea83b | 2017-09-25 21:05:57 -0700 | [diff] [blame] | 908 | global run_all_configs |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 909 | |
| Alex Light | 7a1ccf8 | 2017-02-21 09:52:34 -0800 | [diff] [blame] | 910 | parser = argparse.ArgumentParser(description="Runs all or a subset of the ART test suite.") |
| Andreas Gampe | 09b2d50 | 2017-11-29 19:08:16 -0800 | [diff] [blame] | 911 | parser.add_argument('-t', '--test', action='append', dest='tests', help='name(s) of the test(s)') |
| Alex Light | c032251 | 2018-03-13 10:33:52 -0700 | [diff] [blame] | 912 | global_group = parser.add_argument_group('Global options', |
| 913 | 'Options that affect all tests being run') |
| 914 | global_group.add_argument('-j', type=int, dest='n_thread') |
| 915 | global_group.add_argument('--timeout', default=timeout, type=int, dest='timeout') |
| 916 | global_group.add_argument('--verbose', '-v', action='store_true', dest='verbose') |
| 917 | global_group.add_argument('--dry-run', action='store_true', dest='dry_run') |
| Vladimir Marko | 41b1f0e | 2018-03-21 11:17:12 +0000 | [diff] [blame] | 918 | global_group.add_argument("--skip", action='append', dest="skips", default=[], |
| Alex Light | c032251 | 2018-03-13 10:33:52 -0700 | [diff] [blame] | 919 | help="Skip the given test in all circumstances.") |
| Vladimir Marko | 41b1f0e | 2018-03-21 11:17:12 +0000 | [diff] [blame] | 920 | global_group.add_argument("--no-skips", dest="ignore_skips", action='store_true', default=False, |
| Alex Light | c032251 | 2018-03-13 10:33:52 -0700 | [diff] [blame] | 921 | help="""Don't skip any run-test configurations listed in |
| 922 | knownfailures.json.""") |
| 923 | global_group.add_argument('--no-build-dependencies', |
| 924 | action='store_false', dest='build', |
| 925 | help="""Don't build dependencies under any circumstances. This is the |
| 926 | behavior if ART_TEST_RUN_TEST_ALWAYS_BUILD is not set to 'true'.""") |
| 927 | global_group.add_argument('-b', '--build-dependencies', |
| 928 | action='store_true', dest='build', |
| 929 | help="""Build dependencies under all circumstances. By default we will |
| 930 | not build dependencies unless ART_TEST_RUN_TEST_BUILD=true.""") |
| 931 | global_group.add_argument('--build-target', dest='build_target', help='master-art-host targets') |
| 932 | global_group.set_defaults(build = env.ART_TEST_RUN_TEST_BUILD) |
| 933 | global_group.add_argument('--gdb', action='store_true', dest='gdb') |
| 934 | global_group.add_argument('--gdb-arg', dest='gdb_arg') |
| Vladimir Marko | 41b1f0e | 2018-03-21 11:17:12 +0000 | [diff] [blame] | 935 | global_group.add_argument('--runtime-option', action='append', dest='runtime_option', |
| 936 | help="""Pass an option to the runtime. Runtime options |
| 937 | starting with a '-' must be separated by a '=', for |
| 938 | example '--runtime-option=-Xjitthreshold:0'.""") |
| Alex Light | c032251 | 2018-03-13 10:33:52 -0700 | [diff] [blame] | 939 | global_group.add_argument('--dex2oat-jobs', type=int, dest='dex2oat_jobs', |
| 940 | help='Number of dex2oat jobs') |
| 941 | global_group.add_argument('-a', '--all', action='store_true', dest='run_all', |
| 942 | help="Run all the possible configurations for the input test set") |
| 943 | for variant_type, variant_set in VARIANT_TYPE_DICT.items(): |
| 944 | var_group = parser.add_argument_group( |
| 945 | '{}-type Options'.format(variant_type), |
| 946 | "Options that control the '{}' variants.".format(variant_type)) |
| 947 | for variant in variant_set: |
| 948 | flag = '--' + variant |
| 949 | var_group.add_argument(flag, action='store_true', dest=variant) |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 950 | |
| Shubham Ajmera | b9d09ca | 2017-03-07 10:45:05 -0800 | [diff] [blame] | 951 | options = vars(parser.parse_args()) |
| 952 | if options['build_target']: |
| 953 | options = setup_env_for_build_target(target_config[options['build_target']], |
| 954 | parser, options) |
| 955 | |
| Andreas Gampe | 09b2d50 | 2017-11-29 19:08:16 -0800 | [diff] [blame] | 956 | tests = None |
| Shubham Ajmera | b9d09ca | 2017-03-07 10:45:05 -0800 | [diff] [blame] | 957 | env.EXTRA_DISABLED_TESTS.update(set(options['skips'])) |
| Andreas Gampe | 09b2d50 | 2017-11-29 19:08:16 -0800 | [diff] [blame] | 958 | if options['tests']: |
| 959 | tests = set() |
| 960 | for test_name in options['tests']: |
| 961 | tests |= parse_test_name(test_name) |
| Shubham Ajmera | 8585395 | 2017-08-29 16:26:21 -0700 | [diff] [blame] | 962 | |
| 963 | for variant_type in VARIANT_TYPE_DICT: |
| 964 | for variant in VARIANT_TYPE_DICT[variant_type]: |
| 965 | if options.get(variant): |
| 966 | _user_input_variants[variant_type].add(variant) |
| 967 | |
| Shubham Ajmera | b9d09ca | 2017-03-07 10:45:05 -0800 | [diff] [blame] | 968 | if options['verbose']: |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 969 | verbose = True |
| Shubham Ajmera | b9d09ca | 2017-03-07 10:45:05 -0800 | [diff] [blame] | 970 | if options['n_thread']: |
| 971 | n_thread = max(1, options['n_thread']) |
| Alex Light | 42242dd | 2018-02-16 09:23:57 -0800 | [diff] [blame] | 972 | ignore_skips = options['ignore_skips'] |
| Shubham Ajmera | b9d09ca | 2017-03-07 10:45:05 -0800 | [diff] [blame] | 973 | if options['dry_run']: |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 974 | dry_run = True |
| 975 | verbose = True |
| Shubham Ajmera | b9d09ca | 2017-03-07 10:45:05 -0800 | [diff] [blame] | 976 | build = options['build'] |
| 977 | if options['gdb']: |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 978 | n_thread = 1 |
| 979 | gdb = True |
| Shubham Ajmera | b9d09ca | 2017-03-07 10:45:05 -0800 | [diff] [blame] | 980 | if options['gdb_arg']: |
| 981 | gdb_arg = options['gdb_arg'] |
| Vladimir Marko | 41b1f0e | 2018-03-21 11:17:12 +0000 | [diff] [blame] | 982 | runtime_option = options['runtime_option']; |
| Shubham Ajmera | fe79349 | 2017-03-16 13:31:35 -0700 | [diff] [blame] | 983 | timeout = options['timeout'] |
| Shubham Ajmera | 981d99c | 2017-08-17 14:11:08 -0700 | [diff] [blame] | 984 | if options['dex2oat_jobs']: |
| 985 | dex2oat_jobs = options['dex2oat_jobs'] |
| Shubham Ajmera | 42ea83b | 2017-09-25 21:05:57 -0700 | [diff] [blame] | 986 | if options['run_all']: |
| 987 | run_all_configs = True |
| Shubham Ajmera | 22499e2 | 2017-03-22 18:33:37 -0700 | [diff] [blame] | 988 | |
| Andreas Gampe | 09b2d50 | 2017-11-29 19:08:16 -0800 | [diff] [blame] | 989 | return tests |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 990 | |
| 991 | def main(): |
| 992 | gather_test_info() |
| Andreas Gampe | 09b2d50 | 2017-11-29 19:08:16 -0800 | [diff] [blame] | 993 | user_requested_tests = parse_option() |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 994 | setup_test_env() |
| 995 | if build: |
| 996 | build_targets = '' |
| Shubham Ajmera | 8585395 | 2017-08-29 16:26:21 -0700 | [diff] [blame] | 997 | if 'host' in _user_input_variants['target']: |
| Shubham Ajmera | 186d321 | 2017-07-21 01:20:57 +0000 | [diff] [blame] | 998 | build_targets += 'test-art-host-run-test-dependencies' |
| Shubham Ajmera | 8585395 | 2017-08-29 16:26:21 -0700 | [diff] [blame] | 999 | if 'target' in _user_input_variants['target']: |
| Shubham Ajmera | 186d321 | 2017-07-21 01:20:57 +0000 | [diff] [blame] | 1000 | build_targets += 'test-art-target-run-test-dependencies' |
| Igor Murashkin | bab1506 | 2018-02-23 14:53:24 -0800 | [diff] [blame] | 1001 | if 'jvm' in _user_input_variants['target']: |
| 1002 | build_targets += 'test-art-host-run-test-dependencies' |
| Shubham Ajmera | 06cde29 | 2017-02-10 23:15:05 +0000 | [diff] [blame] | 1003 | build_command = 'make' |
| Colin Cross | 91f55e6 | 2017-10-21 12:45:26 -0700 | [diff] [blame] | 1004 | build_command += ' DX=' |
| Shubham Ajmera | 4a5a162 | 2017-03-22 10:07:19 -0700 | [diff] [blame] | 1005 | build_command += ' -j' |
| Shubham Ajmera | 06cde29 | 2017-02-10 23:15:05 +0000 | [diff] [blame] | 1006 | build_command += ' -C ' + env.ANDROID_BUILD_TOP |
| 1007 | build_command += ' ' + build_targets |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 1008 | if subprocess.call(build_command.split()): |
| 1009 | sys.exit(1) |
| Andreas Gampe | 09b2d50 | 2017-11-29 19:08:16 -0800 | [diff] [blame] | 1010 | if user_requested_tests: |
| 1011 | test_runner_thread = threading.Thread(target=run_tests, args=(user_requested_tests,)) |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 1012 | else: |
| 1013 | test_runner_thread = threading.Thread(target=run_tests, args=(RUN_TEST_SET,)) |
| 1014 | test_runner_thread.daemon = True |
| 1015 | try: |
| 1016 | test_runner_thread.start() |
| Shubham Ajmera | 535a15c | 2017-11-02 11:31:14 -0700 | [diff] [blame] | 1017 | # This loops waits for all the threads to finish, unless |
| 1018 | # stop_testrunner is set to True. When ART_TEST_KEEP_GOING |
| 1019 | # is set to false, stop_testrunner is set to True as soon as |
| 1020 | # a test fails to signal the parent thread to stop |
| 1021 | # the execution of the testrunner. |
| 1022 | while threading.active_count() > 1 and not stop_testrunner: |
| Shubham Ajmera | 186d321 | 2017-07-21 01:20:57 +0000 | [diff] [blame] | 1023 | time.sleep(0.1) |
| 1024 | print_analysis() |
| Shubham Ajmera | fe79349 | 2017-03-16 13:31:35 -0700 | [diff] [blame] | 1025 | except Exception as e: |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 1026 | print_analysis() |
| Shubham Ajmera | faf1250 | 2017-02-15 17:19:44 +0000 | [diff] [blame] | 1027 | print_text(str(e)) |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 1028 | sys.exit(1) |
| Shubham Ajmera | c5aae87 | 2017-02-16 19:58:59 +0000 | [diff] [blame] | 1029 | if failed_tests: |
| 1030 | sys.exit(1) |
| 1031 | sys.exit(0) |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 1032 | |
| Shubham Ajmera | 65adb8b | 2017-02-06 16:04:25 +0000 | [diff] [blame] | 1033 | if __name__ == '__main__': |
| 1034 | main() |