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