OLD | NEW |
---|---|
1 // Copyright 2015 The Crashpad Authors. All rights reserved. | 1 // Copyright 2015 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 #if defined(ARCH_CPU_64_BITS) | 192 #if defined(ARCH_CPU_64_BITS) |
193 TEST(ProcessInfo, OtherProcessWOW64) { | 193 TEST(ProcessInfo, OtherProcessWOW64) { |
194 #ifndef NDEBUG | 194 #ifndef NDEBUG |
195 TestOtherProcess(FILE_PATH_LITERAL("..\\..\\out\\Debug")); | 195 TestOtherProcess(FILE_PATH_LITERAL("..\\..\\out\\Debug")); |
196 #else | 196 #else |
197 TestOtherProcess(FILE_PATH_LITERAL("..\\..\\out\\Release")); | 197 TestOtherProcess(FILE_PATH_LITERAL("..\\..\\out\\Release")); |
198 #endif | 198 #endif |
199 } | 199 } |
200 #endif // ARCH_CPU_64_BITS | 200 #endif // ARCH_CPU_64_BITS |
201 | 201 |
202 TEST(ProcessInfo, AccessibleRangesNone) { | |
203 std::vector<ProcessInfo::MemoryInfo> memory_info; | |
204 ProcessInfo::MemoryInfo mi; | |
205 | |
206 mi.base_address = 0; | |
207 mi.region_size = 10; | |
208 mi.state = MEM_FREE; | |
209 memory_info.push_back(mi); | |
210 | |
211 std::vector<CheckedRange<WinVMAddress, WinVMSize>> result = | |
212 GetAccessibleRangesInMemoryMap(2, 4, memory_info); | |
213 | |
214 EXPECT_EQ(0u, result.size()); | |
Mark Mentovai
2015/09/29 21:35:50
For the zeroes, EXPECT_TRUE(result.empty()) reads
scottmg
2015/09/30 17:40:26
Done.
| |
215 } | |
216 | |
217 TEST(ProcessInfo, AccessibleRangesOneInside) { | |
218 std::vector<ProcessInfo::MemoryInfo> memory_info; | |
219 ProcessInfo::MemoryInfo mi; | |
220 | |
221 mi.base_address = 0; | |
222 mi.region_size = 10; | |
223 mi.state = MEM_COMMIT; | |
224 memory_info.push_back(mi); | |
225 | |
226 std::vector<CheckedRange<WinVMAddress, WinVMSize>> result = | |
227 GetAccessibleRangesInMemoryMap(2, 4, memory_info); | |
228 | |
229 ASSERT_EQ(result.size(), 1u); | |
230 EXPECT_EQ(2, result[0].base()); | |
231 EXPECT_EQ(4, result[0].size()); | |
232 } | |
233 | |
234 TEST(ProcessInfo, AccessibleRangesOneTruncatedSize) { | |
235 std::vector<ProcessInfo::MemoryInfo> memory_info; | |
236 ProcessInfo::MemoryInfo mi; | |
237 | |
238 mi.base_address = 0; | |
239 mi.region_size = 10; | |
240 mi.state = MEM_COMMIT; | |
241 memory_info.push_back(mi); | |
242 | |
243 mi.base_address = 10; | |
244 mi.region_size = 20; | |
245 mi.state = MEM_FREE; | |
246 memory_info.push_back(mi); | |
247 | |
248 std::vector<CheckedRange<WinVMAddress, WinVMSize>> result = | |
249 GetAccessibleRangesInMemoryMap(5, 10, memory_info); | |
250 | |
251 ASSERT_EQ(result.size(), 1u); | |
252 EXPECT_EQ(5, result[0].base()); | |
253 EXPECT_EQ(5, result[0].size()); | |
254 } | |
255 | |
256 | |
257 TEST(ProcessInfo, AccessibleRangesOneMovedStart) { | |
258 std::vector<ProcessInfo::MemoryInfo> memory_info; | |
259 ProcessInfo::MemoryInfo mi; | |
260 | |
261 mi.base_address = 0; | |
262 mi.region_size = 10; | |
263 mi.state = MEM_FREE; | |
264 memory_info.push_back(mi); | |
265 | |
266 mi.base_address = 10; | |
267 mi.region_size = 20; | |
268 mi.state = MEM_COMMIT; | |
269 memory_info.push_back(mi); | |
270 | |
271 std::vector<CheckedRange<WinVMAddress, WinVMSize>> result = | |
272 GetAccessibleRangesInMemoryMap(5, 10, memory_info); | |
273 | |
274 ASSERT_EQ(result.size(), 1u); | |
275 EXPECT_EQ(10, result[0].base()); | |
276 EXPECT_EQ(5, result[0].size()); | |
277 } | |
278 | |
279 TEST(ProcessInfo, AccessibleRangesCoalesced) { | |
280 std::vector<ProcessInfo::MemoryInfo> memory_info; | |
281 ProcessInfo::MemoryInfo mi; | |
282 | |
283 mi.base_address = 0; | |
284 mi.region_size = 10; | |
285 mi.state = MEM_FREE; | |
286 memory_info.push_back(mi); | |
287 | |
288 mi.base_address = 10; | |
289 mi.region_size = 2; | |
290 mi.state = MEM_COMMIT; | |
291 memory_info.push_back(mi); | |
292 | |
293 mi.base_address = 12; | |
294 mi.region_size = 5; | |
295 mi.state = MEM_RESERVE; | |
296 memory_info.push_back(mi); | |
297 | |
298 std::vector<CheckedRange<WinVMAddress, WinVMSize>> result = | |
299 GetAccessibleRangesInMemoryMap(11, 4, memory_info); | |
300 | |
301 ASSERT_EQ(result.size(), 1u); | |
302 EXPECT_EQ(11, result[0].base()); | |
303 EXPECT_EQ(4, result[0].size()); | |
304 } | |
305 | |
306 TEST(ProcessInfo, AccessibleRangesMiddleUnavailable) { | |
307 std::vector<ProcessInfo::MemoryInfo> memory_info; | |
308 ProcessInfo::MemoryInfo mi; | |
309 | |
310 mi.base_address = 0; | |
311 mi.region_size = 10; | |
312 mi.state = MEM_COMMIT; | |
313 memory_info.push_back(mi); | |
314 | |
315 mi.base_address = 10; | |
316 mi.region_size = 5; | |
317 mi.state = MEM_FREE; | |
318 memory_info.push_back(mi); | |
319 | |
320 mi.base_address = 15; | |
321 mi.region_size = 100; | |
322 mi.state = MEM_COMMIT; | |
323 memory_info.push_back(mi); | |
324 | |
325 std::vector<CheckedRange<WinVMAddress, WinVMSize>> result = | |
326 GetAccessibleRangesInMemoryMap(5, 45, memory_info); | |
327 | |
328 ASSERT_EQ(result.size(), 2u); | |
329 EXPECT_EQ(5, result[0].base()); | |
330 EXPECT_EQ(5, result[0].size()); | |
331 EXPECT_EQ(15, result[1].base()); | |
332 EXPECT_EQ(35, result[1].size()); | |
333 } | |
334 | |
202 } // namespace | 335 } // namespace |
203 } // namespace test | 336 } // namespace test |
204 } // namespace crashpad | 337 } // namespace crashpad |
OLD | NEW |