| OLD | NEW |
| 1 #!/bin/env python | 1 #!/bin/env 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 # chrome_tests.py | 6 # chrome_tests.py |
| 7 | 7 |
| 8 ''' Runs various chrome tests through purify_test.py | 8 ''' Runs various chrome tests through purify_test.py |
| 9 ''' | 9 ''' |
| 10 | 10 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 # relative to the top of the tree. | 54 # relative to the top of the tree. |
| 55 self._source_dir = os.path.dirname(os.path.dirname(script_dir)) | 55 self._source_dir = os.path.dirname(os.path.dirname(script_dir)) |
| 56 | 56 |
| 57 # since this path is used for string matching, make sure it's always | 57 # since this path is used for string matching, make sure it's always |
| 58 # an absolute Windows-style path | 58 # an absolute Windows-style path |
| 59 self._source_dir = utility.GetAbsolutePath(self._source_dir) | 59 self._source_dir = utility.GetAbsolutePath(self._source_dir) |
| 60 | 60 |
| 61 self._report_dir = options.report_dir | 61 self._report_dir = options.report_dir |
| 62 if not self._report_dir: | 62 if not self._report_dir: |
| 63 if not options.buildbot: | 63 if not options.buildbot: |
| 64 self._report_dir = os.path.join(script_dir, "latest") | 64 self._report_dir = os.path.join(script_dir, "latest", test) |
| 65 else: | 65 else: |
| 66 # On the buildbot, we archive to a specific location on chrome-web | 66 # On the buildbot, we archive to a specific location on chrome-web |
| 67 # with a directory based on the test name and the current svn revision. | 67 # with a directory based on the test name and the current svn revision. |
| 68 # NOTE: These modules are located in trunk/tools/buildbot, which is not | 68 # NOTE: These modules are located in trunk/tools/buildbot, which is not |
| 69 # in the default config. You'll need to check this out and add | 69 # in the default config. You'll need to check this out and add |
| 70 # scripts/* to your PYTHONPATH to test outside of the buildbot. | 70 # scripts/* to your PYTHONPATH to test outside of the buildbot. |
| 71 import slave_utils | 71 import slave_utils |
| 72 import chromium_config | 72 import chromium_config |
| 73 chrome_web_dir = chromium_config.Archive.purify_test_result_archive | 73 chrome_web_dir = chromium_config.Archive.purify_test_result_archive |
| 74 current_version = str(slave_utils.SubversionRevision(self._source_dir)) | 74 current_version = str(slave_utils.SubversionRevision(self._source_dir)) |
| 75 # This line is how the buildbot master figures out our directory. | 75 # This line is how the buildbot master figures out our directory. |
| 76 print "last change:", current_version | 76 print "last change:", current_version |
| 77 self._report_dir = os.path.join(chrome_web_dir, test,current_version) | 77 self._report_dir = os.path.join(chrome_web_dir, test, current_version) |
| 78 if not os.path.exists(self._report_dir): | 78 if not os.path.exists(self._report_dir): |
| 79 os.makedirs(self._report_dir) | 79 os.makedirs(self._report_dir) |
| 80 | 80 |
| 81 purify_test = os.path.join(script_dir, "purify_test.py") | 81 purify_test = os.path.join(script_dir, "purify_test.py") |
| 82 self._command_preamble = ["python.exe", purify_test, "--echo_to_stdout", | 82 self._command_preamble = ["python.exe", purify_test, "--echo_to_stdout", |
| 83 "--source_dir=%s" % (self._source_dir), | 83 "--source_dir=%s" % (self._source_dir), |
| 84 "--report_dir=%s" % (self._report_dir), | |
| 85 "--save_cache"] | 84 "--save_cache"] |
| 86 | 85 |
| 87 def _DefaultCommand(self, module, exe=None): | 86 def _DefaultCommand(self, module, exe=None): |
| 88 '''Generates the default command array that most tests will use.''' | 87 '''Generates the default command array that most tests will use.''' |
| 89 module_dir = os.path.join(self._source_dir, module) | 88 module_dir = os.path.join(self._source_dir, module) |
| 90 if module == "chrome": | 89 if module == "chrome": |
| 91 # unfortunately, not all modules have the same directory structure | 90 # unfortunately, not all modules have the same directory structure |
| 92 self._data_dir = os.path.join(module_dir, "test", "data", "purify") | 91 self._data_dir = os.path.join(module_dir, "test", "data", "purify") |
| 93 else: | 92 else: |
| 94 self._data_dir = os.path.join(module_dir, "data", "purify") | 93 self._data_dir = os.path.join(module_dir, "data", "purify") |
| (...skipping 17 matching lines...) Expand all Loading... |
| 112 self._options.build_dir = dir_chrome | 111 self._options.build_dir = dir_chrome |
| 113 elif os.path.isdir(dir_module) and not os.path.isdir(dir_chrome): | 112 elif os.path.isdir(dir_module) and not os.path.isdir(dir_chrome): |
| 114 self._options.build_dir = dir_module | 113 self._options.build_dir = dir_module |
| 115 elif os.stat(dir_module)[stat.ST_MTIME] > os.stat(dir_chrome)[stat.ST_MT
IME]: | 114 elif os.stat(dir_module)[stat.ST_MTIME] > os.stat(dir_chrome)[stat.ST_MT
IME]: |
| 116 self._options.build_dir = dir_module | 115 self._options.build_dir = dir_module |
| 117 else: | 116 else: |
| 118 self._options.build_dir = dir_chrome | 117 self._options.build_dir = dir_chrome |
| 119 | 118 |
| 120 cmd = list(self._command_preamble) | 119 cmd = list(self._command_preamble) |
| 121 cmd.append("--data_dir=%s" % self._data_dir) | 120 cmd.append("--data_dir=%s" % self._data_dir) |
| 121 cmd.append("--report_dir=%s" % self._report_dir) |
| 122 if self._options.baseline: | 122 if self._options.baseline: |
| 123 cmd.append("--baseline") | 123 cmd.append("--baseline") |
| 124 if self._options.verbose: | 124 if self._options.verbose: |
| 125 cmd.append("--verbose") | 125 cmd.append("--verbose") |
| 126 if exe: | 126 if exe: |
| 127 cmd.append(os.path.join(self._options.build_dir, exe)) | 127 cmd.append(os.path.join(self._options.build_dir, exe)) |
| 128 return cmd | 128 return cmd |
| 129 | 129 |
| 130 def Run(self): | 130 def Run(self): |
| 131 ''' Runs the test specified by command-line argument --test ''' | 131 ''' Runs the test specified by command-line argument --test ''' |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 exe - the name of the exe (it's assumed to exist in build_dir) | 177 exe - the name of the exe (it's assumed to exist in build_dir) |
| 178 name - the name of this test (used to name output files) | 178 name - the name of this test (used to name output files) |
| 179 script - the driver program or script. If it's python.exe, we use | 179 script - the driver program or script. If it's python.exe, we use |
| 180 search-path behavior to execute, otherwise we assume that it is in | 180 search-path behavior to execute, otherwise we assume that it is in |
| 181 build_dir. | 181 build_dir. |
| 182 multi - a boolean hint that the exe will be run multiple times, generating | 182 multi - a boolean hint that the exe will be run multiple times, generating |
| 183 multiple output files (without this option, only the last run will be | 183 multiple output files (without this option, only the last run will be |
| 184 recorded and analyzed) | 184 recorded and analyzed) |
| 185 cmd_args - extra arguments to pass to the purify_test.py script | 185 cmd_args - extra arguments to pass to the purify_test.py script |
| 186 ''' | 186 ''' |
| 187 if out_dir_extra: |
| 188 self._report_dir = os.path.join(self._report_dir, out_dir_extra) |
| 187 cmd = self._DefaultCommand(module) | 189 cmd = self._DefaultCommand(module) |
| 188 exe = os.path.join(self._options.build_dir, exe) | 190 exe = os.path.join(self._options.build_dir, exe) |
| 189 cmd.append("--exe=%s" % exe) | 191 cmd.append("--exe=%s" % exe) |
| 190 cmd.append("--name=%s" % name) | 192 cmd.append("--name=%s" % name) |
| 191 if multi: | 193 if multi: |
| 192 out = os.path.join(google.path_utils.ScriptDir(), | |
| 193 "latest") | |
| 194 if out_dir_extra: | 194 if out_dir_extra: |
| 195 out = os.path.join(out, out_dir_extra) | 195 if os.path.exists(self._report_dir): |
| 196 if os.path.exists(out): | 196 old_files = glob.glob(os.path.join(self._report_dir, "*.txt")) |
| 197 old_files = glob.glob(os.path.join(out, "*.txt")) | |
| 198 for f in old_files: | 197 for f in old_files: |
| 199 os.remove(f) | 198 os.remove(f) |
| 200 else: | 199 else: |
| 201 os.makedirs(out) | 200 os.makedirs(self._report_dir) |
| 202 out = os.path.join(out, "%s%%5d.txt" % name) | 201 out_file = os.path.join(self._report_dir, "%s%%5d.txt" % name) |
| 203 cmd.append("--out_file=%s" % out) | 202 cmd.append("--out_file=%s" % out_file) |
| 204 if cmd_args: | 203 if cmd_args: |
| 205 cmd.extend(cmd_args) | 204 cmd.extend(cmd_args) |
| 206 if script[0] != "python.exe" and not os.path.exists(script[0]): | 205 if script[0] != "python.exe" and not os.path.exists(script[0]): |
| 207 script[0] = os.path.join(self._options.build_dir, script[0]) | 206 script[0] = os.path.join(self._options.build_dir, script[0]) |
| 208 cmd.extend(script) | 207 cmd.extend(script) |
| 209 self._ReadGtestFilterFile(name, cmd) | 208 self._ReadGtestFilterFile(name, cmd) |
| 210 return common.RunSubprocess(cmd, 0) | 209 return common.RunSubprocess(cmd, 0) |
| 211 | 210 |
| 212 def InstrumentDll(self): | 211 def InstrumentDll(self): |
| 213 '''Does a blocking Purify instrumentation of chrome.dll.''' | 212 '''Does a blocking Purify instrumentation of chrome.dll.''' |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 script_cmd.append("--test-list=%s" % self._args[0]) | 282 script_cmd.append("--test-list=%s" % self._args[0]) |
| 284 else: | 283 else: |
| 285 script_cmd.extend(self._args) | 284 script_cmd.extend(self._args) |
| 286 | 285 |
| 287 if run_all: | 286 if run_all: |
| 288 ret = self.ScriptedTest("webkit", "test_shell.exe", "layout", | 287 ret = self.ScriptedTest("webkit", "test_shell.exe", "layout", |
| 289 script_cmd, multi=True, cmd_args=["--timeout=0"]) | 288 script_cmd, multi=True, cmd_args=["--timeout=0"]) |
| 290 return ret | 289 return ret |
| 291 | 290 |
| 292 # store each chunk in its own directory so that we can find the data later | 291 # store each chunk in its own directory so that we can find the data later |
| 293 chunk_dir = os.path.join("layout", "chunk_%05d" % chunk_num) | 292 chunk_dir = os.path.join("chunk_%05d" % chunk_num) |
| 294 ret = self.ScriptedTest("webkit", "test_shell.exe", "layout", | 293 ret = self.ScriptedTest("webkit", "test_shell.exe", "layout", |
| 295 script_cmd, multi=True, cmd_args=["--timeout=0"], | 294 script_cmd, multi=True, cmd_args=["--timeout=0"], |
| 296 out_dir_extra=chunk_dir) | 295 out_dir_extra=chunk_dir) |
| 297 | 296 |
| 298 # Wait until after the test runs to completion to write out the new chunk | 297 # Wait until after the test runs to completion to write out the new chunk |
| 299 # number. This way, if the bot is killed, we'll start running again from | 298 # number. This way, if the bot is killed, we'll start running again from |
| 300 # the current chunk rather than skipping it. | 299 # the current chunk rather than skipping it. |
| 301 try: | 300 try: |
| 302 f = open(chunk_file, "w") | 301 f = open(chunk_file, "w") |
| 303 chunk_num += 1 | 302 chunk_num += 1 |
| 304 f.write("%d" % chunk_num) | 303 f.write("%d" % chunk_num) |
| 305 f.close() | 304 f.close() |
| 306 except IOError, (errno, strerror): | 305 except IOError, (errno, strerror): |
| 307 logging.error("error writing to file %s (%d, %s)" % (chunk_file, errno, | 306 logging.error("error writing to file %s (%d, %s)" % (chunk_file, errno, |
| 308 strerror)) | 307 strerror)) |
| 309 # Since we're running small chunks of the layout tests, it's important to | 308 # Since we're running small chunks of the layout tests, it's important to |
| 310 # mark the ones that have errors in them. These won't be visible in the | 309 # mark the ones that have errors in them. These won't be visible in the |
| 311 # summary list for long, but will be useful for someone reviewing this bot. | 310 # summary list for long, but will be useful for someone reviewing this bot. |
| 312 return ret | 311 #return ret |
| 312 # For now, since a fair number of layout tests are still red, we'll use the |
| 313 # magic orange indicator return code to avoid making the tree look red when |
| 314 # nothing has changed. When We get the layout tests into a stable green, |
| 315 # this code should be undone. |
| 316 # BUG=7516 |
| 317 if ret: |
| 318 return -88 |
| 319 return 0 |
| 313 | 320 |
| 314 def TestUI(self): | 321 def TestUI(self): |
| 315 if not self._options.no_reinstrument: | 322 if not self._options.no_reinstrument: |
| 316 instrumentation_error = self.InstrumentDll() | 323 instrumentation_error = self.InstrumentDll() |
| 317 if instrumentation_error: | 324 if instrumentation_error: |
| 318 return instrumentation_error | 325 return instrumentation_error |
| 319 return self.ScriptedTest("chrome", "chrome.exe", "ui_tests", | 326 return self.ScriptedTest("chrome", "chrome.exe", "ui_tests", |
| 320 ["ui_tests.exe", | 327 ["ui_tests.exe", |
| 321 "--single-process", | 328 "--single-process", |
| 322 "--ui-test-timeout=180000", | 329 "--ui-test-timeout=180000", |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 tests = ChromeTests(options, args, t) | 371 tests = ChromeTests(options, args, t) |
| 365 ret = tests.Run() | 372 ret = tests.Run() |
| 366 if ret: return ret | 373 if ret: return ret |
| 367 return 0 | 374 return 0 |
| 368 | 375 |
| 369 | 376 |
| 370 if __name__ == "__main__": | 377 if __name__ == "__main__": |
| 371 ret = _main(sys.argv) | 378 ret = _main(sys.argv) |
| 372 sys.exit(ret) | 379 sys.exit(ret) |
| 373 | 380 |
| OLD | NEW |