summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorphajdan.jr <phajdan.jr@chromium.org>2015-10-30 04:44:57 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-30 11:45:45 +0000
commitb265c2ebb2408257f1fb5c01d5811b35e9e67db0 (patch)
tree480298d7cb8b6a07a982cb0c874d4a0be6371630 /base
parent31bb6eef8786a9c8847fcc7850db367c751af194 (diff)
downloadchromium_src-b265c2ebb2408257f1fb5c01d5811b35e9e67db0.zip
chromium_src-b265c2ebb2408257f1fb5c01d5811b35e9e67db0.tar.gz
chromium_src-b265c2ebb2408257f1fb5c01d5811b35e9e67db0.tar.bz2
Support disabling unit test batching. Use it for angle_end2end_tests
This is a reland of https://codereview.chromium.org/1209243004 Depends on https://codereview.chromium.org/1430633002 TBR=piman, kbr BUG=501604, 509883 Review URL: https://codereview.chromium.org/1418113010 Cr-Commit-Position: refs/heads/master@{#357083}
Diffstat (limited to 'base')
-rw-r--r--base/test/launcher/unit_test_launcher.cc46
-rw-r--r--base/test/launcher/unit_test_launcher.h13
2 files changed, 50 insertions, 9 deletions
diff --git a/base/test/launcher/unit_test_launcher.cc b/base/test/launcher/unit_test_launcher.cc
index 761dcfd..9cd7d71 100644
--- a/base/test/launcher/unit_test_launcher.cc
+++ b/base/test/launcher/unit_test_launcher.cc
@@ -158,7 +158,7 @@ bool GetSwitchValueAsInt(const std::string& switch_name, int* result) {
std::string switch_value =
CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switch_name);
- if (!StringToInt(switch_value, result) || *result < 1) {
+ if (!StringToInt(switch_value, result) || *result < 0) {
LOG(ERROR) << "Invalid value for " << switch_name << ": " << switch_value;
return false;
}
@@ -168,6 +168,7 @@ bool GetSwitchValueAsInt(const std::string& switch_name, int* result) {
int LaunchUnitTestsInternal(const RunTestSuiteCallback& run_test_suite,
int default_jobs,
+ int default_batch_limit,
bool use_job_objects,
const Closure& gtest_init) {
#if defined(OS_ANDROID)
@@ -210,7 +211,7 @@ int LaunchUnitTestsInternal(const RunTestSuiteCallback& run_test_suite,
gtest_init.Run();
TestTimeouts::Initialize();
- int batch_limit = kDefaultTestBatchLimit;
+ int batch_limit = default_batch_limit;
if (!GetSwitchValueAsInt(switches::kTestLauncherBatchLimit, &batch_limit))
return 1;
@@ -435,16 +436,40 @@ int LaunchUnitTests(int argc,
char** argv,
const RunTestSuiteCallback& run_test_suite) {
CommandLine::Init(argc, argv);
- return LaunchUnitTestsInternal(run_test_suite, SysInfo::NumberOfProcessors(),
- true, Bind(&InitGoogleTestChar, &argc, argv));
+ return LaunchUnitTestsInternal(
+ run_test_suite,
+ SysInfo::NumberOfProcessors(),
+ kDefaultTestBatchLimit,
+ true,
+ Bind(&InitGoogleTestChar, &argc, argv));
}
int LaunchUnitTestsSerially(int argc,
char** argv,
const RunTestSuiteCallback& run_test_suite) {
CommandLine::Init(argc, argv);
- return LaunchUnitTestsInternal(run_test_suite, 1, true,
- Bind(&InitGoogleTestChar, &argc, argv));
+ return LaunchUnitTestsInternal(
+ run_test_suite,
+ 1,
+ kDefaultTestBatchLimit,
+ true,
+ Bind(&InitGoogleTestChar, &argc, argv));
+}
+
+int LaunchUnitTestsWithOptions(
+ int argc,
+ char** argv,
+ int default_jobs,
+ int default_batch_limit,
+ bool use_job_objects,
+ const RunTestSuiteCallback& run_test_suite) {
+ CommandLine::Init(argc, argv);
+ return LaunchUnitTestsInternal(
+ run_test_suite,
+ default_jobs,
+ default_batch_limit,
+ use_job_objects,
+ Bind(&InitGoogleTestChar, &argc, argv));
}
#if defined(OS_WIN)
@@ -454,9 +479,12 @@ int LaunchUnitTests(int argc,
const RunTestSuiteCallback& run_test_suite) {
// Windows CommandLine::Init ignores argv anyway.
CommandLine::Init(argc, NULL);
- return LaunchUnitTestsInternal(run_test_suite, SysInfo::NumberOfProcessors(),
- use_job_objects,
- Bind(&InitGoogleTestWChar, &argc, argv));
+ return LaunchUnitTestsInternal(
+ run_test_suite,
+ SysInfo::NumberOfProcessors(),
+ kDefaultTestBatchLimit,
+ use_job_objects,
+ Bind(&InitGoogleTestWChar, &argc, argv));
}
#endif // defined(OS_WIN)
diff --git a/base/test/launcher/unit_test_launcher.h b/base/test/launcher/unit_test_launcher.h
index d5ba153..83e5eaf 100644
--- a/base/test/launcher/unit_test_launcher.h
+++ b/base/test/launcher/unit_test_launcher.h
@@ -24,6 +24,19 @@ int LaunchUnitTestsSerially(int argc,
char** argv,
const RunTestSuiteCallback& run_test_suite);
+// Launches unit tests in given test suite. Returns exit code.
+// |default_jobs| is the default number of parallel test jobs.
+// |default_batch_limit| is the default size of test batch
+// (use 0 to disable batching).
+// |use_job_objects| determines whether to use job objects.
+int LaunchUnitTestsWithOptions(
+ int argc,
+ char** argv,
+ int default_jobs,
+ int default_batch_limit,
+ bool use_job_objects,
+ const RunTestSuiteCallback& run_test_suite);
+
#if defined(OS_WIN)
// Launches unit tests in given test suite. Returns exit code.
// |use_job_objects| determines whether to use job objects.