Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: base/process_util_unittest.cc

Issue 9121046: Cleanup in ProcessSingleton. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to LKGR. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/process_util.h ('k') | base/process_util_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <limits> 7 #include <limits>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/eintr_wrapper.h" 10 #include "base/eintr_wrapper.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 TEST_F(ProcessUtilTest, GetProcId) { 177 TEST_F(ProcessUtilTest, GetProcId) {
178 base::ProcessId id1 = base::GetProcId(GetCurrentProcess()); 178 base::ProcessId id1 = base::GetProcId(GetCurrentProcess());
179 EXPECT_NE(0ul, id1); 179 EXPECT_NE(0ul, id1);
180 base::ProcessHandle handle = this->SpawnChild("SimpleChildProcess", false); 180 base::ProcessHandle handle = this->SpawnChild("SimpleChildProcess", false);
181 ASSERT_NE(base::kNullProcessHandle, handle); 181 ASSERT_NE(base::kNullProcessHandle, handle);
182 base::ProcessId id2 = base::GetProcId(handle); 182 base::ProcessId id2 = base::GetProcId(handle);
183 EXPECT_NE(0ul, id2); 183 EXPECT_NE(0ul, id2);
184 EXPECT_NE(id1, id2); 184 EXPECT_NE(id1, id2);
185 base::CloseProcessHandle(handle); 185 base::CloseProcessHandle(handle);
186 } 186 }
187
188 TEST_F(ProcessUtilTest, GetModuleFromAddress) {
189 // Since the unit tests are their own EXE, this should be
190 // equivalent to the EXE's HINSTANCE.
191 //
192 // kExpectedKilledExitCode is a constant in this file and
193 // therefore within the unit test EXE.
194 EXPECT_EQ(::GetModuleHandle(NULL),
195 base::GetModuleFromAddress(
196 const_cast<int*>(&kExpectedKilledExitCode)));
197
198 // Any address within the kernel32 module should return
199 // kernel32's HMODULE. Our only assumption here is that
200 // kernel32 is larger than 4 bytes.
201 HMODULE kernel32 = ::GetModuleHandle(L"kernel32.dll");
202 HMODULE kernel32_from_address =
203 base::GetModuleFromAddress(reinterpret_cast<DWORD*>(kernel32) + 1);
204 EXPECT_EQ(kernel32, kernel32_from_address);
205 }
187 #endif 206 #endif
188 207
189 #if !defined(OS_MACOSX) 208 #if !defined(OS_MACOSX)
190 // This test is disabled on Mac, since it's flaky due to ReportCrash 209 // This test is disabled on Mac, since it's flaky due to ReportCrash
191 // taking a variable amount of time to parse and load the debug and 210 // taking a variable amount of time to parse and load the debug and
192 // symbol data for this unit test's executable before firing the 211 // symbol data for this unit test's executable before firing the
193 // signal handler. 212 // signal handler.
194 // 213 //
195 // TODO(gspencer): turn this test process into a very small program 214 // TODO(gspencer): turn this test process into a very small program
196 // with no symbols (instead of using the multiprocess testing 215 // with no symbols (instead of using the multiprocess testing
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 SetUpInDeathAssert(); 1156 SetUpInDeathAssert();
1138 while ((value_ = base::AllocatePsychoticallyBigObjCObject())) {} 1157 while ((value_ = base::AllocatePsychoticallyBigObjCObject())) {}
1139 }, ""); 1158 }, "");
1140 } 1159 }
1141 1160
1142 #endif // !ARCH_CPU_64_BITS 1161 #endif // !ARCH_CPU_64_BITS
1143 #endif // OS_MACOSX 1162 #endif // OS_MACOSX
1144 1163
1145 #endif // !defined(OS_ANDROID) && !defined(OS_OPENBSD) && 1164 #endif // !defined(OS_ANDROID) && !defined(OS_OPENBSD) &&
1146 // !defined(OS_WIN) && !defined(ADDRESS_SANITIZER) 1165 // !defined(OS_WIN) && !defined(ADDRESS_SANITIZER)
OLDNEW
« no previous file with comments | « base/process_util.h ('k') | base/process_util_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698