| 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 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 if test not in self._test_list: | 42 if test not in self._test_list: |
| 43 raise TestNotFound("Unknown test: %s" % test) | 43 raise TestNotFound("Unknown test: %s" % test) |
| 44 | 44 |
| 45 self._options = options | 45 self._options = options |
| 46 self._args = args | 46 self._args = args |
| 47 self._test = test | 47 self._test = test |
| 48 | 48 |
| 49 script_dir = google.path_utils.ScriptDir() | 49 script_dir = google.path_utils.ScriptDir() |
| 50 utility = google.platform_utils.PlatformUtility(script_dir) | 50 utility = google.platform_utils.PlatformUtility(script_dir) |
| 51 |
| 51 # Compute the top of the tree (the "source dir") from the script dir (where | 52 # Compute the top of the tree (the "source dir") from the script dir (where |
| 52 # this script lives). We assume that the script dir is in tools/purify | 53 # this script lives). We assume that the script dir is in tools/purify |
| 53 # relative to the top of the tree. | 54 # relative to the top of the tree. |
| 54 self._source_dir = os.path.dirname(os.path.dirname(script_dir)) | 55 self._source_dir = os.path.dirname(os.path.dirname(script_dir)) |
| 56 |
| 55 # 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 |
| 56 # an absolute Windows-style path | 58 # an absolute Windows-style path |
| 57 self._source_dir = utility.GetAbsolutePath(self._source_dir) | 59 self._source_dir = utility.GetAbsolutePath(self._source_dir) |
| 60 |
| 61 self._report_dir = options.report_dir |
| 62 if not self._report_dir: |
| 63 if not options.buildbot: |
| 64 self._report_dir = os.path.join(script_dir, "latest") |
| 65 else: |
| 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. |
| 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 |
| 70 # scripts/* to your PYTHONPATH to test outside of the buildbot. |
| 71 import slave_utils |
| 72 import chromium_config |
| 73 chrome_web_dir = chromium_config.Archive.purify_test_result_archive |
| 74 current_version = str(slave_utils.SubversionRevision(self._source_dir)) |
| 75 # This line is how the buildbot master figures out our directory. |
| 76 print "last change:", current_version |
| 77 self._report_dir = os.path.join(chrome_web_dir, test,current_version) |
| 78 if not os.path.exists(self._report_dir): |
| 79 os.makedirs(self._report_dir) |
| 80 |
| 58 purify_test = os.path.join(script_dir, "purify_test.py") | 81 purify_test = os.path.join(script_dir, "purify_test.py") |
| 59 self._command_preamble = ["python.exe", purify_test, "--echo_to_stdout", | 82 self._command_preamble = ["python.exe", purify_test, "--echo_to_stdout", |
| 60 "--source_dir=%s" % (self._source_dir), | 83 "--source_dir=%s" % (self._source_dir), |
| 84 "--report_dir=%s" % (self._report_dir), |
| 61 "--save_cache"] | 85 "--save_cache"] |
| 62 | 86 |
| 63 def _DefaultCommand(self, module, exe=None): | 87 def _DefaultCommand(self, module, exe=None): |
| 64 '''Generates the default command array that most tests will use.''' | 88 '''Generates the default command array that most tests will use.''' |
| 65 module_dir = os.path.join(self._source_dir, module) | 89 module_dir = os.path.join(self._source_dir, module) |
| 66 if module == "chrome": | 90 if module == "chrome": |
| 67 # unfortunately, not all modules have the same directory structure | 91 # unfortunately, not all modules have the same directory structure |
| 68 self._data_dir = os.path.join(module_dir, "test", "data", "purify") | 92 self._data_dir = os.path.join(module_dir, "test", "data", "purify") |
| 69 else: | 93 else: |
| 70 self._data_dir = os.path.join(module_dir, "data", "purify") | 94 self._data_dir = os.path.join(module_dir, "data", "purify") |
| 95 |
| 71 if not self._options.build_dir: | 96 if not self._options.build_dir: |
| 72 dir_chrome = os.path.join(self._source_dir, "chrome", "Release") | 97 dir_chrome = os.path.join(self._source_dir, "chrome", "Release") |
| 73 dir_module = os.path.join(module_dir, "Release") | 98 dir_module = os.path.join(module_dir, "Release") |
| 74 if exe: | 99 if exe: |
| 75 exe_chrome = os.path.join(dir_chrome, exe) | 100 exe_chrome = os.path.join(dir_chrome, exe) |
| 76 exe_module = os.path.join(dir_module, exe) | 101 exe_module = os.path.join(dir_module, exe) |
| 77 if os.path.isfile(exe_chrome) and not os.path.isfile(exe_module): | 102 if os.path.isfile(exe_chrome) and not os.path.isfile(exe_module): |
| 78 self._options.build_dir = dir_chrome | 103 self._options.build_dir = dir_chrome |
| 79 elif os.path.isfile(exe_module) and not os.path.isfile(exe_chrome): | 104 elif os.path.isfile(exe_module) and not os.path.isfile(exe_chrome): |
| 80 self._options.build_dir = dir_module | 105 self._options.build_dir = dir_module |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 if not self._options.no_reinstrument: | 315 if not self._options.no_reinstrument: |
| 291 instrumentation_error = self.InstrumentDll() | 316 instrumentation_error = self.InstrumentDll() |
| 292 if instrumentation_error: | 317 if instrumentation_error: |
| 293 return instrumentation_error | 318 return instrumentation_error |
| 294 return self.ScriptedTest("chrome", "chrome.exe", "ui_tests", | 319 return self.ScriptedTest("chrome", "chrome.exe", "ui_tests", |
| 295 ["ui_tests.exe", | 320 ["ui_tests.exe", |
| 296 "--single-process", | 321 "--single-process", |
| 297 "--ui-test-timeout=180000", | 322 "--ui-test-timeout=180000", |
| 298 "--ui-test-action-timeout=80000", | 323 "--ui-test-action-timeout=80000", |
| 299 "--ui-test-action-max-timeout=180000", | 324 "--ui-test-action-max-timeout=180000", |
| 300 » » » "--ui-test-sleep-timeout=40000"], | 325 "--ui-test-sleep-timeout=40000"], |
| 301 multi=True) | 326 multi=True) |
| 302 | 327 |
| 303 | 328 |
| 304 def _main(argv): | 329 def _main(argv): |
| 305 parser = optparse.OptionParser("usage: %prog -b <dir> -t <test> " | 330 parser = optparse.OptionParser("usage: %prog -b <dir> -t <test> " |
| 306 "[-t <test> ...]") | 331 "[-t <test> ...]") |
| 307 parser.disable_interspersed_args() | 332 parser.disable_interspersed_args() |
| 308 parser.add_option("-b", "--build_dir", | 333 parser.add_option("-b", "--build_dir", |
| 309 help="the location of the output of the compiler output") | 334 help="the location of the output of the compiler output") |
| 310 parser.add_option("-t", "--test", action="append", | 335 parser.add_option("-t", "--test", action="append", |
| 311 help="which test to run") | 336 help="which test to run") |
| 312 parser.add_option("", "--baseline", action="store_true", default=False, | 337 parser.add_option("", "--baseline", action="store_true", default=False, |
| 313 help="generate baseline data instead of validating") | 338 help="generate baseline data instead of validating") |
| 314 parser.add_option("", "--gtest_filter", | 339 parser.add_option("", "--gtest_filter", |
| 315 help="additional arguments to --gtest_filter") | 340 help="additional arguments to --gtest_filter") |
| 316 parser.add_option("-v", "--verbose", action="store_true", default=False, | 341 parser.add_option("-v", "--verbose", action="store_true", default=False, |
| 317 help="verbose output - enable debug log messages") | 342 help="verbose output - enable debug log messages") |
| 318 parser.add_option("", "--no-reinstrument", action="store_true", default=False, | 343 parser.add_option("", "--no-reinstrument", action="store_true", default=False, |
| 319 help="Don't force a re-instrumentation for ui_tests") | 344 help="Don't force a re-instrumentation for ui_tests") |
| 320 parser.add_option("", "--run-singly", action="store_true", default=False, | 345 parser.add_option("", "--run-singly", action="store_true", default=False, |
| 321 help="run tests independently of each other so that they " | 346 help="run tests independently of each other so that they " |
| 322 "don't interfere with each other and so that errors " | 347 "don't interfere with each other and so that errors " |
| 323 "can be accurately attributed to their source"); | 348 "can be accurately attributed to their source"); |
| 349 parser.add_option("", "--report_dir", |
| 350 help="path where report files are saved") |
| 351 parser.add_option("", "--buildbot", action="store_true", default=False, |
| 352 help="whether we're being run in a buildbot environment") |
| 324 options, args = parser.parse_args() | 353 options, args = parser.parse_args() |
| 325 | 354 |
| 326 if options.verbose: | 355 if options.verbose: |
| 327 google.logging_utils.config_root(logging.DEBUG) | 356 google.logging_utils.config_root(logging.DEBUG) |
| 328 else: | 357 else: |
| 329 google.logging_utils.config_root() | 358 google.logging_utils.config_root() |
| 330 | 359 |
| 331 if not options.test or not len(options.test): | 360 if not options.test or not len(options.test): |
| 332 parser.error("--test not specified") | 361 parser.error("--test not specified") |
| 333 | 362 |
| 334 for t in options.test: | 363 for t in options.test: |
| 335 tests = ChromeTests(options, args, t) | 364 tests = ChromeTests(options, args, t) |
| 336 ret = tests.Run() | 365 ret = tests.Run() |
| 337 if ret: return ret | 366 if ret: return ret |
| 338 return 0 | 367 return 0 |
| 339 | 368 |
| 340 | 369 |
| 341 if __name__ == "__main__": | 370 if __name__ == "__main__": |
| 342 ret = _main(sys.argv) | 371 ret = _main(sys.argv) |
| 343 sys.exit(ret) | 372 sys.exit(ret) |
| 344 | 373 |
| OLD | NEW |