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

Unified Diff: base/test/launcher/test_launcher.cc

Issue 58413003: GTTF: Make it possible to pass sharding settings from command line. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/test/test_switches.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/launcher/test_launcher.cc
diff --git a/base/test/launcher/test_launcher.cc b/base/test/launcher/test_launcher.cc
index 00766347c8e8818cbb8cbd6b1c6edf193cd59247..1d0c8fe6e6755dbfdb5aa8387ef78e427eb3c4ec 100644
--- a/base/test/launcher/test_launcher.cc
+++ b/base/test/launcher/test_launcher.cc
@@ -552,14 +552,42 @@ bool TestLauncher::Init() {
return false;
}
- if (!TakeInt32FromEnvironment(kTestTotalShards, &total_shards_))
- return false;
- if (!TakeInt32FromEnvironment(kTestShardIndex, &shard_index_))
- return false;
+ // Initialize sharding. Command line takes precedence over legacy environment
+ // variables.
+ if (command_line->HasSwitch(switches::kTestLauncherTotalShards) &&
+ command_line->HasSwitch(switches::kTestLauncherShardIndex)) {
+ if (!StringToInt(
+ command_line->GetSwitchValueASCII(
+ switches::kTestLauncherTotalShards),
+ &total_shards_)) {
+ LOG(ERROR) << "Invalid value for " << switches::kTestLauncherTotalShards;
+ return false;
+ }
+ if (!StringToInt(
+ command_line->GetSwitchValueASCII(
+ switches::kTestLauncherShardIndex),
+ &shard_index_)) {
+ LOG(ERROR) << "Invalid value for " << switches::kTestLauncherShardIndex;
+ return false;
+ }
+ fprintf(stdout,
+ "Using sharding settings from command line. This is shard %d/%d\n",
+ shard_index_, total_shards_);
+ fflush(stdout);
+ } else {
+ if (!TakeInt32FromEnvironment(kTestTotalShards, &total_shards_))
+ return false;
+ if (!TakeInt32FromEnvironment(kTestShardIndex, &shard_index_))
+ return false;
+ fprintf(stdout,
+ "Using sharding settings from environment. This is shard %d/%d\n",
+ shard_index_, total_shards_);
+ fflush(stdout);
+ }
if (shard_index_ < 0 ||
total_shards_ < 0 ||
shard_index_ >= total_shards_) {
- LOG(ERROR) << "Invalid environment variables: we require 0 <= "
+ LOG(ERROR) << "Invalid sharding settings: we require 0 <= "
<< kTestShardIndex << " < " << kTestTotalShards
<< ", but you have " << kTestShardIndex << "=" << shard_index_
<< ", " << kTestTotalShards << "=" << total_shards_ << ".\n";
« no previous file with comments | « no previous file | base/test/test_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698