Commit 35833b71 authored by machenbach's avatar machenbach Committed by Commit bot

[swarming] Let v8 test driver use gtest environment variables for shards.

BUG=chromium:535160
LOG=n
NOTRY=true

Review URL: https://codereview.chromium.org/1395343002

Cr-Commit-Position: refs/heads/master@{#31207}
parent 0c2dff29
......@@ -458,7 +458,27 @@ def ProcessOptions(options):
return True
def ShardTests(tests, shard_count, shard_run):
def ShardTests(tests, options):
# Read gtest shard configuration from environment (e.g. set by swarming).
# If none is present, use values passed on the command line.
shard_count = int(os.environ.get('GTEST_TOTAL_SHARDS', options.shard_count))
shard_run = os.environ.get('GTEST_SHARD_INDEX')
if shard_run is not None:
# The v8 shard_run starts at 1, while GTEST_SHARD_INDEX starts at 0.
shard_run = int(shard_run) + 1
else:
shard_run = options.shard_run
if options.shard_count > 1:
# Log if a value was passed on the cmd line and it differs from the
# environment variables.
if options.shard_count != shard_count:
print("shard_count from cmd line differs from environment variable "
"GTEST_TOTAL_SHARDS")
if options.shard_run > 1 and options.shard_run != shard_run:
print("shard_run from cmd line differs from environment variable "
"GTEST_SHARD_INDEX")
if shard_count < 2:
return tests
if shard_run < 1 or shard_run > shard_count:
......@@ -650,7 +670,7 @@ def Execute(arch, mode, args, options, suites, workspace):
else:
s.tests = variant_tests
s.tests = ShardTests(s.tests, options.shard_count, options.shard_run)
s.tests = ShardTests(s.tests, options)
num_tests += len(s.tests)
if options.cat:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment