| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #define _CRT_SECURE_NO_WARNINGS | 5 #define _CRT_SECURE_NO_WARNINGS |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 base::LaunchOptions options; | 600 base::LaunchOptions options; |
| 601 options.wait = true; | 601 options.wait = true; |
| 602 options.environ = env_changes; | 602 options.environ = env_changes; |
| 603 options.clear_environ = clear_environ; | 603 options.clear_environ = clear_environ; |
| 604 options.fds_to_remap = &fds_to_remap; | 604 options.fds_to_remap = &fds_to_remap; |
| 605 #if defined(OS_LINUX) | 605 #if defined(OS_LINUX) |
| 606 options.clone_flags = clone_flags; | 606 options.clone_flags = clone_flags; |
| 607 #else | 607 #else |
| 608 CHECK_EQ(0, clone_flags); | 608 CHECK_EQ(0, clone_flags); |
| 609 #endif // OS_LINUX | 609 #endif // OS_LINUX |
| 610 EXPECT_TRUE(base::LaunchProcess(args, options, NULL)); | 610 EXPECT_TRUE(base::LaunchProcess(args, options).IsValid()); |
| 611 PCHECK(IGNORE_EINTR(close(fds[1])) == 0); | 611 PCHECK(IGNORE_EINTR(close(fds[1])) == 0); |
| 612 | 612 |
| 613 char buf[512]; | 613 char buf[512]; |
| 614 const ssize_t n = HANDLE_EINTR(read(fds[0], buf, sizeof(buf))); | 614 const ssize_t n = HANDLE_EINTR(read(fds[0], buf, sizeof(buf))); |
| 615 | 615 |
| 616 PCHECK(IGNORE_EINTR(close(fds[0])) == 0); | 616 PCHECK(IGNORE_EINTR(close(fds[0])) == 0); |
| 617 | 617 |
| 618 return std::string(buf, n); | 618 return std::string(buf, n); |
| 619 } | 619 } |
| 620 | 620 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 | 672 |
| 673 env_changes[kBaseTest] = "wibble"; | 673 env_changes[kBaseTest] = "wibble"; |
| 674 EXPECT_EQ("wibble\n", | 674 EXPECT_EQ("wibble\n", |
| 675 TestLaunchProcess( | 675 TestLaunchProcess( |
| 676 echo_base_test, env_changes, no_clear_environ, no_clone_flags)); | 676 echo_base_test, env_changes, no_clear_environ, no_clone_flags)); |
| 677 | 677 |
| 678 #if defined(OS_LINUX) | 678 #if defined(OS_LINUX) |
| 679 // Test a non-trival value for clone_flags. | 679 // Test a non-trival value for clone_flags. |
| 680 // Don't test on Valgrind as it has limited support for clone(). | 680 // Don't test on Valgrind as it has limited support for clone(). |
| 681 if (!RunningOnValgrind()) { | 681 if (!RunningOnValgrind()) { |
| 682 EXPECT_EQ( | 682 EXPECT_EQ("wibble\n", TestLaunchProcess(echo_base_test, env_changes, |
| 683 "wibble\n", | 683 no_clear_environ, CLONE_FS)); |
| 684 TestLaunchProcess( | |
| 685 echo_base_test, env_changes, no_clear_environ, CLONE_FS | SIGCHLD)); | |
| 686 } | 684 } |
| 687 | 685 |
| 688 EXPECT_EQ( | 686 EXPECT_EQ( |
| 689 "BASE_TEST=wibble\n", | 687 "BASE_TEST=wibble\n", |
| 690 TestLaunchProcess( | 688 TestLaunchProcess( |
| 691 print_env, env_changes, true /* clear_environ */, no_clone_flags)); | 689 print_env, env_changes, true /* clear_environ */, no_clone_flags)); |
| 692 env_changes.clear(); | 690 env_changes.clear(); |
| 693 EXPECT_EQ( | 691 EXPECT_EQ( |
| 694 "", | 692 "", |
| 695 TestLaunchProcess( | 693 TestLaunchProcess( |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 | 907 |
| 910 // Check that process was really killed. | 908 // Check that process was really killed. |
| 911 EXPECT_TRUE(IsProcessDead(child_process.Handle())); | 909 EXPECT_TRUE(IsProcessDead(child_process.Handle())); |
| 912 } | 910 } |
| 913 | 911 |
| 914 MULTIPROCESS_TEST_MAIN(process_util_test_die_immediately) { | 912 MULTIPROCESS_TEST_MAIN(process_util_test_die_immediately) { |
| 915 return 0; | 913 return 0; |
| 916 } | 914 } |
| 917 | 915 |
| 918 #endif // defined(OS_POSIX) | 916 #endif // defined(OS_POSIX) |
| OLD | NEW |