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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 if (!temp_dir.CreateUniqueTempDir() || !temp_dir.IsValid()) { | 346 if (!temp_dir.CreateUniqueTempDir() || !temp_dir.IsValid()) { |
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; |
| 357 options.process_handle = &process_handle; |
| 358 |
356 #if defined(OS_POSIX) | 359 #if defined(OS_POSIX) |
357 const char* browser_wrapper = getenv("BROWSER_WRAPPER"); | 360 const char* browser_wrapper = getenv("BROWSER_WRAPPER"); |
358 if (browser_wrapper) { | 361 if (browser_wrapper) { |
359 new_cmd_line.PrependWrapper(browser_wrapper); | 362 new_cmd_line.PrependWrapper(browser_wrapper); |
360 VLOG(1) << "BROWSER_WRAPPER was set, prefixing command_line with " | 363 VLOG(1) << "BROWSER_WRAPPER was set, prefixing command_line with " |
361 << browser_wrapper; | 364 << browser_wrapper; |
362 } | 365 } |
363 | 366 |
364 // On POSIX, we launch the test in a new process group with pgid equal to | 367 // On POSIX, we launch the test in a new process group with pgid equal to |
365 // its pid. Any child processes that the test may create will inherit the | 368 // its pid. Any child processes that the test may create will inherit the |
366 // same pgid. This way, if the test is abruptly terminated, we can clean up | 369 // same pgid. This way, if the test is abruptly terminated, we can clean up |
367 // any orphaned child processes it may have left behind. | 370 // any orphaned child processes it may have left behind. |
368 base::environment_vector no_env; | 371 options.new_process_group = true; |
369 base::file_handle_mapping_vector no_files; | 372 #endif |
370 if (!base::LaunchAppInNewProcessGroup(new_cmd_line.argv(), no_env, no_files, | 373 |
371 false, &process_handle)) | 374 if (!base::LaunchProcess(new_cmd_line, options)) |
372 return false; | 375 return false; |
373 #else | |
374 if (!base::LaunchApp(new_cmd_line, false, false, &process_handle)) | |
375 return false; | |
376 #endif | |
377 | 376 |
378 int timeout_ms = | 377 int timeout_ms = |
379 test_launcher_utils::GetTestTerminationTimeout(test_name, | 378 test_launcher_utils::GetTestTerminationTimeout(test_name, |
380 default_timeout_ms); | 379 default_timeout_ms); |
381 | 380 |
382 int exit_code = 0; | 381 int exit_code = 0; |
383 if (!base::WaitForExitCodeWithTimeout(process_handle, &exit_code, | 382 if (!base::WaitForExitCodeWithTimeout(process_handle, &exit_code, |
384 timeout_ms)) { | 383 timeout_ms)) { |
385 LOG(ERROR) << "Test timeout (" << timeout_ms | 384 LOG(ERROR) << "Test timeout (" << timeout_ms |
386 << " ms) exceeded for " << test_name; | 385 << " ms) exceeded for " << test_name; |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 exit_code = 1; | 642 exit_code = 1; |
644 break; | 643 break; |
645 } | 644 } |
646 | 645 |
647 // Special value "-1" means "repeat indefinitely". | 646 // Special value "-1" means "repeat indefinitely". |
648 if (cycles != -1) | 647 if (cycles != -1) |
649 cycles--; | 648 cycles--; |
650 } | 649 } |
651 return exit_code; | 650 return exit_code; |
652 } | 651 } |
OLD | NEW |