OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """ | 6 """ |
7 Runs all the available unit tests, layout tests, page-cycler tests, etc. | 7 Runs all the available unit tests, layout tests, page-cycler tests, etc. |
8 for a build of Chrome, imitating a buildbot. | 8 for a build of Chrome, imitating a buildbot. |
9 | 9 |
10 Usage examples: | 10 Usage examples: |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 'build_type': options.build_type, | 102 'build_type': options.build_type, |
103 'page_heap': '', | 103 'page_heap': '', |
104 'python': python_path, | 104 'python': python_path, |
105 'slave_scripts': _BuildbotScriptPath('slave'), | 105 'slave_scripts': _BuildbotScriptPath('slave'), |
106 } | 106 } |
107 if options.build_type == 'kjs': | 107 if options.build_type == 'kjs': |
108 substitutions['page_heap'] = '--enable-pageheap' | 108 substitutions['page_heap'] = '--enable-pageheap' |
109 return [word % substitutions for word in list] | 109 return [word % substitutions for word in list] |
110 | 110 |
111 | 111 |
112 def RunTestsInShards(test_command, verbose=True): | |
113 """Runs a test in shards. The number of shards is equal to | |
114 NUMBER_OF_PROCESSORS. | |
115 | |
116 Args: | |
117 test_command: the test command to run, which is a list of one or more | |
118 strings. | |
119 verbose: if True, combines stdout and stderr into stdout. | |
120 Otherwise, prints only the command's stderr to stdout. | |
121 | |
122 Returns: | |
123 The first shard process's exit status. | |
124 | |
125 Raises: | |
126 CommandNotFound if the command executable could not be found. | |
127 """ | |
128 processor_count = 2 | |
M-A Ruel
2009/07/29 22:24:46
nit: I think it should default to 1.
| |
129 try: | |
130 processor_count = int(os.environ['NUMBER_OF_PROCESSORS']) | |
131 except KeyError: | |
132 print 'No NUMBER_OF_PROCESSORS defined. Use 2 instances.' | |
133 | |
134 commands = [] | |
135 for i in xrange(processor_count): | |
136 command = [test_command[j] for j in xrange(len(test_command))] | |
137 # To support sharding, the test executable needs to provide --batch-count | |
138 # --batch-index command line switches. | |
139 command.append('--batch-count=%s' % processor_count) | |
140 command.append('--batch-index=%d' % i) | |
141 commands.append(command) | |
142 return google.process_utils.RunCommandsInParallel(commands, verbose)[0][0] | |
143 | |
144 | |
112 def main(options, args): | 145 def main(options, args): |
113 """Runs all the selected tests for the given build type and target.""" | 146 """Runs all the selected tests for the given build type and target.""" |
114 options.build_type = options.build_type.lower() | 147 options.build_type = options.build_type.lower() |
115 options.target = options.target.title() | 148 options.target = options.target.title() |
116 | 149 |
117 this_script_dir = google.path_utils.ScriptDir() | 150 this_script_dir = google.path_utils.ScriptDir() |
118 test_path = google.path_utils.FindUpward(this_script_dir, | 151 test_path = google.path_utils.FindUpward(this_script_dir, |
119 'chrome', options.target) | 152 'chrome', options.target) |
120 | 153 |
121 # Add the buildbot script paths to the module search path. | 154 # Add the buildbot script paths to the module search path. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 failures = [] | 210 failures = [] |
178 start_time = time.time() | 211 start_time = time.time() |
179 for test in tests: | 212 for test in tests: |
180 test_start_time = time.time() | 213 test_start_time = time.time() |
181 command = _MakeSubstitutions(COMMANDS[test], options) | 214 command = _MakeSubstitutions(COMMANDS[test], options) |
182 command[0] = os.path.join(test_path, command[0]) | 215 command[0] = os.path.join(test_path, command[0]) |
183 if options.verbose: | 216 if options.verbose: |
184 print | 217 print |
185 print 'Running %s:' % test, | 218 print 'Running %s:' % test, |
186 try: | 219 try: |
187 result = google.process_utils.RunCommand(command, options.verbose) | 220 if test == 'ui': |
221 result = RunTestsInShards(command, options.verbose) | |
222 else: | |
223 result = google.process_utils.RunCommand(command, options.verbose) | |
188 except google.process_utils.CommandNotFound, e: | 224 except google.process_utils.CommandNotFound, e: |
189 print '%s' % e | 225 print '%s' % e |
190 raise | 226 raise |
191 if options.verbose: | 227 if options.verbose: |
192 print test, | 228 print test, |
193 print '(%ds)' % (time.time() - test_start_time), | 229 print '(%ds)' % (time.time() - test_start_time), |
194 if result: | 230 if result: |
195 print 'FAIL' | 231 print 'FAIL' |
196 failures.append(test) | 232 failures.append(test) |
197 else: | 233 else: |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
234 kill_list = set([os.path.basename(x) for x in kill_list]) | 270 kill_list = set([os.path.basename(x) for x in kill_list]) |
235 sys.exit(google.process_utils.KillAll(kill_list)) | 271 sys.exit(google.process_utils.KillAll(kill_list)) |
236 | 272 |
237 try: | 273 try: |
238 result = main(options, args) | 274 result = main(options, args) |
239 finally: | 275 finally: |
240 # Kill the httpd. | 276 # Kill the httpd. |
241 if _httpd: | 277 if _httpd: |
242 _httpd.StopServer(force=True) | 278 _httpd.StopServer(force=True) |
243 sys.exit(result) | 279 sys.exit(result) |
OLD | NEW |