diff options
author | nsylvain@chromium.org <nsylvain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-25 21:02:35 +0000 |
---|---|---|
committer | nsylvain@chromium.org <nsylvain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-25 21:02:35 +0000 |
commit | b5fcde45e2826c6500275bdbe539a0176974892d (patch) | |
tree | 06ac2217569931a139117e2f67f92270d69569e9 /tools/purify | |
parent | c7c21e231ada54e575c6aed8336cea16e1eac82f (diff) | |
download | chromium_src-b5fcde45e2826c6500275bdbe539a0176974892d.zip chromium_src-b5fcde45e2826c6500275bdbe539a0176974892d.tar.gz chromium_src-b5fcde45e2826c6500275bdbe539a0176974892d.tar.bz2 |
Run the unit tests in 5 chunks instead of just 1.
BUG:19833
Review URL: http://codereview.chromium.org/212040
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27244 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/purify')
-rw-r--r-- | tools/purify/chrome_tests.py | 25 | ||||
-rw-r--r-- | tools/purify/sharded_test_runner.py | 33 |
2 files changed, 50 insertions, 8 deletions
diff --git a/tools/purify/chrome_tests.py b/tools/purify/chrome_tests.py index 7b808a5..0484d8d 100644 --- a/tools/purify/chrome_tests.py +++ b/tools/purify/chrome_tests.py @@ -103,7 +103,7 @@ class ChromeTests: return dir_chrome elif os.path.isfile(exe_module) and not os.path.isfile(exe_chrome): return dir_module - elif (os.stat(exe_module)[stat.ST_MTIME] > + elif (os.stat(exe_module)[stat.ST_MTIME] > os.stat(exe_chrome)[stat.ST_MTIME]): return dir_module else: @@ -211,16 +211,25 @@ class ChromeTests: if gtest_filter: cmd.append("--gtest_filter=%s" % gtest_filter) - def SimpleTest(self, module, name): + def SimpleTest(self, module, name, total_shards=None): cmd = self._DefaultCommand(module, name) - if not self._options.run_singly: + exe = cmd[-1] + current_path = os.path.dirname(sys.argv[0]) + + # TODO(nsylvain): Add a flag to disable this. + if total_shards: + script = ["python.exe", + os.path.join(current_path, "sharded_test_runner.py"), exe, + str(total_shards)] + return self.ScriptedTest(module, name, name, script, multi=True) + elif self._options.run_singly: + script = ["python.exe", + os.path.join(current_path, "test_runner.py"), exe] + return self.ScriptedTest(module, name, name, script, multi=True) + else: 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): @@ -289,7 +298,7 @@ class ChromeTests: return self.SimpleTest("webkit", "test_shell_tests.exe") def TestUnit(self): - return self.SimpleTest("chrome", "unit_tests.exe") + return self.SimpleTest("chrome", "unit_tests.exe", total_shards=5) def TestLayoutAll(self): return self.TestLayout(run_all=True) diff --git a/tools/purify/sharded_test_runner.py b/tools/purify/sharded_test_runner.py new file mode 100644 index 0000000..e7f5ecf --- /dev/null +++ b/tools/purify/sharded_test_runner.py @@ -0,0 +1,33 @@ +#!/bin/env python +# Copyright (c) 2009 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. + +# sharded_test_runner + +import optparse +import os +import re +import subprocess +import sys + +import common + +def RunShardedTests(exe, total_shards, params): + os.environ['GTEST_TOTAL_SHARDS'] = str(total_shards) + for shard in range(total_shards): + os.environ['GTEST_SHARD_INDEX'] = str(shard) + cmd = [exe] + cmd.extend(params) + common.RunSubprocess(cmd) + + +def main(): + exe = sys.argv[1] + total_shards = int(sys.argv[2]) + params = sys.argv[3:] + RunShardedTests(exe, total_shards, params) + + +if __name__ == "__main__": + main() |