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

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

Issue 441333002: Disallow breakaway from job for unit tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months 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
Index: base/test/launcher/test_launcher.cc
diff --git a/base/test/launcher/test_launcher.cc b/base/test/launcher/test_launcher.cc
index 56ed4a27024bd95cfcd87a237a46fe54c9d9be0b..bc477b7f59f30ec6203e0013570ab5446c2d7ae3 100644
--- a/base/test/launcher/test_launcher.cc
+++ b/base/test/launcher/test_launcher.cc
@@ -49,6 +49,7 @@ namespace base {
int LaunchChildTestProcessWithOptions(const CommandLine& command_line,
const LaunchOptions& options,
bool use_job_objects,
+ bool allow_breakaway,
base::TimeDelta timeout,
bool* was_timeout);
@@ -224,6 +225,7 @@ void DoLaunchChildTestProcess(
const CommandLine& command_line,
base::TimeDelta timeout,
bool use_job_objects,
+ bool allow_breakaway,
bool redirect_stdio,
scoped_refptr<MessageLoopProxy> message_loop_proxy,
const TestLauncher::LaunchChildGTestProcessCallback& callback) {
@@ -275,7 +277,8 @@ void DoLaunchChildTestProcess(
bool was_timeout = false;
int exit_code = LaunchChildTestProcessWithOptions(
- command_line, options, use_job_objects, timeout, &was_timeout);
+ command_line, options, use_job_objects, allow_breakaway,
+ timeout, &was_timeout);
if (redirect_stdio) {
#if defined(OS_WIN)
@@ -410,6 +413,7 @@ void TestLauncher::LaunchChildGTestProcess(
const std::string& wrapper,
base::TimeDelta timeout,
bool use_job_objects,
+ bool allow_breakaway,
const LaunchChildGTestProcessCallback& callback) {
DCHECK(thread_checker_.CalledOnValidThread());
@@ -428,6 +432,7 @@ void TestLauncher::LaunchChildGTestProcess(
new_command_line,
timeout,
use_job_objects,
+ allow_breakaway,
redirect_stdio,
MessageLoopProxy::current(),
Bind(&TestLauncher::OnLaunchTestProcessFinished,
@@ -1005,6 +1010,7 @@ CommandLine PrepareCommandLineForGTest(const CommandLine& command_line,
int LaunchChildTestProcessWithOptions(const CommandLine& command_line,
const LaunchOptions& options,
bool use_job_objects,
+ bool allow_breakaway,
base::TimeDelta timeout,
bool* was_timeout) {
#if defined(OS_POSIX)
@@ -1025,12 +1031,16 @@ int LaunchChildTestProcessWithOptions(const CommandLine& command_line,
return -1;
}
+ DWORD flags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
+
// Allow break-away from job since sandbox and few other places rely on it
// on Windows versions prior to Windows 8 (which supports nested jobs).
// TODO(phajdan.jr): Do not allow break-away on Windows 8.
- if (!SetJobObjectLimitFlags(job_handle.Get(),
- JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE |
- JOB_OBJECT_LIMIT_BREAKAWAY_OK)) {
+ if (allow_breakaway) {
sky 2014/08/06 17:58:49 nit: no {}
Paweł Hajdan Jr. 2014/08/07 12:17:41 Done.
+ flags |= JOB_OBJECT_LIMIT_BREAKAWAY_OK;
+ }
+
+ if (!SetJobObjectLimitFlags(job_handle.Get(), flags)) {
LOG(ERROR) << "Could not SetJobObjectLimitFlags.";
return -1;
}

Powered by Google App Engine
This is Rietveld 408576698