| OLD | NEW |
| 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 """ | 14 """ |
| 15 | 15 |
| 16 | 16 |
| 17 from cStringIO import StringIO | 17 from cStringIO import StringIO |
| 18 import optparse | 18 import optparse |
| 19 import os | 19 import os |
| 20 import pty | |
| 21 import Queue | 20 import Queue |
| 22 import random | 21 import random |
| 23 import re | 22 import re |
| 24 import subprocess | 23 import subprocess |
| 25 import sys | 24 import sys |
| 26 import threading | 25 import threading |
| 27 | 26 |
| 28 | 27 |
| 29 SS_USAGE = "Usage: python %prog [options] path/to/test [gtest_args]" | 28 SS_USAGE = "python %prog [options] path/to/test [gtest_args]" |
| 30 SS_DEFAULT_NUM_CORES = 4 | 29 SS_DEFAULT_NUM_CORES = 4 |
| 31 SS_DEFAULT_SHARDS_PER_CORE = 5 # num_shards = cores * SHARDS_PER_CORE | 30 SS_DEFAULT_SHARDS_PER_CORE = 5 # num_shards = cores * SHARDS_PER_CORE |
| 32 SS_DEFAULT_RUNS_PER_CORE = 1 # num_workers = cores * RUNS_PER_CORE | 31 SS_DEFAULT_RUNS_PER_CORE = 1 # num_workers = cores * RUNS_PER_CORE |
| 33 | 32 |
| 34 | 33 |
| 35 def DetectNumCores(): | 34 def DetectNumCores(): |
| 36 """Detects the number of cores on the machine. | 35 """Detects the number of cores on the machine. |
| 37 | 36 |
| 38 Returns: | 37 Returns: |
| 39 The number of cores on the machine or DEFAULT_NUM_CORES if it could not | 38 The number of cores on the machine or DEFAULT_NUM_CORES if it could not |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 | 343 |
| 345 # shard and run the whole test | 344 # shard and run the whole test |
| 346 ss = ShardingSupervisor(args[0], num_shards, num_runs, options.color, | 345 ss = ShardingSupervisor(args[0], num_shards, num_runs, options.color, |
| 347 options.reorder, gtest_args) | 346 options.reorder, gtest_args) |
| 348 return ss.ShardTest() | 347 return ss.ShardTest() |
| 349 | 348 |
| 350 | 349 |
| 351 if __name__ == "__main__": | 350 if __name__ == "__main__": |
| 352 sys.exit(main()) | 351 sys.exit(main()) |
| 353 | 352 |
| OLD | NEW |