diff options
author | huanr@chromium.org <huanr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-10 23:04:21 +0000 |
---|---|---|
committer | huanr@chromium.org <huanr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-10 23:04:21 +0000 |
commit | ed1c9da9c46143da81c9449719b51b2b6fbc0e97 (patch) | |
tree | 7acd9fbab70f7ec056f515f9219be4264ba9e465 /chrome/test | |
parent | b40cd8793cea3e4e95f0dea05cf9ee3c84941d77 (diff) | |
download | chromium_src-ed1c9da9c46143da81c9449719b51b2b6fbc0e97.zip chromium_src-ed1c9da9c46143da81c9449719b51b2b6fbc0e97.tar.gz chromium_src-ed1c9da9c46143da81c9449719b51b2b6fbc0e97.tar.bz2 |
Adding command line switch to run UI test in parallel.
BUG=16006
TEST=none
Review URL: http://codereview.chromium.org/149445
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20435 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r-- | chrome/test/ui/ui_test_suite.cc | 34 | ||||
-rw-r--r-- | chrome/test/ui/ui_test_suite.h | 4 |
2 files changed, 38 insertions, 0 deletions
diff --git a/chrome/test/ui/ui_test_suite.cc b/chrome/test/ui/ui_test_suite.cc index 3ff0fef..691a75f 100644 --- a/chrome/test/ui/ui_test_suite.cc +++ b/chrome/test/ui/ui_test_suite.cc @@ -15,6 +15,12 @@ const wchar_t UITestSuite::kUseExistingBrowser[] = L"use-existing-browser"; // Timeout for the test in milliseconds. UI tests only. const wchar_t UITestSuite::kTestTimeout[] = L"test-timeout"; +// Parameters to run test in parallel. UI tests only. +const wchar_t UITestSuite::kBatchCount[] = L"batch-count"; +const wchar_t UITestSuite::kBatchIndex[] = L"batch-index"; +const char UITestSuite::kGTestTotalShards[] = "GTEST_TOTAL_SHARDS="; +const char UITestSuite::kGTestShardIndex[] = "GTEST_SHARD_INDEX="; + UITestSuite::UITestSuite(int argc, char** argv) : ChromeTestSuite(argc, argv) { @@ -50,6 +56,34 @@ void UITestSuite::Initialize() { if (!test_timeout.empty()) { UITest::set_test_timeout_ms(StringToInt(WideToUTF16Hack(test_timeout))); } + +#if defined(OS_WIN) + int batch_count = 0; + int batch_index = 0; + std::wstring batch_count_str = + parsed_command_line.GetSwitchValue(UITestSuite::kBatchCount); + if (!batch_count_str.empty()) { + batch_count = StringToInt(WideToUTF16Hack(batch_count_str)); + } + std::wstring batch_index_str = + parsed_command_line.GetSwitchValue(UITestSuite::kBatchIndex); + if (!batch_index_str.empty()) { + batch_index = StringToInt(WideToUTF16Hack(batch_index_str)); + } + if (batch_count > 0 && batch_index >= 0 && batch_index < batch_count) { + // Running UI test in parallel. Gtest supports running tests in shards, + // and every UI test instance is running with different user data dir. + // Thus all we need to do is to set up environment variables for gtest. + // See http://code.google.com/p/googletest/wiki/GoogleTestAdvancedGuide. + std::string batch_count_env(UITestSuite::kGTestTotalShards); + batch_count_env.append(WideToASCII(batch_count_str)); + std::string batch_index_env(UITestSuite::kGTestShardIndex); + batch_index_env.append(WideToASCII(batch_index_str)); + _putenv(batch_count_env.c_str()); + _putenv(batch_index_env.c_str()); + } +#endif + std::wstring js_flags = parsed_command_line.GetSwitchValue(switches::kJavaScriptFlags); if (!js_flags.empty()) { diff --git a/chrome/test/ui/ui_test_suite.h b/chrome/test/ui/ui_test_suite.h index 7da80fa..b5771cb 100644 --- a/chrome/test/ui/ui_test_suite.h +++ b/chrome/test/ui/ui_test_suite.h @@ -29,6 +29,10 @@ class UITestSuite : public ChromeTestSuite { static const wchar_t kUseExistingBrowser[]; static const wchar_t kTestTimeout[]; + static const wchar_t kBatchCount[]; + static const wchar_t kBatchIndex[]; + static const char kGTestTotalShards[]; + static const char kGTestShardIndex[]; }; #endif // CHROME_TEST_UI_UI_TEST_SUITE_H_ |