OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/multiprocess_test.h" | 7 #include "base/multiprocess_test.h" |
8 #include "base/platform_thread.h" | 8 #include "base/platform_thread.h" |
9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 }; | 26 }; |
27 | 27 |
28 MULTIPROCESS_TEST_MAIN(SimpleChildProcess) { | 28 MULTIPROCESS_TEST_MAIN(SimpleChildProcess) { |
29 return 0; | 29 return 0; |
30 } | 30 } |
31 | 31 |
32 TEST_F(ProcessUtilTest, SpawnChild) { | 32 TEST_F(ProcessUtilTest, SpawnChild) { |
33 ProcessHandle handle = this->SpawnChild(L"SimpleChildProcess"); | 33 ProcessHandle handle = this->SpawnChild(L"SimpleChildProcess"); |
34 | 34 |
35 ASSERT_NE(static_cast<ProcessHandle>(NULL), handle); | 35 ASSERT_NE(static_cast<ProcessHandle>(NULL), handle); |
36 EXPECT_TRUE(WaitForSingleProcess(handle, 1000)); | 36 EXPECT_TRUE(WaitForSingleProcess(handle, 5000)); |
37 } | 37 } |
38 | 38 |
39 MULTIPROCESS_TEST_MAIN(SlowChildProcess) { | 39 MULTIPROCESS_TEST_MAIN(SlowChildProcess) { |
40 // Sleep until file "SlowChildProcess.die" is created. | 40 // Sleep until file "SlowChildProcess.die" is created. |
41 FILE *fp; | 41 FILE *fp; |
42 do { | 42 do { |
43 PlatformThread::Sleep(100); | 43 PlatformThread::Sleep(100); |
44 fp = fopen("SlowChildProcess.die", "r"); | 44 fp = fopen("SlowChildProcess.die", "r"); |
45 } while (!fp); | 45 } while (!fp); |
46 fclose(fp); | 46 fclose(fp); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 EXPECT_TRUE(WaitForSingleProcess(handle, 1000)); | 204 EXPECT_TRUE(WaitForSingleProcess(handle, 1000)); |
205 close(fds[0]); | 205 close(fds[0]); |
206 close(sockets[0]); | 206 close(sockets[0]); |
207 close(sockets[1]); | 207 close(sockets[1]); |
208 close(dev_null); | 208 close(dev_null); |
209 } | 209 } |
210 | 210 |
211 #endif // defined(OS_POSIX) | 211 #endif // defined(OS_POSIX) |
212 | 212 |
213 } // namespace base | 213 } // namespace base |
OLD | NEW |