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

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: fix 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
« no previous file with comments | « base/test/launcher/test_launcher.h ('k') | base/test/launcher/unit_test_launcher.cc » ('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 ca60cbacea0da7ea79ffbe31f0844b902d2be630..af505a55d8dd31bafbf39cc5d776ac0577dbba47 100644
--- a/base/test/launcher/test_launcher.cc
+++ b/base/test/launcher/test_launcher.cc
@@ -48,7 +48,7 @@ namespace base {
// Returns exit code of the process.
int LaunchChildTestProcessWithOptions(const CommandLine& command_line,
const LaunchOptions& options,
- bool use_job_objects,
+ int flags,
base::TimeDelta timeout,
bool* was_timeout);
@@ -223,7 +223,7 @@ void RunCallback(
void DoLaunchChildTestProcess(
const CommandLine& command_line,
base::TimeDelta timeout,
- bool use_job_objects,
+ int flags,
bool redirect_stdio,
scoped_refptr<MessageLoopProxy> message_loop_proxy,
const TestLauncher::LaunchChildGTestProcessCallback& callback) {
@@ -275,7 +275,7 @@ void DoLaunchChildTestProcess(
bool was_timeout = false;
int exit_code = LaunchChildTestProcessWithOptions(
- command_line, options, use_job_objects, timeout, &was_timeout);
+ command_line, options, flags, timeout, &was_timeout);
if (redirect_stdio) {
#if defined(OS_WIN)
@@ -409,7 +409,7 @@ void TestLauncher::LaunchChildGTestProcess(
const CommandLine& command_line,
const std::string& wrapper,
base::TimeDelta timeout,
- bool use_job_objects,
+ int flags,
const LaunchChildGTestProcessCallback& callback) {
DCHECK(thread_checker_.CalledOnValidThread());
@@ -427,7 +427,7 @@ void TestLauncher::LaunchChildGTestProcess(
Bind(&DoLaunchChildTestProcess,
new_command_line,
timeout,
- use_job_objects,
+ flags,
redirect_stdio,
MessageLoopProxy::current(),
Bind(&TestLauncher::OnLaunchTestProcessFinished,
@@ -1009,7 +1009,7 @@ CommandLine PrepareCommandLineForGTest(const CommandLine& command_line,
// TODO(phajdan.jr): Move to anonymous namespace.
int LaunchChildTestProcessWithOptions(const CommandLine& command_line,
const LaunchOptions& options,
- bool use_job_objects,
+ int flags,
base::TimeDelta timeout,
bool* was_timeout) {
#if defined(OS_POSIX)
@@ -1023,19 +1023,22 @@ int LaunchChildTestProcessWithOptions(const CommandLine& command_line,
DCHECK(!new_options.job_handle);
win::ScopedHandle job_handle;
- if (use_job_objects) {
+ if (flags & TestLauncher::USE_JOB_OBJECTS) {
job_handle.Set(CreateJobObject(NULL, NULL));
if (!job_handle.IsValid()) {
LOG(ERROR) << "Could not create JobObject.";
return -1;
}
+ DWORD job_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 (flags & TestLauncher::ALLOW_BREAKAWAY_FROM_JOB)
+ job_flags |= JOB_OBJECT_LIMIT_BREAKAWAY_OK;
+
+ if (!SetJobObjectLimitFlags(job_handle.Get(), job_flags)) {
LOG(ERROR) << "Could not SetJobObjectLimitFlags.";
return -1;
}
« no previous file with comments | « base/test/launcher/test_launcher.h ('k') | base/test/launcher/unit_test_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698