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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 std::string message; | 357 std::string message; |
358 for (int i = 0; i < 1025; i++) { // 1025 so it does not end on a kilo-byte | 358 for (int i = 0; i < 1025; i++) { // 1025 so it does not end on a kilo-byte |
359 // boundary. | 359 // boundary. |
360 message += "Hello!"; | 360 message += "Hello!"; |
361 } | 361 } |
362 // cmd.exe's echo always adds a \r\n to its output. | 362 // cmd.exe's echo always adds a \r\n to its output. |
363 std::string expected(message); | 363 std::string expected(message); |
364 expected += "\r\n"; | 364 expected += "\r\n"; |
365 | 365 |
366 FilePath cmd(L"cmd.exe"); | 366 FilePath cmd(L"cmd.exe"); |
367 CommandLine cmd_line(cmd); | 367 base::CommandLine cmd_line(cmd); |
368 cmd_line.AppendArg("/c"); | 368 cmd_line.AppendArg("/c"); |
369 cmd_line.AppendArg("echo " + message + ""); | 369 cmd_line.AppendArg("echo " + message + ""); |
370 std::string output; | 370 std::string output; |
371 ASSERT_TRUE(base::GetAppOutput(cmd_line, &output)); | 371 ASSERT_TRUE(base::GetAppOutput(cmd_line, &output)); |
372 EXPECT_EQ(expected, output); | 372 EXPECT_EQ(expected, output); |
373 | 373 |
374 // Let's make sure stderr is ignored. | 374 // Let's make sure stderr is ignored. |
375 CommandLine other_cmd_line(cmd); | 375 base::CommandLine other_cmd_line(cmd); |
376 other_cmd_line.AppendArg("/c"); | 376 other_cmd_line.AppendArg("/c"); |
377 // http://msdn.microsoft.com/library/cc772622.aspx | 377 // http://msdn.microsoft.com/library/cc772622.aspx |
378 cmd_line.AppendArg("echo " + message + " >&2"); | 378 cmd_line.AppendArg("echo " + message + " >&2"); |
379 output.clear(); | 379 output.clear(); |
380 ASSERT_TRUE(base::GetAppOutput(other_cmd_line, &output)); | 380 ASSERT_TRUE(base::GetAppOutput(other_cmd_line, &output)); |
381 EXPECT_EQ("", output); | 381 EXPECT_EQ("", output); |
382 } | 382 } |
383 | 383 |
384 // TODO(estade): if possible, port this test. | 384 // TODO(estade): if possible, port this test. |
385 TEST_F(ProcessUtilTest, LaunchAsUser) { | 385 TEST_F(ProcessUtilTest, LaunchAsUser) { |
386 base::UserTokenHandle token; | 386 base::UserTokenHandle token; |
387 ASSERT_TRUE(OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &token)); | 387 ASSERT_TRUE(OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &token)); |
388 base::LaunchOptions options; | 388 base::LaunchOptions options; |
389 options.as_user = token; | 389 options.as_user = token; |
390 EXPECT_TRUE(base::LaunchProcess(MakeCmdLine("SimpleChildProcess"), options, | 390 EXPECT_TRUE(base::LaunchProcess(MakeCmdLine("SimpleChildProcess"), options, |
391 NULL)); | 391 NULL)); |
392 } | 392 } |
393 | 393 |
394 static const char kEventToTriggerHandleSwitch[] = "event-to-trigger-handle"; | 394 static const char kEventToTriggerHandleSwitch[] = "event-to-trigger-handle"; |
395 | 395 |
396 MULTIPROCESS_TEST_MAIN(TriggerEventChildProcess) { | 396 MULTIPROCESS_TEST_MAIN(TriggerEventChildProcess) { |
397 std::string handle_value_string = | 397 std::string handle_value_string = |
398 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 398 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
399 kEventToTriggerHandleSwitch); | 399 kEventToTriggerHandleSwitch); |
400 CHECK(!handle_value_string.empty()); | 400 CHECK(!handle_value_string.empty()); |
401 | 401 |
402 uint64 handle_value_uint64; | 402 uint64 handle_value_uint64; |
403 CHECK(base::StringToUint64(handle_value_string, &handle_value_uint64)); | 403 CHECK(base::StringToUint64(handle_value_string, &handle_value_uint64)); |
404 // Give ownership of the handle to |event|. | 404 // Give ownership of the handle to |event|. |
405 base::WaitableEvent event(reinterpret_cast<HANDLE>(handle_value_uint64)); | 405 base::WaitableEvent event(reinterpret_cast<HANDLE>(handle_value_uint64)); |
406 | 406 |
407 event.Signal(); | 407 event.Signal(); |
408 | 408 |
409 return 0; | 409 return 0; |
410 } | 410 } |
411 | 411 |
412 TEST_F(ProcessUtilTest, InheritSpecifiedHandles) { | 412 TEST_F(ProcessUtilTest, InheritSpecifiedHandles) { |
413 // Manually create the event, so that it can be inheritable. | 413 // Manually create the event, so that it can be inheritable. |
414 SECURITY_ATTRIBUTES security_attributes = {}; | 414 SECURITY_ATTRIBUTES security_attributes = {}; |
415 security_attributes.nLength = static_cast<DWORD>(sizeof(security_attributes)); | 415 security_attributes.nLength = static_cast<DWORD>(sizeof(security_attributes)); |
416 security_attributes.lpSecurityDescriptor = NULL; | 416 security_attributes.lpSecurityDescriptor = NULL; |
417 security_attributes.bInheritHandle = true; | 417 security_attributes.bInheritHandle = true; |
418 | 418 |
419 // Takes ownership of the event handle. | 419 // Takes ownership of the event handle. |
420 base::WaitableEvent event( | 420 base::WaitableEvent event( |
421 CreateEvent(&security_attributes, true, false, NULL)); | 421 CreateEvent(&security_attributes, true, false, NULL)); |
422 base::HandlesToInheritVector handles_to_inherit; | 422 base::HandlesToInheritVector handles_to_inherit; |
423 handles_to_inherit.push_back(event.handle()); | 423 handles_to_inherit.push_back(event.handle()); |
424 base::LaunchOptions options; | 424 base::LaunchOptions options; |
425 options.handles_to_inherit = &handles_to_inherit; | 425 options.handles_to_inherit = &handles_to_inherit; |
426 | 426 |
427 CommandLine cmd_line = MakeCmdLine("TriggerEventChildProcess"); | 427 base::CommandLine cmd_line = MakeCmdLine("TriggerEventChildProcess"); |
428 cmd_line.AppendSwitchASCII(kEventToTriggerHandleSwitch, | 428 cmd_line.AppendSwitchASCII(kEventToTriggerHandleSwitch, |
429 base::Uint64ToString(reinterpret_cast<uint64>(event.handle()))); | 429 base::Uint64ToString(reinterpret_cast<uint64>(event.handle()))); |
430 | 430 |
431 // This functionality actually requires Vista or later. Make sure that it | 431 // This functionality actually requires Vista or later. Make sure that it |
432 // fails properly on XP. | 432 // fails properly on XP. |
433 if (base::win::GetVersion() < base::win::VERSION_VISTA) { | 433 if (base::win::GetVersion() < base::win::VERSION_VISTA) { |
434 EXPECT_FALSE(base::LaunchProcess(cmd_line, options, NULL)); | 434 EXPECT_FALSE(base::LaunchProcess(cmd_line, options, NULL)); |
435 return; | 435 return; |
436 } | 436 } |
437 | 437 |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 | 742 |
743 TEST_F(ProcessUtilTest, GetAppOutput) { | 743 TEST_F(ProcessUtilTest, GetAppOutput) { |
744 std::string output; | 744 std::string output; |
745 | 745 |
746 #if defined(OS_ANDROID) | 746 #if defined(OS_ANDROID) |
747 std::vector<std::string> argv; | 747 std::vector<std::string> argv; |
748 argv.push_back("sh"); // Instead of /bin/sh, force path search to find it. | 748 argv.push_back("sh"); // Instead of /bin/sh, force path search to find it. |
749 argv.push_back("-c"); | 749 argv.push_back("-c"); |
750 | 750 |
751 argv.push_back("exit 0"); | 751 argv.push_back("exit 0"); |
752 EXPECT_TRUE(base::GetAppOutput(CommandLine(argv), &output)); | 752 EXPECT_TRUE(base::GetAppOutput(base::CommandLine(argv), &output)); |
753 EXPECT_STREQ("", output.c_str()); | 753 EXPECT_STREQ("", output.c_str()); |
754 | 754 |
755 argv[2] = "exit 1"; | 755 argv[2] = "exit 1"; |
756 EXPECT_FALSE(base::GetAppOutput(CommandLine(argv), &output)); | 756 EXPECT_FALSE(base::GetAppOutput(base::CommandLine(argv), &output)); |
757 EXPECT_STREQ("", output.c_str()); | 757 EXPECT_STREQ("", output.c_str()); |
758 | 758 |
759 argv[2] = "echo foobar42"; | 759 argv[2] = "echo foobar42"; |
760 EXPECT_TRUE(base::GetAppOutput(CommandLine(argv), &output)); | 760 EXPECT_TRUE(base::GetAppOutput(base::CommandLine(argv), &output)); |
761 EXPECT_STREQ("foobar42\n", output.c_str()); | 761 EXPECT_STREQ("foobar42\n", output.c_str()); |
762 #else | 762 #else |
763 EXPECT_TRUE(base::GetAppOutput(CommandLine(FilePath("true")), &output)); | 763 EXPECT_TRUE(base::GetAppOutput(base::CommandLine(FilePath("true")), |
| 764 &output)); |
764 EXPECT_STREQ("", output.c_str()); | 765 EXPECT_STREQ("", output.c_str()); |
765 | 766 |
766 EXPECT_FALSE(base::GetAppOutput(CommandLine(FilePath("false")), &output)); | 767 EXPECT_FALSE(base::GetAppOutput(base::CommandLine(FilePath("false")), |
| 768 &output)); |
767 | 769 |
768 std::vector<std::string> argv; | 770 std::vector<std::string> argv; |
769 argv.push_back("/bin/echo"); | 771 argv.push_back("/bin/echo"); |
770 argv.push_back("-n"); | 772 argv.push_back("-n"); |
771 argv.push_back("foobar42"); | 773 argv.push_back("foobar42"); |
772 EXPECT_TRUE(base::GetAppOutput(CommandLine(argv), &output)); | 774 EXPECT_TRUE(base::GetAppOutput(base::CommandLine(argv), &output)); |
773 EXPECT_STREQ("foobar42", output.c_str()); | 775 EXPECT_STREQ("foobar42", output.c_str()); |
774 #endif // defined(OS_ANDROID) | 776 #endif // defined(OS_ANDROID) |
775 } | 777 } |
776 | 778 |
777 // Flakes on Android, crbug.com/375840 | 779 // Flakes on Android, crbug.com/375840 |
778 #if defined(OS_ANDROID) | 780 #if defined(OS_ANDROID) |
779 #define MAYBE_GetAppOutputRestricted DISABLED_GetAppOutputRestricted | 781 #define MAYBE_GetAppOutputRestricted DISABLED_GetAppOutputRestricted |
780 #else | 782 #else |
781 #define MAYBE_GetAppOutputRestricted GetAppOutputRestricted | 783 #define MAYBE_GetAppOutputRestricted GetAppOutputRestricted |
782 #endif | 784 #endif |
783 TEST_F(ProcessUtilTest, MAYBE_GetAppOutputRestricted) { | 785 TEST_F(ProcessUtilTest, MAYBE_GetAppOutputRestricted) { |
784 // Unfortunately, since we can't rely on the path, we need to know where | 786 // Unfortunately, since we can't rely on the path, we need to know where |
785 // everything is. So let's use /bin/sh, which is on every POSIX system, and | 787 // everything is. So let's use /bin/sh, which is on every POSIX system, and |
786 // its built-ins. | 788 // its built-ins. |
787 std::vector<std::string> argv; | 789 std::vector<std::string> argv; |
788 argv.push_back(std::string(kShellPath)); // argv[0] | 790 argv.push_back(std::string(kShellPath)); // argv[0] |
789 argv.push_back("-c"); // argv[1] | 791 argv.push_back("-c"); // argv[1] |
790 | 792 |
791 // On success, should set |output|. We use |/bin/sh -c 'exit 0'| instead of | 793 // On success, should set |output|. We use |/bin/sh -c 'exit 0'| instead of |
792 // |true| since the location of the latter may be |/bin| or |/usr/bin| (and we | 794 // |true| since the location of the latter may be |/bin| or |/usr/bin| (and we |
793 // need absolute paths). | 795 // need absolute paths). |
794 argv.push_back("exit 0"); // argv[2]; equivalent to "true" | 796 argv.push_back("exit 0"); // argv[2]; equivalent to "true" |
795 std::string output = "abc"; | 797 std::string output = "abc"; |
796 EXPECT_TRUE(base::GetAppOutputRestricted(CommandLine(argv), &output, 100)); | 798 EXPECT_TRUE(base::GetAppOutputRestricted(base::CommandLine(argv), &output, |
| 799 100)); |
797 EXPECT_STREQ("", output.c_str()); | 800 EXPECT_STREQ("", output.c_str()); |
798 | 801 |
799 argv[2] = "exit 1"; // equivalent to "false" | 802 argv[2] = "exit 1"; // equivalent to "false" |
800 output = "before"; | 803 output = "before"; |
801 EXPECT_FALSE(base::GetAppOutputRestricted(CommandLine(argv), | 804 EXPECT_FALSE(base::GetAppOutputRestricted(base::CommandLine(argv), &output, |
802 &output, 100)); | 805 100)); |
803 EXPECT_STREQ("", output.c_str()); | 806 EXPECT_STREQ("", output.c_str()); |
804 | 807 |
805 // Amount of output exactly equal to space allowed. | 808 // Amount of output exactly equal to space allowed. |
806 argv[2] = "echo 123456789"; // (the sh built-in doesn't take "-n") | 809 argv[2] = "echo 123456789"; // (the sh built-in doesn't take "-n") |
807 output.clear(); | 810 output.clear(); |
808 EXPECT_TRUE(base::GetAppOutputRestricted(CommandLine(argv), &output, 10)); | 811 EXPECT_TRUE(base::GetAppOutputRestricted(base::CommandLine(argv), &output, |
| 812 10)); |
809 EXPECT_STREQ("123456789\n", output.c_str()); | 813 EXPECT_STREQ("123456789\n", output.c_str()); |
810 | 814 |
811 // Amount of output greater than space allowed. | 815 // Amount of output greater than space allowed. |
812 output.clear(); | 816 output.clear(); |
813 EXPECT_TRUE(base::GetAppOutputRestricted(CommandLine(argv), &output, 5)); | 817 EXPECT_TRUE(base::GetAppOutputRestricted(base::CommandLine(argv), &output, |
| 818 5)); |
814 EXPECT_STREQ("12345", output.c_str()); | 819 EXPECT_STREQ("12345", output.c_str()); |
815 | 820 |
816 // Amount of output less than space allowed. | 821 // Amount of output less than space allowed. |
817 output.clear(); | 822 output.clear(); |
818 EXPECT_TRUE(base::GetAppOutputRestricted(CommandLine(argv), &output, 15)); | 823 EXPECT_TRUE(base::GetAppOutputRestricted(base::CommandLine(argv), &output, |
| 824 15)); |
819 EXPECT_STREQ("123456789\n", output.c_str()); | 825 EXPECT_STREQ("123456789\n", output.c_str()); |
820 | 826 |
821 // Zero space allowed. | 827 // Zero space allowed. |
822 output = "abc"; | 828 output = "abc"; |
823 EXPECT_TRUE(base::GetAppOutputRestricted(CommandLine(argv), &output, 0)); | 829 EXPECT_TRUE(base::GetAppOutputRestricted(base::CommandLine(argv), &output, |
| 830 0)); |
824 EXPECT_STREQ("", output.c_str()); | 831 EXPECT_STREQ("", output.c_str()); |
825 } | 832 } |
826 | 833 |
827 #if !defined(OS_MACOSX) && !defined(OS_OPENBSD) | 834 #if !defined(OS_MACOSX) && !defined(OS_OPENBSD) |
828 // TODO(benwells): GetAppOutputRestricted should terminate applications | 835 // TODO(benwells): GetAppOutputRestricted should terminate applications |
829 // with SIGPIPE when we have enough output. http://crbug.com/88502 | 836 // with SIGPIPE when we have enough output. http://crbug.com/88502 |
830 TEST_F(ProcessUtilTest, GetAppOutputRestrictedSIGPIPE) { | 837 TEST_F(ProcessUtilTest, GetAppOutputRestrictedSIGPIPE) { |
831 std::vector<std::string> argv; | 838 std::vector<std::string> argv; |
832 std::string output; | 839 std::string output; |
833 | 840 |
834 argv.push_back(std::string(kShellPath)); // argv[0] | 841 argv.push_back(std::string(kShellPath)); // argv[0] |
835 argv.push_back("-c"); | 842 argv.push_back("-c"); |
836 #if defined(OS_ANDROID) | 843 #if defined(OS_ANDROID) |
837 argv.push_back("while echo 12345678901234567890; do :; done"); | 844 argv.push_back("while echo 12345678901234567890; do :; done"); |
838 EXPECT_TRUE(base::GetAppOutputRestricted(CommandLine(argv), &output, 10)); | 845 EXPECT_TRUE(base::GetAppOutputRestricted(base::CommandLine(argv), &output, |
| 846 10)); |
839 EXPECT_STREQ("1234567890", output.c_str()); | 847 EXPECT_STREQ("1234567890", output.c_str()); |
840 #else | 848 #else |
841 argv.push_back("yes"); | 849 argv.push_back("yes"); |
842 EXPECT_TRUE(base::GetAppOutputRestricted(CommandLine(argv), &output, 10)); | 850 EXPECT_TRUE(base::GetAppOutputRestricted(base::CommandLine(argv), &output, |
| 851 10)); |
843 EXPECT_STREQ("y\ny\ny\ny\ny\n", output.c_str()); | 852 EXPECT_STREQ("y\ny\ny\ny\ny\n", output.c_str()); |
844 #endif | 853 #endif |
845 } | 854 } |
846 #endif | 855 #endif |
847 | 856 |
848 #if defined(ADDRESS_SANITIZER) && defined(OS_MACOSX) && \ | 857 #if defined(ADDRESS_SANITIZER) && defined(OS_MACOSX) && \ |
849 defined(ARCH_CPU_64_BITS) | 858 defined(ARCH_CPU_64_BITS) |
850 // Times out under AddressSanitizer on 64-bit OS X, see | 859 // Times out under AddressSanitizer on 64-bit OS X, see |
851 // http://crbug.com/298197. | 860 // http://crbug.com/298197. |
852 #define MAYBE_GetAppOutputRestrictedNoZombies \ | 861 #define MAYBE_GetAppOutputRestrictedNoZombies \ |
853 DISABLED_GetAppOutputRestrictedNoZombies | 862 DISABLED_GetAppOutputRestrictedNoZombies |
854 #else | 863 #else |
855 #define MAYBE_GetAppOutputRestrictedNoZombies GetAppOutputRestrictedNoZombies | 864 #define MAYBE_GetAppOutputRestrictedNoZombies GetAppOutputRestrictedNoZombies |
856 #endif | 865 #endif |
857 TEST_F(ProcessUtilTest, MAYBE_GetAppOutputRestrictedNoZombies) { | 866 TEST_F(ProcessUtilTest, MAYBE_GetAppOutputRestrictedNoZombies) { |
858 std::vector<std::string> argv; | 867 std::vector<std::string> argv; |
859 | 868 |
860 argv.push_back(std::string(kShellPath)); // argv[0] | 869 argv.push_back(std::string(kShellPath)); // argv[0] |
861 argv.push_back("-c"); // argv[1] | 870 argv.push_back("-c"); // argv[1] |
862 argv.push_back("echo 123456789012345678901234567890"); // argv[2] | 871 argv.push_back("echo 123456789012345678901234567890"); // argv[2] |
863 | 872 |
864 // Run |GetAppOutputRestricted()| 300 (> default per-user processes on Mac OS | 873 // Run |GetAppOutputRestricted()| 300 (> default per-user processes on Mac OS |
865 // 10.5) times with an output buffer big enough to capture all output. | 874 // 10.5) times with an output buffer big enough to capture all output. |
866 for (int i = 0; i < 300; i++) { | 875 for (int i = 0; i < 300; i++) { |
867 std::string output; | 876 std::string output; |
868 EXPECT_TRUE(base::GetAppOutputRestricted(CommandLine(argv), &output, 100)); | 877 EXPECT_TRUE(base::GetAppOutputRestricted(base::CommandLine(argv), &output, |
| 878 100)); |
869 EXPECT_STREQ("123456789012345678901234567890\n", output.c_str()); | 879 EXPECT_STREQ("123456789012345678901234567890\n", output.c_str()); |
870 } | 880 } |
871 | 881 |
872 // Ditto, but with an output buffer too small to capture all output. | 882 // Ditto, but with an output buffer too small to capture all output. |
873 for (int i = 0; i < 300; i++) { | 883 for (int i = 0; i < 300; i++) { |
874 std::string output; | 884 std::string output; |
875 EXPECT_TRUE(base::GetAppOutputRestricted(CommandLine(argv), &output, 10)); | 885 EXPECT_TRUE(base::GetAppOutputRestricted(base::CommandLine(argv), &output, |
| 886 10)); |
876 EXPECT_STREQ("1234567890", output.c_str()); | 887 EXPECT_STREQ("1234567890", output.c_str()); |
877 } | 888 } |
878 } | 889 } |
879 | 890 |
880 TEST_F(ProcessUtilTest, GetAppOutputWithExitCode) { | 891 TEST_F(ProcessUtilTest, GetAppOutputWithExitCode) { |
881 // Test getting output from a successful application. | 892 // Test getting output from a successful application. |
882 std::vector<std::string> argv; | 893 std::vector<std::string> argv; |
883 std::string output; | 894 std::string output; |
884 int exit_code; | 895 int exit_code; |
885 argv.push_back(std::string(kShellPath)); // argv[0] | 896 argv.push_back(std::string(kShellPath)); // argv[0] |
886 argv.push_back("-c"); // argv[1] | 897 argv.push_back("-c"); // argv[1] |
887 argv.push_back("echo foo"); // argv[2]; | 898 argv.push_back("echo foo"); // argv[2]; |
888 EXPECT_TRUE(base::GetAppOutputWithExitCode(CommandLine(argv), &output, | 899 EXPECT_TRUE(base::GetAppOutputWithExitCode(base::CommandLine(argv), &output, |
889 &exit_code)); | 900 &exit_code)); |
890 EXPECT_STREQ("foo\n", output.c_str()); | 901 EXPECT_STREQ("foo\n", output.c_str()); |
891 EXPECT_EQ(exit_code, 0); | 902 EXPECT_EQ(exit_code, 0); |
892 | 903 |
893 // Test getting output from an application which fails with a specific exit | 904 // Test getting output from an application which fails with a specific exit |
894 // code. | 905 // code. |
895 output.clear(); | 906 output.clear(); |
896 argv[2] = "echo foo; exit 2"; | 907 argv[2] = "echo foo; exit 2"; |
897 EXPECT_TRUE(base::GetAppOutputWithExitCode(CommandLine(argv), &output, | 908 EXPECT_TRUE(base::GetAppOutputWithExitCode(base::CommandLine(argv), &output, |
898 &exit_code)); | 909 &exit_code)); |
899 EXPECT_STREQ("foo\n", output.c_str()); | 910 EXPECT_STREQ("foo\n", output.c_str()); |
900 EXPECT_EQ(exit_code, 2); | 911 EXPECT_EQ(exit_code, 2); |
901 } | 912 } |
902 | 913 |
903 TEST_F(ProcessUtilTest, GetParentProcessId) { | 914 TEST_F(ProcessUtilTest, GetParentProcessId) { |
904 base::ProcessId ppid = base::GetParentProcessId(base::GetCurrentProcId()); | 915 base::ProcessId ppid = base::GetParentProcessId(base::GetCurrentProcId()); |
905 EXPECT_EQ(ppid, getppid()); | 916 EXPECT_EQ(ppid, getppid()); |
906 } | 917 } |
907 | 918 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 // Check that process was really killed. | 954 // Check that process was really killed. |
944 EXPECT_TRUE(IsProcessDead(child_process)); | 955 EXPECT_TRUE(IsProcessDead(child_process)); |
945 base::CloseProcessHandle(child_process); | 956 base::CloseProcessHandle(child_process); |
946 } | 957 } |
947 | 958 |
948 MULTIPROCESS_TEST_MAIN(process_util_test_die_immediately) { | 959 MULTIPROCESS_TEST_MAIN(process_util_test_die_immediately) { |
949 return 0; | 960 return 0; |
950 } | 961 } |
951 | 962 |
952 #endif // defined(OS_POSIX) | 963 #endif // defined(OS_POSIX) |
OLD | NEW |