| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 // Test getting output from an application which fails with a specific exit | 851 // Test getting output from an application which fails with a specific exit |
| 852 // code. | 852 // code. |
| 853 output.clear(); | 853 output.clear(); |
| 854 argv[2] = "echo foo; exit 2"; | 854 argv[2] = "echo foo; exit 2"; |
| 855 EXPECT_TRUE(base::GetAppOutputWithExitCode(base::CommandLine(argv), &output, | 855 EXPECT_TRUE(base::GetAppOutputWithExitCode(base::CommandLine(argv), &output, |
| 856 &exit_code)); | 856 &exit_code)); |
| 857 EXPECT_STREQ("foo\n", output.c_str()); | 857 EXPECT_STREQ("foo\n", output.c_str()); |
| 858 EXPECT_EQ(exit_code, 2); | 858 EXPECT_EQ(exit_code, 2); |
| 859 } | 859 } |
| 860 | 860 |
| 861 #if !defined(OS_FUCHSIA) |
| 861 TEST_F(ProcessUtilTest, GetParentProcessId) { | 862 TEST_F(ProcessUtilTest, GetParentProcessId) { |
| 862 base::ProcessId ppid = | 863 base::ProcessId ppid = |
| 863 base::GetParentProcessId(base::GetCurrentProcessHandle()); | 864 base::GetParentProcessId(base::GetCurrentProcessHandle()); |
| 864 EXPECT_EQ(ppid, getppid()); | 865 EXPECT_EQ(ppid, getppid()); |
| 865 } | 866 } |
| 867 #endif // OS_FUCHSIA |
| 866 | 868 |
| 867 // TODO(port): port those unit tests. | 869 // TODO(port): port those unit tests. |
| 868 bool IsProcessDead(base::ProcessHandle child) { | 870 bool IsProcessDead(base::ProcessHandle child) { |
| 869 // waitpid() will actually reap the process which is exactly NOT what we | 871 // waitpid() will actually reap the process which is exactly NOT what we |
| 870 // want to test for. The good thing is that if it can't find the process | 872 // want to test for. The good thing is that if it can't find the process |
| 871 // we'll get a nice value for errno which we can test for. | 873 // we'll get a nice value for errno which we can test for. |
| 872 const pid_t result = HANDLE_EINTR(waitpid(child, NULL, WNOHANG)); | 874 const pid_t result = HANDLE_EINTR(waitpid(child, NULL, WNOHANG)); |
| 873 return result == -1 && errno == ECHILD; | 875 return result == -1 && errno == ECHILD; |
| 874 } | 876 } |
| 875 | 877 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 | 1023 |
| 1022 base::SpawnChildResult spawn_child = | 1024 base::SpawnChildResult spawn_child = |
| 1023 SpawnChildWithOptions("SimpleChildProcess", options); | 1025 SpawnChildWithOptions("SimpleChildProcess", options); |
| 1024 ASSERT_TRUE(spawn_child.process.IsValid()); | 1026 ASSERT_TRUE(spawn_child.process.IsValid()); |
| 1025 | 1027 |
| 1026 int exit_code = kSuccess; | 1028 int exit_code = kSuccess; |
| 1027 EXPECT_TRUE(spawn_child.process.WaitForExit(&exit_code)); | 1029 EXPECT_TRUE(spawn_child.process.WaitForExit(&exit_code)); |
| 1028 EXPECT_NE(kSuccess, exit_code); | 1030 EXPECT_NE(kSuccess, exit_code); |
| 1029 } | 1031 } |
| 1030 #endif // defined(OS_LINUX) | 1032 #endif // defined(OS_LINUX) |
| OLD | NEW |