| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 do { | 43 do { |
| 44 PlatformThread::Sleep(100); | 44 PlatformThread::Sleep(100); |
| 45 fp = fopen("SlowChildProcess.die", "r"); | 45 fp = fopen("SlowChildProcess.die", "r"); |
| 46 } while (!fp); | 46 } while (!fp); |
| 47 fclose(fp); | 47 fclose(fp); |
| 48 remove("SlowChildProcess.die"); | 48 remove("SlowChildProcess.die"); |
| 49 exit(0); | 49 exit(0); |
| 50 return 0; | 50 return 0; |
| 51 } | 51 } |
| 52 | 52 |
| 53 #if defined(OS_WIN) | |
| 54 #define EXE_SUFFIX L".exe" | |
| 55 #else | |
| 56 #define EXE_SUFFIX L"" | |
| 57 #endif | |
| 58 | |
| 59 TEST_F(ProcessUtilTest, KillSlowChild) { | 53 TEST_F(ProcessUtilTest, KillSlowChild) { |
| 60 remove("SlowChildProcess.die"); | 54 remove("SlowChildProcess.die"); |
| 61 int oldcount = GetProcessCount(L"base_unittests" EXE_SUFFIX, 0); | |
| 62 ProcessHandle handle = this->SpawnChild(L"SlowChildProcess"); | 55 ProcessHandle handle = this->SpawnChild(L"SlowChildProcess"); |
| 63 ASSERT_NE(static_cast<ProcessHandle>(NULL), handle); | 56 ASSERT_NE(static_cast<ProcessHandle>(NULL), handle); |
| 64 EXPECT_EQ(oldcount+1, GetProcessCount(L"base_unittests" EXE_SUFFIX, 0)); | |
| 65 FILE *fp = fopen("SlowChildProcess.die", "w"); | 57 FILE *fp = fopen("SlowChildProcess.die", "w"); |
| 66 fclose(fp); | 58 fclose(fp); |
| 67 EXPECT_TRUE(base::WaitForSingleProcess(handle, 5000)); | 59 EXPECT_TRUE(base::WaitForSingleProcess(handle, 5000)); |
| 68 EXPECT_EQ(oldcount, GetProcessCount(L"base_unittests" EXE_SUFFIX, 0)); | |
| 69 base::CloseProcessHandle(handle); | 60 base::CloseProcessHandle(handle); |
| 70 } | 61 } |
| 71 | 62 |
| 72 // TODO(estade): if possible, port these 2 tests. | 63 // TODO(estade): if possible, port these 2 tests. |
| 73 #if defined(OS_WIN) | 64 #if defined(OS_WIN) |
| 74 TEST_F(ProcessUtilTest, EnableLFH) { | 65 TEST_F(ProcessUtilTest, EnableLFH) { |
| 75 ASSERT_TRUE(EnableLowFragmentationHeap()); | 66 ASSERT_TRUE(EnableLowFragmentationHeap()); |
| 76 if (IsDebuggerPresent()) { | 67 if (IsDebuggerPresent()) { |
| 77 // Under these conditions, LFH can't be enabled. There's no point to test | 68 // Under these conditions, LFH can't be enabled. There's no point to test |
| 78 // anything. | 69 // anything. |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 base::CloseProcessHandle(handle); | 214 base::CloseProcessHandle(handle); |
| 224 close(fds[0]); | 215 close(fds[0]); |
| 225 close(sockets[0]); | 216 close(sockets[0]); |
| 226 close(sockets[1]); | 217 close(sockets[1]); |
| 227 close(dev_null); | 218 close(dev_null); |
| 228 } | 219 } |
| 229 | 220 |
| 230 #endif // defined(OS_POSIX) | 221 #endif // defined(OS_POSIX) |
| 231 | 222 |
| 232 } // namespace base | 223 } // namespace base |
| OLD | NEW |