| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 exit(0); | 48 exit(0); |
| 49 return 0; | 49 return 0; |
| 50 } | 50 } |
| 51 | 51 |
| 52 #if defined(OS_WIN) | 52 #if defined(OS_WIN) |
| 53 #define EXE_SUFFIX L".exe" | 53 #define EXE_SUFFIX L".exe" |
| 54 #else | 54 #else |
| 55 #define EXE_SUFFIX L"" | 55 #define EXE_SUFFIX L"" |
| 56 #endif | 56 #endif |
| 57 | 57 |
| 58 #if defined(OS_MACOSX) |
| 58 // TODO(port): finish port on Mac | 59 // TODO(port): finish port on Mac |
| 59 #if !defined(OS_MACOSX) | 60 TEST_F(ProcessUtilTest, DISABLED_KillSlowChild) { |
| 61 #else |
| 60 TEST_F(ProcessUtilTest, KillSlowChild) { | 62 TEST_F(ProcessUtilTest, KillSlowChild) { |
| 63 #endif |
| 61 remove("SlowChildProcess.die"); | 64 remove("SlowChildProcess.die"); |
| 62 int oldcount = GetProcessCount(L"base_unittests" EXE_SUFFIX, 0); | 65 int oldcount = GetProcessCount(L"base_unittests" EXE_SUFFIX, 0); |
| 63 | 66 |
| 64 ProcessHandle handle = this->SpawnChild(L"SlowChildProcess"); | 67 ProcessHandle handle = this->SpawnChild(L"SlowChildProcess"); |
| 65 | 68 |
| 66 ASSERT_NE(static_cast<ProcessHandle>(NULL), handle); | 69 ASSERT_NE(static_cast<ProcessHandle>(NULL), handle); |
| 67 EXPECT_EQ(oldcount+1, GetProcessCount(L"base_unittests" EXE_SUFFIX, 0)); | 70 EXPECT_EQ(oldcount+1, GetProcessCount(L"base_unittests" EXE_SUFFIX, 0)); |
| 68 FILE *fp = fopen("SlowChildProcess.die", "w"); | 71 FILE *fp = fopen("SlowChildProcess.die", "w"); |
| 69 fclose(fp); | 72 fclose(fp); |
| 70 EXPECT_TRUE(base::WaitForSingleProcess(handle, 5000)); | 73 EXPECT_TRUE(base::WaitForSingleProcess(handle, 5000)); |
| 71 EXPECT_EQ(oldcount, GetProcessCount(L"base_unittests" EXE_SUFFIX, 0)); | 74 EXPECT_EQ(oldcount, GetProcessCount(L"base_unittests" EXE_SUFFIX, 0)); |
| 72 } | 75 } |
| 73 #endif | |
| 74 | 76 |
| 75 // TODO(estade): if possible, port these 2 tests. | 77 // TODO(estade): if possible, port these 2 tests. |
| 76 #if defined(OS_WIN) | 78 #if defined(OS_WIN) |
| 77 TEST_F(ProcessUtilTest, EnableLFH) { | 79 TEST_F(ProcessUtilTest, EnableLFH) { |
| 78 ASSERT_TRUE(EnableLowFragmentationHeap()); | 80 ASSERT_TRUE(EnableLowFragmentationHeap()); |
| 79 if (IsDebuggerPresent()) { | 81 if (IsDebuggerPresent()) { |
| 80 // Under these conditions, LFH can't be enabled. There's no point to test | 82 // Under these conditions, LFH can't be enabled. There's no point to test |
| 81 // anything. | 83 // anything. |
| 82 const char* no_debug_env = getenv("_NO_DEBUG_HEAP"); | 84 const char* no_debug_env = getenv("_NO_DEBUG_HEAP"); |
| 83 if (!no_debug_env || strcmp(no_debug_env, "1")) | 85 if (!no_debug_env || strcmp(no_debug_env, "1")) |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 EXPECT_TRUE(WaitForSingleProcess(handle, 1000)); | 225 EXPECT_TRUE(WaitForSingleProcess(handle, 1000)); |
| 224 close(fds[0]); | 226 close(fds[0]); |
| 225 close(sockets[0]); | 227 close(sockets[0]); |
| 226 close(sockets[1]); | 228 close(sockets[1]); |
| 227 close(dev_null); | 229 close(dev_null); |
| 228 } | 230 } |
| 229 | 231 |
| 230 #endif // defined(OS_POSIX) | 232 #endif // defined(OS_POSIX) |
| 231 | 233 |
| 232 } // namespace base | 234 } // namespace base |
| OLD | NEW |