summaryrefslogtreecommitdiffstats
path: root/base/test
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-05 01:06:08 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-05 01:06:08 +0000
commit5855fe8532df55631a4d2a8b6c81644cc7f89abb (patch)
tree35c2ded4c6b8149fd1d0679fcb3ca86c2e0016db /base/test
parenta0878513f95d69ba84f1553ed7879982b6d32b94 (diff)
downloadchromium_src-5855fe8532df55631a4d2a8b6c81644cc7f89abb.zip
chromium_src-5855fe8532df55631a4d2a8b6c81644cc7f89abb.tar.gz
chromium_src-5855fe8532df55631a4d2a8b6c81644cc7f89abb.tar.bz2
GTTF: Make it possible to pass sharding settings from command line.
This overrides any environment variables (a message is printed that clearly says which settings are applied). Main rationale is that runtest.py is well suited to pass command line flags but not environment variables. BUG=236893 R=sky@chromium.org Review URL: https://codereview.chromium.org/58413003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232869 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/test')
-rw-r--r--base/test/launcher/test_launcher.cc38
-rw-r--r--base/test/test_switches.cc9
-rw-r--r--base/test/test_switches.h2
3 files changed, 44 insertions, 5 deletions
diff --git a/base/test/launcher/test_launcher.cc b/base/test/launcher/test_launcher.cc
index 0076634..1d0c8fe 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";
diff --git a/base/test/test_switches.cc b/base/test/test_switches.cc
index 18b4881..50b4513 100644
--- a/base/test/test_switches.cc
+++ b/base/test/test_switches.cc
@@ -26,6 +26,15 @@ const char switches::kTestLauncherSummaryOutput[] =
const char switches::kTestLauncherPrintTestStdio[] =
"test-launcher-print-test-stdio";
+// Index of the test shard to run, starting from 0 (first shard) to total shards
+// minus one (last shard).
+const char switches::kTestLauncherShardIndex[] =
+ "test-launcher-shard-index";
+
+// Total number of shards. Must be the same for all shards.
+const char switches::kTestLauncherTotalShards[] =
+ "test-launcher-total-shards";
+
// Time (in milliseconds) that the tests should wait before timing out.
const char switches::kTestLauncherTimeout[] = "test-launcher-timeout";
// TODO(phajdan.jr): Clean up the switch names.
diff --git a/base/test/test_switches.h b/base/test/test_switches.h
index 330b925..a492058 100644
--- a/base/test/test_switches.h
+++ b/base/test/test_switches.h
@@ -15,6 +15,8 @@ extern const char kTestLauncherJobs[];
extern const char kTestLauncherOutput[];
extern const char kTestLauncherSummaryOutput[];
extern const char kTestLauncherPrintTestStdio[];
+extern const char kTestLauncherShardIndex[];
+extern const char kTestLauncherTotalShards[];
extern const char kTestLauncherTimeout[];
extern const char kTestTinyTimeout[];
extern const char kUiTestActionTimeout[];