diff options
author | huanr@chromium.org <huanr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-29 21:15:55 +0000 |
---|---|---|
committer | huanr@chromium.org <huanr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-29 21:15:55 +0000 |
commit | 6cd42b6d1de1feaed37a14062f56952a91632317 (patch) | |
tree | da94eab30d2767c53bff169894a6d2aa453d5f60 /chrome/tools | |
parent | 839575632d4a75a63c7b803f81dbdf83683546e1 (diff) | |
download | chromium_src-6cd42b6d1de1feaed37a14062f56952a91632317.zip chromium_src-6cd42b6d1de1feaed37a14062f56952a91632317.tar.gz chromium_src-6cd42b6d1de1feaed37a14062f56952a91632317.tar.bz2 |
Update smoketests.py so we can run ui_tests in parallel, with
the number of shards equal to NUMBER_OF_PROCESSORS.
Review URL: http://codereview.chromium.org/159568
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21996 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/tools')
-rwxr-xr-x | chrome/tools/test/smoketests.py | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/chrome/tools/test/smoketests.py b/chrome/tools/test/smoketests.py index 50ddd83..f0513df 100755 --- a/chrome/tools/test/smoketests.py +++ b/chrome/tools/test/smoketests.py @@ -109,6 +109,39 @@ def _MakeSubstitutions(list, options): return [word % substitutions for word in list] +def RunTestsInShards(test_command, verbose=True): + """Runs a test in shards. The number of shards is equal to + NUMBER_OF_PROCESSORS. + + Args: + test_command: the test command to run, which is a list of one or more + strings. + verbose: if True, combines stdout and stderr into stdout. + Otherwise, prints only the command's stderr to stdout. + + Returns: + The first shard process's exit status. + + Raises: + CommandNotFound if the command executable could not be found. + """ + processor_count = 2 + try: + processor_count = int(os.environ['NUMBER_OF_PROCESSORS']) + except KeyError: + print 'No NUMBER_OF_PROCESSORS defined. Use 2 instances.' + + commands = [] + for i in xrange(processor_count): + command = [test_command[j] for j in xrange(len(test_command))] + # To support sharding, the test executable needs to provide --batch-count + # --batch-index command line switches. + command.append('--batch-count=%s' % processor_count) + command.append('--batch-index=%d' % i) + commands.append(command) + return google.process_utils.RunCommandsInParallel(commands, verbose)[0][0] + + def main(options, args): """Runs all the selected tests for the given build type and target.""" options.build_type = options.build_type.lower() @@ -184,7 +217,10 @@ def main(options, args): print print 'Running %s:' % test, try: - result = google.process_utils.RunCommand(command, options.verbose) + if test == 'ui': + result = RunTestsInShards(command, options.verbose) + else: + result = google.process_utils.RunCommand(command, options.verbose) except google.process_utils.CommandNotFound, e: print '%s' % e raise |