diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/testrunner/env.py | 6 | ||||
| -rwxr-xr-x | test/testrunner/testrunner.py | 45 |
2 files changed, 30 insertions, 21 deletions
diff --git a/test/testrunner/env.py b/test/testrunner/env.py index ed4b4a9f3e..e93fb3afa8 100644 --- a/test/testrunner/env.py +++ b/test/testrunner/env.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python -# # Copyright 2017, The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -57,7 +55,9 @@ def dump_many_vars(var_name): "make --no-print-directory -C \"%s\" -f build/core/config.mk " "dump-many-vars DUMP_MANY_VARS=\"%s\"") % (ANDROID_BUILD_TOP, all_vars) - config = subprocess.Popen(command, stdout=subprocess.PIPE, + config = subprocess.Popen(command, + stdout=subprocess.PIPE, + universal_newlines=True, shell=True).communicate()[0] # read until EOF, select stdin # Prints out something like: # TARGET_ARCH='arm64' diff --git a/test/testrunner/testrunner.py b/test/testrunner/testrunner.py index a5504098d8..0b9a6e6457 100755 --- a/test/testrunner/testrunner.py +++ b/test/testrunner/testrunner.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2017, The Android Open Source Project # @@ -72,6 +72,9 @@ DEBUGGABLE_TYPES = set() ADDRESS_SIZES = set() OPTIMIZING_COMPILER_TYPES = set() ADDRESS_SIZES_TARGET = {'host': set(), 'target': set()} +# timeout for individual tests. +# TODO: make it adjustable per tests and for buildbots +timeout = 3000 # 50 minutes # DISABLED_TEST_CONTAINER holds information about the disabled tests. It is a map # that has key as the test name (like 001-HelloWorld), and value as set of @@ -451,8 +454,8 @@ def run_test(command, test, test_variant, test_name): test_skipped = True else: test_skipped = False - proc = subprocess.Popen(command.split(), stderr=subprocess.STDOUT, stdout=subprocess.PIPE) - script_output = proc.stdout.read().strip() + proc = subprocess.Popen(command.split(), stderr=subprocess.STDOUT, stdout=subprocess.PIPE, universal_newlines=True) + script_output = proc.communicate(timeout=timeout)[0] test_passed = not proc.wait() if not test_skipped: @@ -469,9 +472,14 @@ def run_test(command, test, test_variant, test_name): skipped_tests.append(test_name) else: print_test_info(test_name, '') - except Exception, e: + except subprocess.TimeoutExpired as e: failed_tests.append(test_name) - print_text(('%s\n%s\n') % (command, str(e))) + print_test_info(test_name, 'TIMEOUT', 'timed out in %d\n%s' % ( + timeout, command)) + except Exception as e: + failed_tests.append(test_name) + print_test_info(test_name, 'FAIL') + print_text(('%s\n%s\n\n') % (command, str(e))) finally: semaphore.release() @@ -508,11 +516,11 @@ def print_test_info(test_name, result, failed_test_info=""): test_count, total_test_count) - if result == "FAIL": + if result == 'FAIL' or result == 'TIMEOUT': info += ('%s %s %s\n%s\n') % ( progress_info, test_name, - COLOR_ERROR + 'FAIL' + COLOR_NORMAL, + COLOR_ERROR + result + COLOR_NORMAL, failed_test_info) else: result_text = '' @@ -533,15 +541,14 @@ def print_test_info(test_name, result, failed_test_info=""): allowed_test_length = console_width - total_output_length test_name_len = len(test_name) if allowed_test_length < test_name_len: - test_name = ('%s...%s') % ( - test_name[:(allowed_test_length - 3)/2], - test_name[-(allowed_test_length - 3)/2:]) + test_name = ('...%s') % ( + test_name[-(allowed_test_length - 3):]) info += ('%s %s %s') % ( progress_info, test_name, result_text) print_text(info) - except Exception, e: + except Exception as e: print_text(('%s\n%s\n') % (test_name, str(e))) failed_tests.append(test_name) finally: @@ -549,10 +556,10 @@ def print_test_info(test_name, result, failed_test_info=""): def verify_knownfailure_entry(entry): supported_field = { - 'tests' : (list, unicode), - 'description' : (list, unicode), - 'bug' : (unicode,), - 'variant' : (unicode,), + 'tests' : (list, str), + 'description' : (list, str), + 'bug' : (str,), + 'variant' : (str,), 'env_vars' : (dict,), } for field in entry: @@ -581,7 +588,7 @@ def get_disabled_test_info(): for failure in known_failures_info: verify_knownfailure_entry(failure) tests = failure.get('tests', []) - if isinstance(tests, unicode): + if isinstance(tests, str): tests = [tests] variants = parse_variants(failure.get('variant')) env_vars = failure.get('env_vars') @@ -774,10 +781,12 @@ def parse_option(): global build global gdb global gdb_arg + global timeout parser = argparse.ArgumentParser(description="Runs all or a subset of the ART test suite.") parser.add_argument('-t', '--test', dest='test', help='name of the test') parser.add_argument('-j', type=int, dest='n_thread') + parser.add_argument('--timeout', default=timeout, type=int, dest='timeout') for variant in TOTAL_VARIANTS_SET: flag = '--' + variant flag_dest = variant.replace('-', '_') @@ -885,7 +894,7 @@ def parse_option(): gdb = True if options['gdb_arg']: gdb_arg = options['gdb_arg'] - + timeout = options['timeout'] return test def main(): @@ -914,7 +923,7 @@ def main(): while threading.active_count() > 1: time.sleep(0.1) print_analysis() - except Exception, e: + except Exception as e: print_analysis() print_text(str(e)) sys.exit(1) |