| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2013 The Chromium Authors. All rights reserved. | 3 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Runs all types of tests from one unified interface.""" | 7 """Runs all types of tests from one unified interface.""" |
| 8 | 8 |
| 9 import argparse | 9 import argparse |
| 10 import collections | 10 import collections |
| 11 import contextlib | 11 import contextlib |
| 12 import itertools | 12 import itertools |
| 13 import logging | 13 import logging |
| 14 import os | 14 import os |
| 15 import signal | 15 import signal |
| 16 import sys | 16 import sys |
| 17 import threading | 17 import threading |
| 18 import traceback | 18 import traceback |
| 19 import unittest | 19 import unittest |
| 20 | 20 |
| 21 import devil_chromium | 21 import devil_chromium |
| 22 from devil import base_error | 22 from devil import base_error |
| 23 from devil.android import device_blacklist | 23 from devil.android import device_blacklist |
| 24 from devil.android import device_errors | 24 from devil.android import device_errors |
| 25 from devil.android import device_utils | 25 from devil.android import device_utils |
| 26 from devil.android import forwarder | 26 from devil.android import forwarder |
| 27 from devil.android import ports | 27 from devil.android import ports |
| 28 from devil.utils import reraiser_thread | 28 from devil.utils import reraiser_thread |
| 29 from devil.utils import run_tests_helper | 29 from devil.utils import run_tests_helper |
| 30 from devil.utils import signal_handler | |
| 31 | 30 |
| 32 from pylib import constants | 31 from pylib import constants |
| 33 from pylib.base import base_test_result | 32 from pylib.base import base_test_result |
| 34 from pylib.base import environment_factory | 33 from pylib.base import environment_factory |
| 35 from pylib.base import test_dispatcher | 34 from pylib.base import test_dispatcher |
| 36 from pylib.base import test_instance_factory | 35 from pylib.base import test_instance_factory |
| 37 from pylib.base import test_run_factory | 36 from pylib.base import test_run_factory |
| 38 from pylib.constants import host_paths | 37 from pylib.constants import host_paths |
| 39 from pylib.linker import setup as linker_setup | 38 from pylib.linker import setup as linker_setup |
| 40 from pylib.results import json_results | 39 from pylib.results import json_results |
| (...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 # pylint: disable=protected-access | 710 # pylint: disable=protected-access |
| 712 thread_stack = ''.join(traceback.format_stack( | 711 thread_stack = ''.join(traceback.format_stack( |
| 713 sys._current_frames()[live_thread.ident])) | 712 sys._current_frames()[live_thread.ident])) |
| 714 msg.extend([ | 713 msg.extend([ |
| 715 'Thread "%s" (ident: %s) is currently running:' % ( | 714 'Thread "%s" (ident: %s) is currently running:' % ( |
| 716 live_thread.name, live_thread.ident), | 715 live_thread.name, live_thread.ident), |
| 717 thread_stack]) | 716 thread_stack]) |
| 718 | 717 |
| 719 infra_error('\n'.join(msg)) | 718 infra_error('\n'.join(msg)) |
| 720 | 719 |
| 721 sigterm_handler = signal_handler.SignalHandler( | 720 signal.signal(signal.SIGTERM, unexpected_sigterm) |
| 722 signal.SIGTERM, unexpected_sigterm) | |
| 723 | 721 |
| 724 ### Set up results handling. | 722 ### Set up results handling. |
| 725 # TODO(jbudorick): Rewrite results handling. | 723 # TODO(jbudorick): Rewrite results handling. |
| 726 | 724 |
| 727 # all_raw_results is a list of lists of | 725 # all_raw_results is a list of lists of |
| 728 # base_test_result.TestRunResults objects. Each instance of | 726 # base_test_result.TestRunResults objects. Each instance of |
| 729 # TestRunResults contains all test results produced by a single try, | 727 # TestRunResults contains all test results produced by a single try, |
| 730 # while each list of TestRunResults contains all tries in a single | 728 # while each list of TestRunResults contains all tries in a single |
| 731 # iteration. | 729 # iteration. |
| 732 all_raw_results = [] | 730 all_raw_results = [] |
| (...skipping 21 matching lines...) Expand all Loading... |
| 754 | 752 |
| 755 ### Set up test objects. | 753 ### Set up test objects. |
| 756 | 754 |
| 757 env = environment_factory.CreateEnvironment(args, infra_error) | 755 env = environment_factory.CreateEnvironment(args, infra_error) |
| 758 test_instance = test_instance_factory.CreateTestInstance(args, infra_error) | 756 test_instance = test_instance_factory.CreateTestInstance(args, infra_error) |
| 759 test_run = test_run_factory.CreateTestRun( | 757 test_run = test_run_factory.CreateTestRun( |
| 760 args, env, test_instance, infra_error) | 758 args, env, test_instance, infra_error) |
| 761 | 759 |
| 762 ### Run. | 760 ### Run. |
| 763 | 761 |
| 764 with sigterm_handler, json_writer, env, test_instance, test_run: | 762 with json_writer, env, test_instance, test_run: |
| 765 | 763 |
| 766 repetitions = (xrange(args.repeat + 1) if args.repeat >= 0 | 764 repetitions = (xrange(args.repeat + 1) if args.repeat >= 0 |
| 767 else itertools.count()) | 765 else itertools.count()) |
| 768 result_counts = collections.defaultdict( | 766 result_counts = collections.defaultdict( |
| 769 lambda: collections.defaultdict(int)) | 767 lambda: collections.defaultdict(int)) |
| 770 iteration_count = 0 | 768 iteration_count = 0 |
| 771 for _ in repetitions: | 769 for _ in repetitions: |
| 772 raw_results = test_run.RunTests() | 770 raw_results = test_run.RunTests() |
| 773 if not raw_results: | 771 if not raw_results: |
| 774 continue | 772 continue |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 if e.is_infra_error: | 878 if e.is_infra_error: |
| 881 return constants.INFRA_EXIT_CODE | 879 return constants.INFRA_EXIT_CODE |
| 882 return constants.ERROR_EXIT_CODE | 880 return constants.ERROR_EXIT_CODE |
| 883 except: # pylint: disable=W0702 | 881 except: # pylint: disable=W0702 |
| 884 logging.exception('Unrecognized error occurred.') | 882 logging.exception('Unrecognized error occurred.') |
| 885 return constants.ERROR_EXIT_CODE | 883 return constants.ERROR_EXIT_CODE |
| 886 | 884 |
| 887 | 885 |
| 888 if __name__ == '__main__': | 886 if __name__ == '__main__': |
| 889 sys.exit(main()) | 887 sys.exit(main()) |
| OLD | NEW |