OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/test/launcher/test_launcher.h" | 5 #include "base/test/launcher/test_launcher.h" |
6 | 6 |
7 #if defined(OS_POSIX) | 7 #if defined(OS_POSIX) |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include "base/test/test_switches.h" | 34 #include "base/test/test_switches.h" |
35 #include "base/test/test_timeouts.h" | 35 #include "base/test/test_timeouts.h" |
36 #include "base/threading/thread_checker.h" | 36 #include "base/threading/thread_checker.h" |
37 #include "base/time/time.h" | 37 #include "base/time/time.h" |
38 #include "testing/gtest/include/gtest/gtest.h" | 38 #include "testing/gtest/include/gtest/gtest.h" |
39 | 39 |
40 #if defined(OS_MACOSX) | 40 #if defined(OS_MACOSX) |
41 #include "base/mac/scoped_nsautorelease_pool.h" | 41 #include "base/mac/scoped_nsautorelease_pool.h" |
42 #endif | 42 #endif |
43 | 43 |
| 44 #if defined(OS_WIN) |
| 45 #include "base/win/windows_version.h" |
| 46 #endif |
| 47 |
44 namespace base { | 48 namespace base { |
45 | 49 |
46 // Launches a child process using |command_line|. If the child process is still | 50 // Launches a child process using |command_line|. If the child process is still |
47 // running after |timeout|, it is terminated and |*was_timeout| is set to true. | 51 // running after |timeout|, it is terminated and |*was_timeout| is set to true. |
48 // Returns exit code of the process. | 52 // Returns exit code of the process. |
49 int LaunchChildTestProcessWithOptions(const CommandLine& command_line, | 53 int LaunchChildTestProcessWithOptions(const CommandLine& command_line, |
50 const LaunchOptions& options, | 54 const LaunchOptions& options, |
51 int flags, | 55 int flags, |
52 base::TimeDelta timeout, | 56 base::TimeDelta timeout, |
53 bool* was_timeout); | 57 bool* was_timeout); |
(...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1027 job_handle.Set(CreateJobObject(NULL, NULL)); | 1031 job_handle.Set(CreateJobObject(NULL, NULL)); |
1028 if (!job_handle.IsValid()) { | 1032 if (!job_handle.IsValid()) { |
1029 LOG(ERROR) << "Could not create JobObject."; | 1033 LOG(ERROR) << "Could not create JobObject."; |
1030 return -1; | 1034 return -1; |
1031 } | 1035 } |
1032 | 1036 |
1033 DWORD job_flags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE; | 1037 DWORD job_flags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE; |
1034 | 1038 |
1035 // Allow break-away from job since sandbox and few other places rely on it | 1039 // Allow break-away from job since sandbox and few other places rely on it |
1036 // on Windows versions prior to Windows 8 (which supports nested jobs). | 1040 // on Windows versions prior to Windows 8 (which supports nested jobs). |
1037 // TODO(phajdan.jr): Do not allow break-away on Windows 8. | 1041 if (win::GetVersion() < win::VERSION_WIN8 && |
1038 if (flags & TestLauncher::ALLOW_BREAKAWAY_FROM_JOB) | 1042 flags & TestLauncher::ALLOW_BREAKAWAY_FROM_JOB) { |
1039 job_flags |= JOB_OBJECT_LIMIT_BREAKAWAY_OK; | 1043 job_flags |= JOB_OBJECT_LIMIT_BREAKAWAY_OK; |
| 1044 } |
1040 | 1045 |
1041 if (!SetJobObjectLimitFlags(job_handle.Get(), job_flags)) { | 1046 if (!SetJobObjectLimitFlags(job_handle.Get(), job_flags)) { |
1042 LOG(ERROR) << "Could not SetJobObjectLimitFlags."; | 1047 LOG(ERROR) << "Could not SetJobObjectLimitFlags."; |
1043 return -1; | 1048 return -1; |
1044 } | 1049 } |
1045 | 1050 |
1046 new_options.job_handle = job_handle.Get(); | 1051 new_options.job_handle = job_handle.Get(); |
1047 } | 1052 } |
1048 #endif // defined(OS_WIN) | 1053 #endif // defined(OS_WIN) |
1049 | 1054 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1097 | 1102 |
1098 g_live_processes.Get().erase(process_handle); | 1103 g_live_processes.Get().erase(process_handle); |
1099 } | 1104 } |
1100 | 1105 |
1101 base::CloseProcessHandle(process_handle); | 1106 base::CloseProcessHandle(process_handle); |
1102 | 1107 |
1103 return exit_code; | 1108 return exit_code; |
1104 } | 1109 } |
1105 | 1110 |
1106 } // namespace base | 1111 } // namespace base |
OLD | NEW |