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 logging | 11 import logging |
12 import os | 12 import os |
13 import shutil | |
14 import signal | 13 import signal |
15 import sys | 14 import sys |
16 import threading | 15 import threading |
17 import unittest | 16 import unittest |
18 | 17 |
19 from devil import base_error | 18 from devil import base_error |
20 from devil.android import apk_helper | 19 from devil.android import apk_helper |
21 from devil.android import device_blacklist | 20 from devil.android import device_blacklist |
22 from devil.android import device_errors | 21 from devil.android import device_errors |
23 from devil.android import device_utils | 22 from devil.android import device_utils |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 test_package='ChromiumLinkerTest') | 704 test_package='ChromiumLinkerTest') |
706 | 705 |
707 if args.json_results_file: | 706 if args.json_results_file: |
708 json_results.GenerateJsonResultsFile(results, args.json_results_file) | 707 json_results.GenerateJsonResultsFile(results, args.json_results_file) |
709 | 708 |
710 return exit_code | 709 return exit_code |
711 | 710 |
712 | 711 |
713 def _RunInstrumentationTests(args, devices): | 712 def _RunInstrumentationTests(args, devices): |
714 """Subcommand of RunTestsCommands which runs instrumentation tests.""" | 713 """Subcommand of RunTestsCommands which runs instrumentation tests.""" |
715 logging.info('_RunInstrumentationTests(%s, %s)' % (str(args), str(devices))) | 714 logging.info('_RunInstrumentationTests(%s, %s)', str(args), str(devices)) |
716 | 715 |
717 instrumentation_options = ProcessInstrumentationOptions(args) | 716 instrumentation_options = ProcessInstrumentationOptions(args) |
718 | 717 |
719 if len(devices) > 1 and args.wait_for_debugger: | 718 if len(devices) > 1 and args.wait_for_debugger: |
720 logging.warning('Debugger can not be sharded, using first available device') | 719 logging.warning('Debugger can not be sharded, using first available device') |
721 devices = devices[:1] | 720 devices = devices[:1] |
722 | 721 |
723 results = base_test_result.TestRunResults() | 722 results = base_test_result.TestRunResults() |
724 exit_code = 0 | 723 exit_code = 0 |
725 | 724 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 'Did not find device %s among attached device. Attached devices: %s' | 909 'Did not find device %s among attached device. Attached devices: %s' |
911 % (test_device, ', '.join(attached_devices))) | 910 % (test_device, ', '.join(attached_devices))) |
912 return test_device | 911 return test_device |
913 | 912 |
914 else: | 913 else: |
915 if not attached_devices: | 914 if not attached_devices: |
916 raise device_errors.NoDevicesError() | 915 raise device_errors.NoDevicesError() |
917 return sorted(attached_devices) | 916 return sorted(attached_devices) |
918 | 917 |
919 | 918 |
920 def RunTestsCommand(args, parser): | 919 def RunTestsCommand(args, parser): # pylint: disable=too-many-return-statements |
921 """Checks test type and dispatches to the appropriate function. | 920 """Checks test type and dispatches to the appropriate function. |
922 | 921 |
923 Args: | 922 Args: |
924 args: argparse.Namespace object. | 923 args: argparse.Namespace object. |
925 parser: argparse.ArgumentParser object. | 924 parser: argparse.ArgumentParser object. |
926 | 925 |
927 Returns: | 926 Returns: |
928 Integer indicated exit code. | 927 Integer indicated exit code. |
929 | 928 |
930 Raises: | 929 Raises: |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1066 if e.is_infra_error: | 1065 if e.is_infra_error: |
1067 return constants.INFRA_EXIT_CODE | 1066 return constants.INFRA_EXIT_CODE |
1068 return constants.ERROR_EXIT_CODE | 1067 return constants.ERROR_EXIT_CODE |
1069 except: # pylint: disable=W0702 | 1068 except: # pylint: disable=W0702 |
1070 logging.exception('Unrecognized error occurred.') | 1069 logging.exception('Unrecognized error occurred.') |
1071 return constants.ERROR_EXIT_CODE | 1070 return constants.ERROR_EXIT_CODE |
1072 | 1071 |
1073 | 1072 |
1074 if __name__ == '__main__': | 1073 if __name__ == '__main__': |
1075 sys.exit(main()) | 1074 sys.exit(main()) |
OLD | NEW |