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 | 13 import shutil |
14 import signal | 14 import signal |
15 import sys | 15 import sys |
16 import threading | 16 import threading |
17 import unittest | 17 import unittest |
18 | 18 |
19 from pylib import android_commands | |
20 from pylib import constants | 19 from pylib import constants |
21 from pylib import forwarder | 20 from pylib import forwarder |
22 from pylib import ports | 21 from pylib import ports |
23 from pylib.base import base_test_result | 22 from pylib.base import base_test_result |
24 from pylib.base import environment_factory | 23 from pylib.base import environment_factory |
25 from pylib.base import test_dispatcher | 24 from pylib.base import test_dispatcher |
26 from pylib.base import test_instance_factory | 25 from pylib.base import test_instance_factory |
27 from pylib.base import test_run_factory | 26 from pylib.base import test_run_factory |
27 from pylib.device import device_errors | |
28 from pylib.device import device_utils | |
28 from pylib.gtest import gtest_config | 29 from pylib.gtest import gtest_config |
29 from pylib.gtest import setup as gtest_setup | 30 from pylib.gtest import setup as gtest_setup |
30 from pylib.gtest import test_options as gtest_test_options | 31 from pylib.gtest import test_options as gtest_test_options |
31 from pylib.linker import setup as linker_setup | 32 from pylib.linker import setup as linker_setup |
32 from pylib.host_driven import setup as host_driven_setup | 33 from pylib.host_driven import setup as host_driven_setup |
33 from pylib.instrumentation import setup as instrumentation_setup | 34 from pylib.instrumentation import setup as instrumentation_setup |
34 from pylib.instrumentation import test_options as instrumentation_test_options | 35 from pylib.instrumentation import test_options as instrumentation_test_options |
35 from pylib.junit import setup as junit_setup | 36 from pylib.junit import setup as junit_setup |
36 from pylib.junit import test_dispatcher as junit_dispatcher | 37 from pylib.junit import test_dispatcher as junit_dispatcher |
37 from pylib.monkey import setup as monkey_setup | 38 from pylib.monkey import setup as monkey_setup |
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
860 | 861 |
861 def _GetAttachedDevices(test_device=None): | 862 def _GetAttachedDevices(test_device=None): |
862 """Get all attached devices. | 863 """Get all attached devices. |
863 | 864 |
864 Args: | 865 Args: |
865 test_device: Name of a specific device to use. | 866 test_device: Name of a specific device to use. |
866 | 867 |
867 Returns: | 868 Returns: |
868 A list of attached devices. | 869 A list of attached devices. |
869 """ | 870 """ |
870 attached_devices = [] | 871 attached_devices = device_utils.DeviceUtils.HealthyDevices() |
872 if test_device: | |
873 test_device = [d for d in attached_devices if d == test_device] | |
874 if not test_device: | |
875 raise device_errors.DeviceUnreachableError( | |
876 'Did not find device %s among attached device. Attached devices: %s' | |
877 % (test_device, ', '.join(attached_devices))) | |
878 return test_device | |
871 | 879 |
perezju
2015/04/29 14:30:11
nit: is than an extra empty line?
jbudorick
2015/04/29 14:33:07
It's here intentionally, if that's what you're ask
| |
872 attached_devices = android_commands.GetAttachedDevices() | 880 else: |
873 if test_device: | 881 if not attached_devices: |
874 assert test_device in attached_devices, ( | 882 raise device_errors.NoDevicesError() |
875 'Did not find device %s among attached device. Attached devices: %s' | 883 return sorted(attached_devices) |
876 % (test_device, ', '.join(attached_devices))) | |
877 attached_devices = [test_device] | |
878 | |
879 assert attached_devices, 'No devices attached.' | |
880 | |
881 return sorted(attached_devices) | |
882 | 884 |
883 | 885 |
884 def RunTestsCommand(args, parser): | 886 def RunTestsCommand(args, parser): |
885 """Checks test type and dispatches to the appropriate function. | 887 """Checks test type and dispatches to the appropriate function. |
886 | 888 |
887 Args: | 889 Args: |
888 args: argparse.Namespace object. | 890 args: argparse.Namespace object. |
889 parser: argparse.ArgumentParser object. | 891 parser: argparse.ArgumentParser object. |
890 | 892 |
891 Returns: | 893 Returns: |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1029 return constants.INFRA_EXIT_CODE | 1031 return constants.INFRA_EXIT_CODE |
1030 else: | 1032 else: |
1031 return constants.ERROR_EXIT_CODE | 1033 return constants.ERROR_EXIT_CODE |
1032 except: # pylint: disable=W0702 | 1034 except: # pylint: disable=W0702 |
1033 logging.exception('Unrecognized error occurred.') | 1035 logging.exception('Unrecognized error occurred.') |
1034 return constants.ERROR_EXIT_CODE | 1036 return constants.ERROR_EXIT_CODE |
1035 | 1037 |
1036 | 1038 |
1037 if __name__ == '__main__': | 1039 if __name__ == '__main__': |
1038 sys.exit(main()) | 1040 sys.exit(main()) |
OLD | NEW |