OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/eintr_wrapper.h" | 8 #include "base/eintr_wrapper.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/multiprocess_test.h" | 10 #include "base/multiprocess_test.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 #endif | 34 #endif |
35 }; | 35 }; |
36 | 36 |
37 MULTIPROCESS_TEST_MAIN(SimpleChildProcess) { | 37 MULTIPROCESS_TEST_MAIN(SimpleChildProcess) { |
38 return 0; | 38 return 0; |
39 } | 39 } |
40 | 40 |
41 TEST_F(ProcessUtilTest, SpawnChild) { | 41 TEST_F(ProcessUtilTest, SpawnChild) { |
42 ProcessHandle handle = this->SpawnChild(L"SimpleChildProcess"); | 42 ProcessHandle handle = this->SpawnChild(L"SimpleChildProcess"); |
43 | 43 |
44 ASSERT_NE(0, handle); | 44 ASSERT_NE(static_cast<ProcessHandle>(NULL), handle); |
45 EXPECT_TRUE(WaitForSingleProcess(handle, 5000)); | 45 EXPECT_TRUE(WaitForSingleProcess(handle, 5000)); |
46 base::CloseProcessHandle(handle); | 46 base::CloseProcessHandle(handle); |
47 } | 47 } |
48 | 48 |
49 MULTIPROCESS_TEST_MAIN(SlowChildProcess) { | 49 MULTIPROCESS_TEST_MAIN(SlowChildProcess) { |
50 // Sleep until file "SlowChildProcess.die" is created. | 50 // Sleep until file "SlowChildProcess.die" is created. |
51 FILE *fp; | 51 FILE *fp; |
52 do { | 52 do { |
53 PlatformThread::Sleep(100); | 53 PlatformThread::Sleep(100); |
54 fp = fopen("SlowChildProcess.die", "r"); | 54 fp = fopen("SlowChildProcess.die", "r"); |
55 } while (!fp); | 55 } while (!fp); |
56 fclose(fp); | 56 fclose(fp); |
57 remove("SlowChildProcess.die"); | 57 remove("SlowChildProcess.die"); |
58 exit(0); | 58 exit(0); |
59 return 0; | 59 return 0; |
60 } | 60 } |
61 | 61 |
62 TEST_F(ProcessUtilTest, KillSlowChild) { | 62 TEST_F(ProcessUtilTest, KillSlowChild) { |
63 remove("SlowChildProcess.die"); | 63 remove("SlowChildProcess.die"); |
64 ProcessHandle handle = this->SpawnChild(L"SlowChildProcess"); | 64 ProcessHandle handle = this->SpawnChild(L"SlowChildProcess"); |
65 ASSERT_NE(0, handle); | 65 ASSERT_NE(static_cast<ProcessHandle>(NULL), handle); |
66 FILE *fp = fopen("SlowChildProcess.die", "w"); | 66 FILE *fp = fopen("SlowChildProcess.die", "w"); |
67 fclose(fp); | 67 fclose(fp); |
68 EXPECT_TRUE(base::WaitForSingleProcess(handle, 5000)); | 68 EXPECT_TRUE(base::WaitForSingleProcess(handle, 5000)); |
69 base::CloseProcessHandle(handle); | 69 base::CloseProcessHandle(handle); |
70 } | 70 } |
71 | 71 |
72 // TODO(estade): if possible, port these 2 tests. | 72 // TODO(estade): if possible, port these 2 tests. |
73 #if defined(OS_WIN) | 73 #if defined(OS_WIN) |
74 TEST_F(ProcessUtilTest, EnableLFH) { | 74 TEST_F(ProcessUtilTest, EnableLFH) { |
75 ASSERT_TRUE(EnableLowFragmentationHeap()); | 75 ASSERT_TRUE(EnableLowFragmentationHeap()); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 #if defined(OS_LINUX) | 274 #if defined(OS_LINUX) |
275 TEST_F(ProcessUtilTest, GetParentProcessId) { | 275 TEST_F(ProcessUtilTest, GetParentProcessId) { |
276 base::ProcessId ppid = GetParentProcessId(GetCurrentProcId()); | 276 base::ProcessId ppid = GetParentProcessId(GetCurrentProcId()); |
277 EXPECT_EQ(ppid, getppid()); | 277 EXPECT_EQ(ppid, getppid()); |
278 } | 278 } |
279 #endif | 279 #endif |
280 | 280 |
281 #endif // defined(OS_POSIX) | 281 #endif // defined(OS_POSIX) |
282 | 282 |
283 } // namespace base | 283 } // namespace base |
OLD | NEW |