OLD | NEW |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Dispatches content_browsertests.""" | |
6 | |
7 import logging | 5 import logging |
8 import os | 6 import os |
9 import sys | 7 import sys |
10 | 8 |
11 from pylib import android_commands | 9 from pylib import android_commands |
12 from pylib import cmd_helper | 10 from pylib import cmd_helper |
13 from pylib import constants | 11 from pylib import constants |
14 from pylib import ports | 12 from pylib import ports |
15 from pylib.base import shard | 13 from pylib.base import shard |
16 from pylib.gtest import dispatch as gtest_dispatch | 14 from pylib.gtest import dispatch as gtest_dispatch |
17 from pylib.gtest import test_runner | 15 from pylib.gtest import test_runner |
18 from pylib.utils import report_results | 16 from pylib.utils import report_results |
19 | 17 |
20 sys.path.insert(0, | 18 sys.path.insert(0, |
21 os.path.join(constants.DIR_SOURCE_ROOT, 'build', 'util', 'lib')) | 19 os.path.join(constants.DIR_SOURCE_ROOT, 'build', 'util', 'lib')) |
| 20 |
22 from common import unittest_util | 21 from common import unittest_util |
23 | 22 |
24 | |
25 def Dispatch(options): | 23 def Dispatch(options): |
26 """Dispatches all content_browsertests.""" | |
27 | |
28 attached_devices = [] | 24 attached_devices = [] |
29 if options.test_device: | 25 if options.test_device: |
30 attached_devices = [options.test_device] | 26 attached_devices = [options.test_device] |
31 else: | 27 else: |
32 attached_devices = android_commands.GetAttachedDevices() | 28 attached_devices = android_commands.GetAttachedDevices() |
33 | 29 |
34 if not attached_devices: | 30 if not attached_devices: |
35 logging.critical('A device must be attached and online.') | 31 logging.critical('A device must be attached and online.') |
36 return 1 | 32 return 1 |
37 | 33 |
(...skipping 20 matching lines...) Expand all Loading... |
58 options.build_type, | 54 options.build_type, |
59 options.webkit, | 55 options.webkit, |
60 options.push_deps, | 56 options.push_deps, |
61 constants.BROWSERTEST_TEST_PACKAGE_NAME, | 57 constants.BROWSERTEST_TEST_PACKAGE_NAME, |
62 constants.BROWSERTEST_TEST_ACTIVITY_NAME, | 58 constants.BROWSERTEST_TEST_ACTIVITY_NAME, |
63 constants.BROWSERTEST_COMMAND_LINE_FILE) | 59 constants.BROWSERTEST_COMMAND_LINE_FILE) |
64 | 60 |
65 # Get tests and split them up based on the number of devices. | 61 # Get tests and split them up based on the number of devices. |
66 all_enabled = gtest_dispatch.GetAllEnabledTests(RunnerFactory, | 62 all_enabled = gtest_dispatch.GetAllEnabledTests(RunnerFactory, |
67 attached_devices) | 63 attached_devices) |
68 if options.test_filter: | 64 if options.gtest_filter: |
69 all_tests = unittest_util.FilterTestNames(all_enabled, | 65 all_tests = unittest_util.FilterTestNames(all_enabled, |
70 options.test_filter) | 66 options.gtest_filter) |
71 else: | 67 else: |
72 all_tests = _FilterTests(all_enabled) | 68 all_tests = _FilterTests(all_enabled) |
73 | 69 |
74 # Run tests. | 70 # Run tests. |
75 # TODO(nileshagrawal): remove this abnormally long setup timeout once fewer | 71 # TODO(nileshagrawal): remove this abnormally long setup timeout once fewer |
76 # files are pushed to the devices for content_browsertests: crbug.com/138275 | 72 # files are pushed to the devices for content_browsertests: crbug.com/138275 |
77 setup_timeout = 20 * 60 # 20 minutes | 73 setup_timeout = 20 * 60 # 20 minutes |
78 test_results = shard.ShardAndRunTests(RunnerFactory, attached_devices, | 74 test_results = shard.ShardAndRunTests(RunnerFactory, attached_devices, |
79 all_tests, options.build_type, | 75 all_tests, options.build_type, |
80 setup_timeout=setup_timeout, | 76 setup_timeout=setup_timeout, |
81 test_timeout=None, | 77 test_timeout=None, |
82 num_retries=options.num_retries) | 78 num_retries=options.num_retries) |
83 report_results.LogFull( | 79 report_results.LogFull( |
84 results=test_results, | 80 results=test_results, |
85 test_type='Unit test', | 81 test_type='Unit test', |
86 test_package=constants.BROWSERTEST_SUITE_NAME, | 82 test_package=constants.BROWSERTEST_SUITE_NAME, |
87 build_type=options.build_type, | 83 build_type=options.build_type, |
88 flakiness_server=options.flakiness_dashboard_server) | 84 flakiness_server=options.flakiness_dashboard_server) |
89 report_results.PrintAnnotation(test_results) | 85 report_results.PrintAnnotation(test_results) |
90 | 86 |
91 return len(test_results.GetNotPass()) | |
92 | |
93 | |
94 def _FilterTests(all_enabled_tests): | 87 def _FilterTests(all_enabled_tests): |
95 """Filters out tests and fixtures starting with PRE_ and MANUAL_.""" | 88 """Filters out tests and fixtures starting with PRE_ and MANUAL_.""" |
96 return [t for t in all_enabled_tests if _ShouldRunOnBot(t)] | 89 return [t for t in all_enabled_tests if _ShouldRunOnBot(t)] |
97 | 90 |
98 | |
99 def _ShouldRunOnBot(test): | 91 def _ShouldRunOnBot(test): |
100 fixture, case = test.split('.', 1) | 92 fixture, case = test.split('.', 1) |
101 if _StartsWith(fixture, case, 'PRE_'): | 93 if _StartsWith(fixture, case, "PRE_"): |
102 return False | 94 return False |
103 if _StartsWith(fixture, case, 'MANUAL_'): | 95 if _StartsWith(fixture, case, "MANUAL_"): |
104 return False | 96 return False |
105 return True | 97 return True |
106 | 98 |
107 | |
108 def _StartsWith(a, b, prefix): | 99 def _StartsWith(a, b, prefix): |
109 return a.startswith(prefix) or b.startswith(prefix) | 100 return a.startswith(prefix) or b.startswith(prefix) |
OLD | NEW |