OLD | NEW |
---|---|
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 import shutil | 7 import shutil |
8 import sys | 8 import sys |
9 | 9 |
10 from pylib import constants | 10 from pylib import constants |
(...skipping 20 matching lines...) Expand all Loading... | |
31 'chrome/test/data/safari_import', | 31 'chrome/test/data/safari_import', |
32 'chrome/test/data/scroll', | 32 'chrome/test/data/scroll', |
33 'chrome/test/data/third_party', | 33 'chrome/test/data/third_party', |
34 'third_party/hunspell_dictionaries/*.dic', | 34 'third_party/hunspell_dictionaries/*.dic', |
35 # crbug.com/258690 | 35 # crbug.com/258690 |
36 'webkit/data/bmp_decoder', | 36 'webkit/data/bmp_decoder', |
37 'webkit/data/ico_decoder', | 37 'webkit/data/ico_decoder', |
38 ] | 38 ] |
39 | 39 |
40 | 40 |
41 # TODO(jbudorick): Make this a class method of GtestTestInstance once | |
42 # test_package_apk and test_package_exe are gone. | |
43 def ParseGTestListTests(raw_list): | |
44 """Parses a raw test list as provided by --gtest_list_tests. | |
45 | |
46 Args: | |
47 raw_list: The raw test listing with the following format: | |
48 | |
49 IPCChannelTest. | |
50 SendMessageInChannelConnected | |
51 IPCSyncChannelTest. | |
52 Simple | |
53 DISABLED_SendWithTimeoutMixedOKAndTimeout | |
54 | |
55 Returns: | |
56 A list of all tests. For the above raw listing: | |
57 | |
58 [IPCChannelTest.SendMessageInChannelConnected, IPCSyncChannelTest.Simple, | |
59 IPCSyncChannelTest.DISABLED_SendWithTimeoutMixedOKAndTimeout] | |
60 """ | |
61 ret = [] | |
62 current = '' | |
63 for test in raw_list: | |
64 if not test: | |
65 continue | |
66 if test[0] != ' ': | |
67 test_case = test.split()[0] | |
68 if test_case.endswith('.'): | |
69 current = test_case | |
70 elif not 'YOU HAVE' in test: | |
71 test_name = test.split()[0] | |
72 ret += [current + test_name] | |
73 return ret | |
74 | |
75 | |
41 class GtestTestInstance(test_instance.TestInstance): | 76 class GtestTestInstance(test_instance.TestInstance): |
42 | 77 |
43 def __init__(self, options, isolate_delegate): | 78 def __init__(self, args, isolate_delegate, error_func): |
44 super(GtestTestInstance, self).__init__() | 79 super(GtestTestInstance, self).__init__() |
45 self._apk_path = os.path.join( | 80 self._suite = args.suite_name[0] |
46 constants.GetOutDirectory(), '%s_apk' % options.suite_name, | 81 |
47 '%s-debug.apk' % options.suite_name) | 82 if self._suite == 'content_browsertests': |
83 error_func('content_browsertests are not currently supported ' | |
84 'in platform mode.') | |
85 self._apk_path = os.path.join( | |
86 constants.GetOutDirectory(), 'apks', '%s.apk' % self._suite) | |
87 else: | |
88 self._apk_path = os.path.join( | |
89 constants.GetOutDirectory(), '%s_apk' % self._suite, | |
90 '%s-debug.apk' % self._suite) | |
91 self._exe_path = os.path.join(constants.GetOutDirectory(), | |
92 self._suite) | |
93 if not os.path.exists(self._apk_path): | |
94 self._apk_path = None | |
95 if not os.path.exists(self._exe_path): | |
96 self._exe_path = None | |
97 if not self._apk_path and not self._exe_path: | |
98 error_func('Could not find apk or executable for %s' % self._suite) | |
99 | |
48 self._data_deps = [] | 100 self._data_deps = [] |
49 self._gtest_filter = options.test_filter | 101 self._gtest_filter = args.test_filter |
50 if options.isolate_file_path: | 102 if args.isolate_file_path: |
51 self._isolate_abs_path = os.path.abspath(options.isolate_file_path) | 103 self._isolate_abs_path = os.path.abspath(args.isolate_file_path) |
52 self._isolate_delegate = isolate_delegate | 104 self._isolate_delegate = isolate_delegate |
53 self._isolated_abs_path = os.path.join( | 105 self._isolated_abs_path = os.path.join( |
54 constants.GetOutDirectory(), '%s.isolated' % options.suite_name) | 106 constants.GetOutDirectory(), '%s.isolated' % self._suite) |
55 else: | 107 else: |
56 logging.warning('No isolate file provided. No data deps will be pushed.'); | 108 logging.warning('No isolate file provided. No data deps will be pushed.'); |
57 self._isolate_delegate = None | 109 self._isolate_delegate = None |
58 self._suite = options.suite_name | |
59 | 110 |
60 #override | 111 #override |
61 def TestType(self): | 112 def TestType(self): |
62 return 'gtest' | 113 return 'gtest' |
63 | 114 |
64 #override | 115 #override |
65 def SetUp(self): | 116 def SetUp(self): |
66 """Map data dependencies via isolate.""" | 117 """Map data dependencies via isolate.""" |
67 if self._isolate_delegate: | 118 if self._isolate_delegate: |
68 self._isolate_delegate.Remap( | 119 self._isolate_delegate.Remap( |
69 self._isolate_abs_path, self._isolated_abs_path) | 120 self._isolate_abs_path, self._isolated_abs_path) |
70 self._isolate_delegate.PurgeExcluded(_DEPS_EXCLUSION_LIST) | 121 self._isolate_delegate.PurgeExcluded(_DEPS_EXCLUSION_LIST) |
71 self._isolate_delegate.MoveOutputDeps() | 122 self._isolate_delegate.MoveOutputDeps() |
72 self._data_deps.extend([(constants.ISOLATE_DEPS_DIR, None)]) | 123 dest_dir = None |
124 if self._suite == 'breakpad_unittests': | |
klundberg
2014/12/11 03:45:38
Anything we can do to avoid this special case in t
jbudorick
2014/12/11 17:43:24
Agreed, it is annoying. At a glance, though, it ap
| |
125 dest_dir = '/data/local/tmp/' | |
126 self._data_deps.extend([(constants.ISOLATE_DEPS_DIR, dest_dir)]) | |
127 | |
73 | 128 |
74 def GetDataDependencies(self): | 129 def GetDataDependencies(self): |
75 """Returns the test suite's data dependencies. | 130 """Returns the test suite's data dependencies. |
76 | 131 |
77 Returns: | 132 Returns: |
78 A list of (host_path, device_path) tuples to push. If device_path is | 133 A list of (host_path, device_path) tuples to push. If device_path is |
79 None, the client is responsible for determining where to push the file. | 134 None, the client is responsible for determining where to push the file. |
80 """ | 135 """ |
81 return self._data_deps | 136 return self._data_deps |
82 | 137 |
83 def FilterTests(self, test_list, disabled_prefixes=None): | 138 def FilterTests(self, test_list, disabled_prefixes=None): |
84 """Filters |test_list| based on prefixes and, if present, a filter string. | 139 """Filters |test_list| based on prefixes and, if present, a filter string. |
85 | 140 |
86 Args: | 141 Args: |
87 test_list: The list of tests to filter. | 142 test_list: The list of tests to filter. |
88 disabled_prefixes: A list of test prefixes to filter. Defaults to | 143 disabled_prefixes: A list of test prefixes to filter. Defaults to |
89 DISABLED_, FLAKY_, FAILS_, PRE_, and MANUAL_ | 144 DISABLED_, FLAKY_, FAILS_, PRE_, and MANUAL_ |
90 Returns: | 145 Returns: |
91 A filtered list of tests to run. | 146 A filtered list of tests to run. |
92 """ | 147 """ |
93 gtest_filter_strings = [ | 148 gtest_filter_strings = [ |
94 self._GenerateDisabledFilterString(disabled_prefixes)] | 149 self._GenerateDisabledFilterString(disabled_prefixes)] |
95 if self._gtest_filter: | 150 if self._gtest_filter: |
96 gtest_filter_strings.append(self._gtest_filter) | 151 gtest_filter_strings.append(self._gtest_filter) |
97 | 152 |
98 filtered_test_list = test_list | 153 filtered_test_list = test_list |
99 for gtest_filter_string in gtest_filter_strings: | 154 for gtest_filter_string in gtest_filter_strings: |
100 logging.info('gtest filter string: %s' % gtest_filter_string) | |
101 filtered_test_list = unittest_util.FilterTestNames( | 155 filtered_test_list = unittest_util.FilterTestNames( |
102 filtered_test_list, gtest_filter_string) | 156 filtered_test_list, gtest_filter_string) |
103 logging.info('final list of tests: %s' % (str(filtered_test_list))) | |
104 return filtered_test_list | 157 return filtered_test_list |
105 | 158 |
106 def _GenerateDisabledFilterString(self, disabled_prefixes): | 159 def _GenerateDisabledFilterString(self, disabled_prefixes): |
107 disabled_filter_items = [] | 160 disabled_filter_items = [] |
108 | 161 |
109 if disabled_prefixes is None: | 162 if disabled_prefixes is None: |
110 disabled_prefixes = ['DISABLED_', 'FLAKY_', 'FAILS_', 'PRE_', 'MANUAL_'] | 163 disabled_prefixes = ['DISABLED_', 'FLAKY_', 'FAILS_', 'PRE_', 'MANUAL_'] |
111 disabled_filter_items += ['%s*' % dp for dp in disabled_prefixes] | 164 disabled_filter_items += ['%s*' % dp for dp in disabled_prefixes] |
165 disabled_filter_items += ['*.%s*' % dp for dp in disabled_prefixes] | |
112 | 166 |
113 disabled_tests_file_path = os.path.join( | 167 disabled_tests_file_path = os.path.join( |
114 constants.DIR_SOURCE_ROOT, 'build', 'android', 'pylib', 'gtest', | 168 constants.DIR_SOURCE_ROOT, 'build', 'android', 'pylib', 'gtest', |
115 'filter', '%s_disabled' % self._suite) | 169 'filter', '%s_disabled' % self._suite) |
116 if disabled_tests_file_path and os.path.exists(disabled_tests_file_path): | 170 if disabled_tests_file_path and os.path.exists(disabled_tests_file_path): |
117 with open(disabled_tests_file_path) as disabled_tests_file: | 171 with open(disabled_tests_file_path) as disabled_tests_file: |
118 disabled_filter_items += [ | 172 disabled_filter_items += [ |
119 '%s' % l for l in (line.strip() for line in disabled_tests_file) | 173 '%s' % l for l in (line.strip() for line in disabled_tests_file) |
120 if l and not l.startswith('#')] | 174 if l and not l.startswith('#')] |
121 | 175 |
122 return '*-%s' % ':'.join(disabled_filter_items) | 176 return '*-%s' % ':'.join(disabled_filter_items) |
123 | 177 |
124 #override | 178 #override |
125 def TearDown(self): | 179 def TearDown(self): |
126 """Clear the mappings created by SetUp.""" | 180 """Clear the mappings created by SetUp.""" |
127 if self._isolate_delegate: | 181 if self._isolate_delegate: |
128 self._isolate_delegate.Clear() | 182 self._isolate_delegate.Clear() |
129 | 183 |
130 @property | 184 @property |
131 def apk(self): | 185 def apk(self): |
132 return self._apk_path | 186 return self._apk_path |
133 | 187 |
134 @property | 188 @property |
189 def exe(self): | |
190 return self._exe_path | |
191 | |
192 @property | |
135 def suite(self): | 193 def suite(self): |
136 return self._suite | 194 return self._suite |
137 | 195 |
OLD | NEW |