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 26 matching lines...) Expand all Loading... |
37 PlatformThread::Sleep(100); | 37 PlatformThread::Sleep(100); |
38 fp = fopen("SlowChildProcess.die", "r"); | 38 fp = fopen("SlowChildProcess.die", "r"); |
39 } while (!fp); | 39 } while (!fp); |
40 fclose(fp); | 40 fclose(fp); |
41 remove("SlowChildProcess.die"); | 41 remove("SlowChildProcess.die"); |
42 exit(0); | 42 exit(0); |
43 return 0; | 43 return 0; |
44 } | 44 } |
45 | 45 |
46 #if defined(OS_WIN) | 46 #if defined(OS_WIN) |
47 #define EXE_SUFFIX ".exe" | 47 #define EXE_SUFFIX L".exe" |
48 #else | 48 #else |
49 #define EXE_SUFFIX "" | 49 #define EXE_SUFFIX L"" |
50 #endif | 50 #endif |
51 | 51 |
52 // TODO(port): finish port on Mac | 52 // TODO(port): finish port on Mac |
53 #if defined(OS_MACOSX) | 53 #if !defined(OS_MACOSX) |
54 TEST_F(ProcessUtilTest, DISABLED_KillSlowChild) | 54 TEST_F(ProcessUtilTest, KillSlowChild) { |
55 #else | |
56 TEST_F(ProcessUtilTest, KillSlowChild) | |
57 #endif | |
58 { | |
59 remove("SlowChildProcess.die"); | 55 remove("SlowChildProcess.die"); |
60 int oldcount = process_util::GetProcessCount(L"base_unittests" EXE_SUFFIX, 0); | 56 int oldcount = process_util::GetProcessCount(L"base_unittests" EXE_SUFFIX, 0); |
61 | 57 |
62 ProcessHandle handle = this->SpawnChild(L"SlowChildProcess"); | 58 ProcessHandle handle = this->SpawnChild(L"SlowChildProcess"); |
63 | 59 |
64 ASSERT_NE(static_cast<ProcessHandle>(NULL), handle); | 60 ASSERT_NE(static_cast<ProcessHandle>(NULL), handle); |
65 EXPECT_EQ(oldcount+1, process_util::GetProcessCount(L"base_unittests" EXE_SUFF
IX, 0)); | 61 EXPECT_EQ(oldcount+1, process_util::GetProcessCount(L"base_unittests" EXE_SUFF
IX, 0)); |
66 FILE *fp = fopen("SlowChildProcess.die", "w"); | 62 FILE *fp = fopen("SlowChildProcess.die", "w"); |
67 fclose(fp); | 63 fclose(fp); |
68 // TODO(port): do something less racy here | 64 // TODO(port): do something less racy here |
69 PlatformThread::Sleep(1000); | 65 PlatformThread::Sleep(1000); |
70 EXPECT_EQ(oldcount, process_util::GetProcessCount(L"base_unittests" EXE_SUFFIX
, 0)); | 66 EXPECT_EQ(oldcount, process_util::GetProcessCount(L"base_unittests" EXE_SUFFIX
, 0)); |
71 } | 67 } |
| 68 #endif |
72 | 69 |
73 // TODO(estade): if possible, port these 2 tests. | 70 // TODO(estade): if possible, port these 2 tests. |
74 #if defined(OS_WIN) | 71 #if defined(OS_WIN) |
75 TEST_F(ProcessUtilTest, EnableLFH) { | 72 TEST_F(ProcessUtilTest, EnableLFH) { |
76 ASSERT_TRUE(process_util::EnableLowFragmentationHeap()); | 73 ASSERT_TRUE(process_util::EnableLowFragmentationHeap()); |
77 if (IsDebuggerPresent()) { | 74 if (IsDebuggerPresent()) { |
78 // Under these conditions, LFH can't be enabled. There's no point to test | 75 // Under these conditions, LFH can't be enabled. There's no point to test |
79 // anything. | 76 // anything. |
80 const char* no_debug_env = getenv("_NO_DEBUG_HEAP"); | 77 const char* no_debug_env = getenv("_NO_DEBUG_HEAP"); |
81 if (!no_debug_env || strcmp(no_debug_env, "1")) | 78 if (!no_debug_env || strcmp(no_debug_env, "1")) |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 EXPECT_GE(expected_total, free_mem2.total); | 130 EXPECT_GE(expected_total, free_mem2.total); |
134 EXPECT_GE(expected_largest, free_mem2.largest); | 131 EXPECT_GE(expected_largest, free_mem2.largest); |
135 EXPECT_TRUE(NULL != free_mem2.largest_ptr); | 132 EXPECT_TRUE(NULL != free_mem2.largest_ptr); |
136 | 133 |
137 delete[] alloc; | 134 delete[] alloc; |
138 delete metrics; | 135 delete metrics; |
139 } | 136 } |
140 #endif // defined(OS_WIN) | 137 #endif // defined(OS_WIN) |
141 | 138 |
142 } // namespace | 139 } // namespace |
OLD | NEW |