OLD | NEW |
---|---|
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 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 """Generate test runner factory and tests for content_browsertests.""" | 5 """Generate test runner factory and tests for content_browsertests.""" |
frankf
2013/07/31 00:14:00
Always rebase, this file is no more.
gkanwar1
2013/07/31 18:07:06
Done.
| |
6 | 6 |
7 import logging | |
8 import os | 7 import os |
9 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 base_test_result | |
16 from pylib.gtest import setup as gtest_setup | 13 from pylib.gtest import setup as gtest_setup |
17 from pylib.gtest import test_runner | 14 from pylib.gtest import test_runner |
18 from pylib.utils import report_results | |
19 | 15 |
20 | 16 |
21 def Setup(test_arguments, timeout, cleanup_test_files, tool, build_type, | 17 def Setup(test_options): |
22 push_deps, gtest_filter): | |
23 """Create the test runner factory and tests. | 18 """Create the test runner factory and tests. |
24 | 19 |
25 Args: | 20 Args: |
26 test_arguments: Additional arguments to pass to the test binary. | 21 test_options: A GTestOptions object containing all options relevant |
27 timeout: Timeout for each test. | 22 to running gtests. |
28 cleanup_test_files: Whether or not to cleanup test files on device. | |
29 tool: Name of the Valgrind tool. | |
30 build_type: 'Release' or 'Debug'. | |
31 push_deps: If True, push all dependencies to the device. | |
32 gtest_filter: filter for tests. | |
33 | 23 |
34 Returns: | 24 Returns: |
35 A tuple of (TestRunnerFactory, tests). | 25 A tuple of (TestRunnerFactory, tests). |
36 """ | 26 """ |
37 | 27 |
38 if not ports.ResetTestServerPortAllocation(): | 28 if not ports.ResetTestServerPortAllocation(): |
39 raise Exception('Failed to reset test server port.') | 29 raise Exception('Failed to reset test server port.') |
40 | 30 |
41 suite_path = os.path.join(cmd_helper.OutDirectory.get(), build_type, 'apks', | 31 suite_path = os.path.join(cmd_helper.OutDirectory.get(), |
32 test_options.build_type, 'apks', | |
42 constants.BROWSERTEST_SUITE_NAME + '.apk') | 33 constants.BROWSERTEST_SUITE_NAME + '.apk') |
43 | 34 |
44 gtest_setup._GenerateDepsDirUsingIsolate( | 35 gtest_setup._GenerateDepsDirUsingIsolate( |
45 constants.BROWSERTEST_SUITE_NAME, build_type) | 36 constants.BROWSERTEST_SUITE_NAME, test_options.build_type) |
46 | 37 |
47 # Constructs a new TestRunner with the current options. | 38 # Constructs a new TestRunner with the current options. |
48 def TestRunnerFactory(device, shard_index): | 39 def TestRunnerFactory(device, shard_index): |
49 return test_runner.TestRunner( | 40 return test_runner.TestRunner( |
41 test_options, | |
42 suite_path, | |
50 device, | 43 device, |
51 suite_path, | |
52 test_arguments, | |
53 timeout, | |
54 cleanup_test_files, | |
55 tool, | |
56 build_type, | |
57 push_deps, | |
58 constants.BROWSERTEST_TEST_PACKAGE_NAME, | 44 constants.BROWSERTEST_TEST_PACKAGE_NAME, |
59 constants.BROWSERTEST_TEST_ACTIVITY_NAME, | 45 constants.BROWSERTEST_TEST_ACTIVITY_NAME, |
60 constants.BROWSERTEST_COMMAND_LINE_FILE) | 46 constants.BROWSERTEST_COMMAND_LINE_FILE) |
61 | 47 |
62 # TODO(gkanwar): This breaks the abstraction of having test_dispatcher.py deal | 48 # TODO(gkanwar): This breaks the abstraction of having test_dispatcher.py deal |
63 # entirely with the devices. Can we do this another way? | 49 # entirely with the devices. Can we do this another way? |
64 attached_devices = android_commands.GetAttachedDevices() | 50 attached_devices = android_commands.GetAttachedDevices() |
65 | 51 |
66 all_tests = gtest_setup.GetTestsFiltered( | 52 all_tests = gtest_setup.GetTestsFiltered( |
67 constants.BROWSERTEST_SUITE_NAME, gtest_filter, TestRunnerFactory, | 53 constants.BROWSERTEST_SUITE_NAME, test_options.gtest_filter, |
68 attached_devices) | 54 TestRunnerFactory, attached_devices) |
69 | 55 |
70 return (TestRunnerFactory, all_tests) | 56 return (TestRunnerFactory, all_tests) |
71 | 57 |
72 | 58 |
73 def _FilterTests(all_enabled_tests): | 59 def _FilterTests(all_enabled_tests): |
74 """Filters out tests and fixtures starting with PRE_ and MANUAL_.""" | 60 """Filters out tests and fixtures starting with PRE_ and MANUAL_.""" |
75 return [t for t in all_enabled_tests if _ShouldRunOnBot(t)] | 61 return [t for t in all_enabled_tests if _ShouldRunOnBot(t)] |
76 | 62 |
77 | 63 |
78 def _ShouldRunOnBot(test): | 64 def _ShouldRunOnBot(test): |
79 fixture, case = test.split('.', 1) | 65 fixture, case = test.split('.', 1) |
80 if _StartsWith(fixture, case, 'PRE_'): | 66 if _StartsWith(fixture, case, 'PRE_'): |
81 return False | 67 return False |
82 if _StartsWith(fixture, case, 'MANUAL_'): | 68 if _StartsWith(fixture, case, 'MANUAL_'): |
83 return False | 69 return False |
84 return True | 70 return True |
85 | 71 |
86 | 72 |
87 def _StartsWith(a, b, prefix): | 73 def _StartsWith(a, b, prefix): |
88 return a.startswith(prefix) or b.startswith(prefix) | 74 return a.startswith(prefix) or b.startswith(prefix) |
OLD | NEW |