Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(535)

Side by Side Diff: tools/sharding_supervisor/sharding_supervisor.py

Issue 7312026: Moved sharding_supervisor (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/tools/sharding_supervisor/sharding_supervisor.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 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 """Shards a given test suite and runs the shards in parallel. 6 """Shards a given test suite and runs the shards in parallel.
7 7
8 ShardingSupervisor is called to process the command line options and creates 8 ShardingSupervisor is called to process the command line options and creates
9 the specified number of worker threads. These threads then run each shard of 9 the specified number of worker threads. These threads then run each shard of
10 the test in a separate process and report on the results. When all the shards 10 the test in a separate process and report on the results. When all the shards
11 have been completed, the supervisor reprints any lines indicating a test 11 have been completed, the supervisor reprints any lines indicating a test
12 failure for convenience. If only one shard is to be run, a single subprocess 12 failure for convenience. If only one shard is to be run, a single subprocess
13 is started for that shard and the output is identical to gtest's output. 13 is started for that shard and the output is identical to gtest's output.
14
15 Usage: python sharding_supervisor.py [options] path/to/test [gtest_args]
16 """ 14 """
17 15
18 16
19 import optparse 17 import optparse
20 import os 18 import os
21 import pty 19 import pty
22 import Queue 20 import Queue
23 import subprocess 21 import subprocess
24 import sys 22 import sys
25 import threading 23 import threading
26 24
27 25
26 USAGE = "Usage: python %prog [options] path/to/test [gtest_args]"
28 DEFAULT_NUM_CORES = 4 27 DEFAULT_NUM_CORES = 4
29 DEFAULT_SHARDS_PER_CORE = 5 # num_shards = cores * SHARDS_PER_CORE 28 DEFAULT_SHARDS_PER_CORE = 5 # num_shards = cores * SHARDS_PER_CORE
30 DEFAULT_RUNS_PER_CORE = 1 # num_workers = cores * RUNS_PER_CORE 29 DEFAULT_RUNS_PER_CORE = 1 # num_workers = cores * RUNS_PER_CORE
31 30
32 31
33 def DetectNumCores(): 32 def DetectNumCores():
34 """Detects the number of cores on the machine. 33 """Detects the number of cores on the machine.
35 34
36 Returns: 35 Returns:
37 The number of cores on the machine or DEFAULT_NUM_CORES if it could not 36 The number of cores on the machine or DEFAULT_NUM_CORES if it could not
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 if self.color: 200 if self.color:
202 sys.stderr.write("\x1b[0;37m") 201 sys.stderr.write("\x1b[0;37m")
203 for line in self.failure_log: 202 for line in self.failure_log:
204 sys.stderr.write(line) 203 sys.stderr.write(line)
205 if self.color: 204 if self.color:
206 sys.stderr.write("\x1b[0;37m") 205 sys.stderr.write("\x1b[0;37m")
207 return num_failed 206 return num_failed
208 207
209 208
210 def main(): 209 def main():
211 parser = optparse.OptionParser() 210 parser = optparse.OptionParser(usage=USAGE)
212 parser.add_option( 211 parser.add_option(
213 "-n", "--shards_per_core", type="int", default=DEFAULT_SHARDS_PER_CORE, 212 "-n", "--shards_per_core", type="int", default=DEFAULT_SHARDS_PER_CORE,
214 help="number of shards to generate per CPU") 213 help="number of shards to generate per CPU")
215 parser.add_option( 214 parser.add_option(
216 "-r", "--runs_per_core", type="int", default=DEFAULT_RUNS_PER_CORE, 215 "-r", "--runs_per_core", type="int", default=DEFAULT_RUNS_PER_CORE,
217 help="number of shards to run in parallel per CPU") 216 help="number of shards to run in parallel per CPU")
218 parser.add_option( 217 parser.add_option(
219 "-c", "--color", action="store_true", default=sys.stdout.isatty(), 218 "-c", "--color", action="store_true", default=sys.stdout.isatty(),
220 help="force color output, also used by gtest if --gtest_color is not" 219 help="force color output, also used by gtest if --gtest_color is not"
221 " specified") 220 " specified")
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 255
257 # shard and run the whole test 256 # shard and run the whole test
258 ss = ShardingSupervisor( 257 ss = ShardingSupervisor(
259 args[0], num_shards, num_runs, options.color, gtest_args) 258 args[0], num_shards, num_runs, options.color, gtest_args)
260 return ss.ShardTest() 259 return ss.ShardTest()
261 260
262 261
263 if __name__ == "__main__": 262 if __name__ == "__main__":
264 sys.exit(main()) 263 sys.exit(main())
265 264
OLDNEW
« no previous file with comments | « chrome/tools/sharding_supervisor/sharding_supervisor.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698