| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/environment.h" | 9 #include "base/environment.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 LOG(ERROR) << "Error creating temp profile directory"; | 347 LOG(ERROR) << "Error creating temp profile directory"; |
| 348 return false; | 348 return false; |
| 349 } | 349 } |
| 350 new_cmd_line.AppendSwitchPath(switches::kUserDataDir, temp_dir.path()); | 350 new_cmd_line.AppendSwitchPath(switches::kUserDataDir, temp_dir.path()); |
| 351 | 351 |
| 352 // file:// access for ChromeOS. | 352 // file:// access for ChromeOS. |
| 353 new_cmd_line.AppendSwitch(switches::kAllowFileAccess); | 353 new_cmd_line.AppendSwitch(switches::kAllowFileAccess); |
| 354 | 354 |
| 355 base::ProcessHandle process_handle; | 355 base::ProcessHandle process_handle; |
| 356 base::LaunchOptions options; | 356 base::LaunchOptions options; |
| 357 options.process_handle = &process_handle; | |
| 358 | 357 |
| 359 #if defined(OS_POSIX) | 358 #if defined(OS_POSIX) |
| 360 const char* browser_wrapper = getenv("BROWSER_WRAPPER"); | 359 const char* browser_wrapper = getenv("BROWSER_WRAPPER"); |
| 361 if (browser_wrapper) { | 360 if (browser_wrapper) { |
| 362 new_cmd_line.PrependWrapper(browser_wrapper); | 361 new_cmd_line.PrependWrapper(browser_wrapper); |
| 363 VLOG(1) << "BROWSER_WRAPPER was set, prefixing command_line with " | 362 VLOG(1) << "BROWSER_WRAPPER was set, prefixing command_line with " |
| 364 << browser_wrapper; | 363 << browser_wrapper; |
| 365 } | 364 } |
| 366 | 365 |
| 367 // On POSIX, we launch the test in a new process group with pgid equal to | 366 // On POSIX, we launch the test in a new process group with pgid equal to |
| 368 // its pid. Any child processes that the test may create will inherit the | 367 // its pid. Any child processes that the test may create will inherit the |
| 369 // same pgid. This way, if the test is abruptly terminated, we can clean up | 368 // same pgid. This way, if the test is abruptly terminated, we can clean up |
| 370 // any orphaned child processes it may have left behind. | 369 // any orphaned child processes it may have left behind. |
| 371 options.new_process_group = true; | 370 options.new_process_group = true; |
| 372 #endif | 371 #endif |
| 373 | 372 |
| 374 if (!base::LaunchProcess(new_cmd_line, options)) | 373 if (!base::LaunchProcess(new_cmd_line, options, &process_handle)) |
| 375 return false; | 374 return false; |
| 376 | 375 |
| 377 int timeout_ms = | 376 int timeout_ms = |
| 378 test_launcher_utils::GetTestTerminationTimeout(test_name, | 377 test_launcher_utils::GetTestTerminationTimeout(test_name, |
| 379 default_timeout_ms); | 378 default_timeout_ms); |
| 380 | 379 |
| 381 int exit_code = 0; | 380 int exit_code = 0; |
| 382 if (!base::WaitForExitCodeWithTimeout(process_handle, &exit_code, | 381 if (!base::WaitForExitCodeWithTimeout(process_handle, &exit_code, |
| 383 timeout_ms)) { | 382 timeout_ms)) { |
| 384 LOG(ERROR) << "Test timeout (" << timeout_ms | 383 LOG(ERROR) << "Test timeout (" << timeout_ms |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 exit_code = 1; | 641 exit_code = 1; |
| 643 break; | 642 break; |
| 644 } | 643 } |
| 645 | 644 |
| 646 // Special value "-1" means "repeat indefinitely". | 645 // Special value "-1" means "repeat indefinitely". |
| 647 if (cycles != -1) | 646 if (cycles != -1) |
| 648 cycles--; | 647 cycles--; |
| 649 } | 648 } |
| 650 return exit_code; | 649 return exit_code; |
| 651 } | 650 } |
| OLD | NEW |