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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 | 272 |
273 std::vector<CheckedRange<WinVMAddress, WinVMSize>> result = | 273 std::vector<CheckedRange<WinVMAddress, WinVMSize>> result = |
274 GetReadableRangesOfMemoryMap(CheckedRange<WinVMAddress, WinVMSize>(5, 10), | 274 GetReadableRangesOfMemoryMap(CheckedRange<WinVMAddress, WinVMSize>(5, 10), |
275 memory_info); | 275 memory_info); |
276 | 276 |
277 ASSERT_EQ(result.size(), 1u); | 277 ASSERT_EQ(result.size(), 1u); |
278 EXPECT_EQ(10, result[0].base()); | 278 EXPECT_EQ(10, result[0].base()); |
279 EXPECT_EQ(5, result[0].size()); | 279 EXPECT_EQ(5, result[0].size()); |
280 } | 280 } |
281 | 281 |
| 282 TEST(ProcessInfo, ReserveIsInaccessible) { |
| 283 std::vector<ProcessInfo::MemoryInfo> memory_info; |
| 284 MEMORY_BASIC_INFORMATION mbi = {0}; |
| 285 |
| 286 mbi.BaseAddress = 0; |
| 287 mbi.RegionSize = 10; |
| 288 mbi.State = MEM_RESERVE; |
| 289 memory_info.push_back(ProcessInfo::MemoryInfo(mbi)); |
| 290 |
| 291 mbi.BaseAddress = reinterpret_cast<void*>(10); |
| 292 mbi.RegionSize = 20; |
| 293 mbi.State = MEM_COMMIT; |
| 294 memory_info.push_back(ProcessInfo::MemoryInfo(mbi)); |
| 295 |
| 296 std::vector<CheckedRange<WinVMAddress, WinVMSize>> result = |
| 297 GetReadableRangesOfMemoryMap(CheckedRange<WinVMAddress, WinVMSize>(5, 10), |
| 298 memory_info); |
| 299 |
| 300 ASSERT_EQ(result.size(), 1u); |
| 301 EXPECT_EQ(10, result[0].base()); |
| 302 EXPECT_EQ(5, result[0].size()); |
| 303 } |
| 304 |
282 TEST(ProcessInfo, AccessibleRangesCoalesced) { | 305 TEST(ProcessInfo, AccessibleRangesCoalesced) { |
283 std::vector<ProcessInfo::MemoryInfo> memory_info; | 306 std::vector<ProcessInfo::MemoryInfo> memory_info; |
284 MEMORY_BASIC_INFORMATION mbi = {0}; | 307 MEMORY_BASIC_INFORMATION mbi = {0}; |
285 | 308 |
286 mbi.BaseAddress = 0; | 309 mbi.BaseAddress = 0; |
287 mbi.RegionSize = 10; | 310 mbi.RegionSize = 10; |
288 mbi.State = MEM_FREE; | 311 mbi.State = MEM_FREE; |
289 memory_info.push_back(ProcessInfo::MemoryInfo(mbi)); | 312 memory_info.push_back(ProcessInfo::MemoryInfo(mbi)); |
290 | 313 |
291 mbi.BaseAddress = reinterpret_cast<void*>(10); | 314 mbi.BaseAddress = reinterpret_cast<void*>(10); |
292 mbi.RegionSize = 2; | 315 mbi.RegionSize = 2; |
293 mbi.State = MEM_COMMIT; | 316 mbi.State = MEM_COMMIT; |
294 memory_info.push_back(ProcessInfo::MemoryInfo(mbi)); | 317 memory_info.push_back(ProcessInfo::MemoryInfo(mbi)); |
295 | 318 |
296 mbi.BaseAddress = reinterpret_cast<void*>(12); | 319 mbi.BaseAddress = reinterpret_cast<void*>(12); |
297 mbi.RegionSize = 5; | 320 mbi.RegionSize = 5; |
298 mbi.State = MEM_RESERVE; | 321 mbi.State = MEM_COMMIT; |
299 memory_info.push_back(ProcessInfo::MemoryInfo(mbi)); | 322 memory_info.push_back(ProcessInfo::MemoryInfo(mbi)); |
300 | 323 |
301 std::vector<CheckedRange<WinVMAddress, WinVMSize>> result = | 324 std::vector<CheckedRange<WinVMAddress, WinVMSize>> result = |
302 GetReadableRangesOfMemoryMap(CheckedRange<WinVMAddress, WinVMSize>(11, 4), | 325 GetReadableRangesOfMemoryMap(CheckedRange<WinVMAddress, WinVMSize>(11, 4), |
303 memory_info); | 326 memory_info); |
304 | 327 |
305 ASSERT_EQ(result.size(), 1u); | 328 ASSERT_EQ(result.size(), 1u); |
306 EXPECT_EQ(11, result[0].base()); | 329 EXPECT_EQ(11, result[0].base()); |
307 EXPECT_EQ(4, result[0].size()); | 330 EXPECT_EQ(4, result[0].size()); |
308 } | 331 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 CheckedRange<WinVMAddress, WinVMSize>(15, 100), memory_info); | 392 CheckedRange<WinVMAddress, WinVMSize>(15, 100), memory_info); |
370 | 393 |
371 ASSERT_EQ(result.size(), 1u); | 394 ASSERT_EQ(result.size(), 1u); |
372 EXPECT_EQ(15, result[0].base()); | 395 EXPECT_EQ(15, result[0].base()); |
373 EXPECT_EQ(5, result[0].size()); | 396 EXPECT_EQ(5, result[0].size()); |
374 } | 397 } |
375 | 398 |
376 } // namespace | 399 } // namespace |
377 } // namespace test | 400 } // namespace test |
378 } // namespace crashpad | 401 } // namespace crashpad |
OLD | NEW |