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 import logging | 5 import logging |
6 import os | 6 import os |
7 | 7 |
8 from pylib import android_commands | 8 from pylib import android_commands |
9 from pylib import cmd_helper | 9 from pylib import cmd_helper |
10 from pylib import constants | 10 from pylib import constants |
11 from pylib import ports | 11 from pylib import ports |
12 from pylib.base import shard | 12 from pylib.base import shard |
13 from pylib.gtest import dispatch as gtest_dispatch | 13 from pylib.gtest import dispatch as gtest_dispatch |
14 from pylib.gtest import test_runner | 14 from pylib.gtest import test_runner |
15 | 15 |
16 CONTENT_BROWSERTEST_SUITENAME = 'content_browsertests' | |
17 | |
18 | 16 |
19 def Dispatch(options): | 17 def Dispatch(options): |
20 attached_devices = [] | 18 attached_devices = [] |
21 if options.test_device: | 19 if options.test_device: |
22 attached_devices = [options.test_device] | 20 attached_devices = [options.test_device] |
23 else: | 21 else: |
24 attached_devices = android_commands.GetAttachedDevices() | 22 attached_devices = android_commands.GetAttachedDevices() |
25 | 23 |
26 if not attached_devices: | 24 if not attached_devices: |
27 logging.critical('A device must be attached and online.') | 25 logging.critical('A device must be attached and online.') |
28 return 1 | 26 return 1 |
29 | 27 |
30 # Reset the test port allocation. It's important to do it before starting | 28 # Reset the test port allocation. It's important to do it before starting |
31 # to dispatch any tests. | 29 # to dispatch any tests. |
32 if not ports.ResetTestServerPortAllocation(): | 30 if not ports.ResetTestServerPortAllocation(): |
33 raise Exception('Failed to reset test server port.') | 31 raise Exception('Failed to reset test server port.') |
34 | 32 |
35 test_suite_dir = os.path.join(cmd_helper.OutDirectory.get(), | 33 test_suite_dir = os.path.join(cmd_helper.OutDirectory.get(), |
36 options.build_type) | 34 options.build_type) |
37 options.test_suite = os.path.join(test_suite_dir, | 35 options.test_suite = os.path.join(test_suite_dir, |
38 'apks', | 36 'apks', |
39 CONTENT_BROWSERTEST_SUITENAME + '.apk') | 37 constants.BROWSERTEST_SUITE_NAME + '.apk') |
40 | 38 |
41 options.test_arguments = '--single_process %s' % options.test_arguments | 39 options.test_arguments = '--single_process %s' % options.test_arguments |
42 | 40 |
43 # Constructs a new TestRunner with the current options. | 41 # Constructs a new TestRunner with the current options. |
44 def RunnerFactory(device): | 42 def RunnerFactory(device): |
45 return test_runner.TestRunner( | 43 return test_runner.TestRunner( |
46 device, | 44 device, |
47 options.test_suite, | 45 options.test_suite, |
48 options.test_arguments, | 46 options.test_arguments, |
49 options.timeout, | 47 options.timeout, |
(...skipping 10 matching lines...) Expand all Loading... |
60 all_tests = [t for t in options.gtest_filter.split(':') if t] | 58 all_tests = [t for t in options.gtest_filter.split(':') if t] |
61 else: | 59 else: |
62 all_tests = gtest_dispatch.GetAllEnabledTests(RunnerFactory, | 60 all_tests = gtest_dispatch.GetAllEnabledTests(RunnerFactory, |
63 attached_devices) | 61 attached_devices) |
64 | 62 |
65 # Run tests. | 63 # Run tests. |
66 test_results = shard.ShardAndRunTests(RunnerFactory, attached_devices, | 64 test_results = shard.ShardAndRunTests(RunnerFactory, attached_devices, |
67 all_tests, options.build_type) | 65 all_tests, options.build_type) |
68 test_results.LogFull( | 66 test_results.LogFull( |
69 test_type='Unit test', | 67 test_type='Unit test', |
70 test_package=CONTENT_BROWSERTEST_SUITENAME, | 68 test_package=constants.BROWSERTEST_SUITE_NAME, |
71 build_type=options.build_type, | 69 build_type=options.build_type, |
72 flakiness_server=options.flakiness_dashboard_server) | 70 flakiness_server=options.flakiness_dashboard_server) |
73 test_results.PrintAnnotation() | 71 test_results.PrintAnnotation() |
OLD | NEW |