diff options
author | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-13 16:48:01 +0000 |
---|---|---|
committer | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-13 16:48:01 +0000 |
commit | 2ccbdbe2508fdf17fde95a96ee197d45faabe467 (patch) | |
tree | 073278da9dc4dceaf8a9e1ff282fb7828260d268 /tools/purify | |
parent | acde9211abf5810732c49da3cfad7ce14650d5a0 (diff) | |
download | chromium_src-2ccbdbe2508fdf17fde95a96ee197d45faabe467.zip chromium_src-2ccbdbe2508fdf17fde95a96ee197d45faabe467.tar.gz chromium_src-2ccbdbe2508fdf17fde95a96ee197d45faabe467.tar.bz2 |
A simple one-at-a-time test runner that can be driven by chrome_tests.py.
This allows memory errors to be isolated to a particular test and a crash
in one test to affect the tests of others.
Review URL: http://codereview.chromium.org/17634
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7938 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/purify')
-rw-r--r-- | tools/purify/chrome_tests.py | 15 | ||||
-rw-r--r-- | tools/purify/test_runner.py | 51 |
2 files changed, 64 insertions, 2 deletions
diff --git a/tools/purify/chrome_tests.py b/tools/purify/chrome_tests.py index fe30c3b..ce3e268 100644 --- a/tools/purify/chrome_tests.py +++ b/tools/purify/chrome_tests.py @@ -134,8 +134,14 @@ class ChromeTests: def SimpleTest(self, module, name): cmd = self._DefaultCommand(module, name) - self._ReadGtestFilterFile(name, cmd) - return common.RunSubprocess(cmd, 0) + if not self._options.run_singly: + self._ReadGtestFilterFile(name, cmd) + cmd.append("--gtest_print_time") + return common.RunSubprocess(cmd, 0) + else: + exe = cmd[-1] + script = ["python.exe", "test_runner.py", exe] + return self.ScriptedTest(module, exe, name, script, multi=True) def ScriptedTest(self, module, exe, name, script, multi=False, cmd_args=None, out_dir_extra=None): @@ -176,6 +182,7 @@ class ChromeTests: script[0] = os.path.join(self._options.build_dir, script[0]) cmd.extend(script) self._ReadGtestFilterFile(name, cmd) + cmd.append("--gtest_print_time") return common.RunSubprocess(cmd, 0) def InstrumentDll(self): @@ -310,6 +317,10 @@ def _main(argv): help="verbose output - enable debug log messages") parser.add_option("", "--no-reinstrument", action="store_true", default=False, help="Don't force a re-instrumentation for ui_tests") + parser.add_option("", "--run-singly", action="store_true", default=False, + help="run tests independently of each other so that they " + "don't interfere with each other and so that errors " + "can be accurately attributed to their source"); options, args = parser.parse_args() if options.verbose: diff --git a/tools/purify/test_runner.py b/tools/purify/test_runner.py new file mode 100644 index 0000000..78ab615 --- /dev/null +++ b/tools/purify/test_runner.py @@ -0,0 +1,51 @@ +#!/bin/env python +# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# test_runner + +import optparse +import os +import re +import subprocess +import sys + +import google.logging_utils +import google.path_utils + +import common + + +def GetAllTests(exe): + cmd = [exe, "--gtest_list_tests"] + p = subprocess.Popen(cmd, stdout=subprocess.PIPE) + line = p.stdout.readline().rstrip() + test = line + tests = [] + while line: + line = p.stdout.readline().rstrip() + if line.startswith(' '): + tests.append(test + line.lstrip()) + else: + test = line + return tests + + +def RunTestsSingly(exe, tests): + for test in tests: + filter = test + if len(sys.argv) > 2: + filter = filter + ":" + sys.argv[2] + cmd = [exe, "--gtest_filter=" + filter] + common.RunSubprocess(cmd) + + +def main(): + exe = sys.argv[1] + all_tests = GetAllTests(exe) + RunTestsSingly(exe, all_tests) + + +if __name__ == "__main__": + main() |