blob: e703b78cfa2eeaf1f8df7fcf888952e5f50cbe25 [file] [log] [blame]
Brian Carlstrom9004cb62013-07-26 15:48:31 -07001/*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "mem_map.h"
18
Ian Rogers700a4022014-05-19 16:49:03 -070019#include <memory>
20
Mathieu Chartier42bddce2015-11-09 15:16:56 -080021#include "common_runtime_test.h"
Evgenii Stepanov1e133742015-05-20 12:30:59 -070022#include "base/memory_tool.h"
Mathieu Chartier42bddce2015-11-09 15:16:56 -080023#include "base/unix_file/fd_file.h"
Brian Carlstrom9004cb62013-07-26 15:48:31 -070024
25namespace art {
26
Mathieu Chartier42bddce2015-11-09 15:16:56 -080027class MemMapTest : public CommonRuntimeTest {
Hiroshi Yamauchifd7e7f12013-10-22 14:17:48 -070028 public:
Ian Rogers13735952014-10-08 12:43:28 -070029 static uint8_t* BaseBegin(MemMap* mem_map) {
30 return reinterpret_cast<uint8_t*>(mem_map->base_begin_);
Hiroshi Yamauchifd7e7f12013-10-22 14:17:48 -070031 }
Mathieu Chartier16d29f82015-11-10 10:32:52 -080032
Ian Rogersef7d42f2014-01-06 12:55:46 -080033 static size_t BaseSize(MemMap* mem_map) {
Hiroshi Yamauchifd7e7f12013-10-22 14:17:48 -070034 return mem_map->base_size_;
35 }
Ian Rogersef7d42f2014-01-06 12:55:46 -080036
Mathieu Chartier16d29f82015-11-10 10:32:52 -080037 static uint8_t* GetValidMapAddress(size_t size, bool low_4gb) {
38 // Find a valid map address and unmap it before returning.
39 std::string error_msg;
40 std::unique_ptr<MemMap> map(MemMap::MapAnonymous("temp",
41 nullptr,
42 size,
43 PROT_READ,
44 low_4gb,
45 false,
46 &error_msg));
47 CHECK(map != nullptr);
48 return map->Begin();
49 }
50
Ian Rogersef7d42f2014-01-06 12:55:46 -080051 static void RemapAtEndTest(bool low_4gb) {
52 std::string error_msg;
53 // Cast the page size to size_t.
54 const size_t page_size = static_cast<size_t>(kPageSize);
55 // Map a two-page memory region.
56 MemMap* m0 = MemMap::MapAnonymous("MemMapTest_RemapAtEndTest_map0",
57 nullptr,
58 2 * page_size,
59 PROT_READ | PROT_WRITE,
60 low_4gb,
Vladimir Marko5c42c292015-02-25 12:02:49 +000061 false,
Ian Rogersef7d42f2014-01-06 12:55:46 -080062 &error_msg);
63 // Check its state and write to it.
Ian Rogers13735952014-10-08 12:43:28 -070064 uint8_t* base0 = m0->Begin();
Ian Rogersef7d42f2014-01-06 12:55:46 -080065 ASSERT_TRUE(base0 != nullptr) << error_msg;
66 size_t size0 = m0->Size();
67 EXPECT_EQ(m0->Size(), 2 * page_size);
68 EXPECT_EQ(BaseBegin(m0), base0);
69 EXPECT_EQ(BaseSize(m0), size0);
70 memset(base0, 42, 2 * page_size);
71 // Remap the latter half into a second MemMap.
72 MemMap* m1 = m0->RemapAtEnd(base0 + page_size,
73 "MemMapTest_RemapAtEndTest_map1",
74 PROT_READ | PROT_WRITE,
75 &error_msg);
76 // Check the states of the two maps.
77 EXPECT_EQ(m0->Begin(), base0) << error_msg;
78 EXPECT_EQ(m0->Size(), page_size);
79 EXPECT_EQ(BaseBegin(m0), base0);
80 EXPECT_EQ(BaseSize(m0), page_size);
Ian Rogers13735952014-10-08 12:43:28 -070081 uint8_t* base1 = m1->Begin();
Ian Rogersef7d42f2014-01-06 12:55:46 -080082 size_t size1 = m1->Size();
83 EXPECT_EQ(base1, base0 + page_size);
84 EXPECT_EQ(size1, page_size);
85 EXPECT_EQ(BaseBegin(m1), base1);
86 EXPECT_EQ(BaseSize(m1), size1);
87 // Write to the second region.
88 memset(base1, 43, page_size);
89 // Check the contents of the two regions.
90 for (size_t i = 0; i < page_size; ++i) {
91 EXPECT_EQ(base0[i], 42);
92 }
93 for (size_t i = 0; i < page_size; ++i) {
94 EXPECT_EQ(base1[i], 43);
95 }
96 // Unmap the first region.
97 delete m0;
98 // Make sure the second region is still accessible after the first
99 // region is unmapped.
100 for (size_t i = 0; i < page_size; ++i) {
101 EXPECT_EQ(base1[i], 43);
102 }
103 delete m1;
104 }
Andreas Gamped8f26db2014-05-19 17:01:13 -0700105
Mathieu Chartier6e88ef62014-10-14 15:01:24 -0700106 void CommonInit() {
107 MemMap::Init();
108 }
109
Andreas Gamped8f26db2014-05-19 17:01:13 -0700110#if defined(__LP64__) && !defined(__x86_64__)
111 static uintptr_t GetLinearScanPos() {
112 return MemMap::next_mem_pos_;
113 }
114#endif
Hiroshi Yamauchifd7e7f12013-10-22 14:17:48 -0700115};
Brian Carlstrom9004cb62013-07-26 15:48:31 -0700116
Andreas Gamped8f26db2014-05-19 17:01:13 -0700117#if defined(__LP64__) && !defined(__x86_64__)
118
119#ifdef __BIONIC__
120extern uintptr_t CreateStartPos(uint64_t input);
121#endif
122
123TEST_F(MemMapTest, Start) {
Mathieu Chartier6e88ef62014-10-14 15:01:24 -0700124 CommonInit();
Andreas Gamped8f26db2014-05-19 17:01:13 -0700125 uintptr_t start = GetLinearScanPos();
126 EXPECT_LE(64 * KB, start);
127 EXPECT_LT(start, static_cast<uintptr_t>(ART_BASE_ADDRESS));
Andreas Gamped8f26db2014-05-19 17:01:13 -0700128#ifdef __BIONIC__
129 // Test a couple of values. Make sure they are different.
130 uintptr_t last = 0;
131 for (size_t i = 0; i < 100; ++i) {
132 uintptr_t random_start = CreateStartPos(i * kPageSize);
133 EXPECT_NE(last, random_start);
134 last = random_start;
135 }
136
137 // Even on max, should be below ART_BASE_ADDRESS.
138 EXPECT_LT(CreateStartPos(~0), static_cast<uintptr_t>(ART_BASE_ADDRESS));
139#endif
140 // End of test.
141}
142#endif
143
Brian Carlstrom9004cb62013-07-26 15:48:31 -0700144TEST_F(MemMapTest, MapAnonymousEmpty) {
Mathieu Chartier6e88ef62014-10-14 15:01:24 -0700145 CommonInit();
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700146 std::string error_msg;
Ian Rogers700a4022014-05-19 16:49:03 -0700147 std::unique_ptr<MemMap> map(MemMap::MapAnonymous("MapAnonymousEmpty",
Vladimir Marko5c42c292015-02-25 12:02:49 +0000148 nullptr,
149 0,
150 PROT_READ,
151 false,
152 false,
153 &error_msg));
Ian Rogersef7d42f2014-01-06 12:55:46 -0800154 ASSERT_TRUE(map.get() != nullptr) << error_msg;
155 ASSERT_TRUE(error_msg.empty());
156 map.reset(MemMap::MapAnonymous("MapAnonymousEmpty",
157 nullptr,
158 kPageSize,
159 PROT_READ | PROT_WRITE,
160 false,
Vladimir Marko5c42c292015-02-25 12:02:49 +0000161 false,
Ian Rogersef7d42f2014-01-06 12:55:46 -0800162 &error_msg));
163 ASSERT_TRUE(map.get() != nullptr) << error_msg;
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700164 ASSERT_TRUE(error_msg.empty());
Brian Carlstrom9004cb62013-07-26 15:48:31 -0700165}
166
Mathieu Chartier486932a2016-02-24 10:09:23 -0800167TEST_F(MemMapTest, MapAnonymousFailNullError) {
168 CommonInit();
169 // Test that we don't crash with a null error_str when mapping at an invalid location.
170 std::unique_ptr<MemMap> map(MemMap::MapAnonymous("MapAnonymousInvalid",
171 reinterpret_cast<uint8_t*>(kPageSize),
172 0x20000,
173 PROT_READ | PROT_WRITE,
174 false,
175 false,
176 nullptr));
177 ASSERT_EQ(nullptr, map.get());
178}
179
Ian Rogersef7d42f2014-01-06 12:55:46 -0800180#ifdef __LP64__
181TEST_F(MemMapTest, MapAnonymousEmpty32bit) {
Mathieu Chartier6e88ef62014-10-14 15:01:24 -0700182 CommonInit();
Hiroshi Yamauchifd7e7f12013-10-22 14:17:48 -0700183 std::string error_msg;
Ian Rogers700a4022014-05-19 16:49:03 -0700184 std::unique_ptr<MemMap> map(MemMap::MapAnonymous("MapAnonymousEmpty",
Vladimir Marko5c42c292015-02-25 12:02:49 +0000185 nullptr,
186 kPageSize,
187 PROT_READ | PROT_WRITE,
188 true,
189 false,
190 &error_msg));
Ian Rogersef7d42f2014-01-06 12:55:46 -0800191 ASSERT_TRUE(map.get() != nullptr) << error_msg;
192 ASSERT_TRUE(error_msg.empty());
193 ASSERT_LT(reinterpret_cast<uintptr_t>(BaseBegin(map.get())), 1ULL << 32);
Hiroshi Yamauchifd7e7f12013-10-22 14:17:48 -0700194}
Mathieu Chartier42bddce2015-11-09 15:16:56 -0800195TEST_F(MemMapTest, MapFile32Bit) {
196 CommonInit();
197 std::string error_msg;
198 ScratchFile scratch_file;
199 constexpr size_t kMapSize = kPageSize;
200 std::unique_ptr<uint8_t[]> data(new uint8_t[kMapSize]());
201 ASSERT_TRUE(scratch_file.GetFile()->WriteFully(&data[0], kMapSize));
202 std::unique_ptr<MemMap> map(MemMap::MapFile(/*byte_count*/kMapSize,
203 PROT_READ,
204 MAP_PRIVATE,
205 scratch_file.GetFd(),
206 /*start*/0,
207 /*low_4gb*/true,
208 scratch_file.GetFilename().c_str(),
209 &error_msg));
210 ASSERT_TRUE(map != nullptr) << error_msg;
211 ASSERT_TRUE(error_msg.empty());
212 ASSERT_EQ(map->Size(), kMapSize);
213 ASSERT_LT(reinterpret_cast<uintptr_t>(BaseBegin(map.get())), 1ULL << 32);
214}
Ian Rogersef7d42f2014-01-06 12:55:46 -0800215#endif
216
Hiroshi Yamauchi4fb5df82014-03-13 15:10:27 -0700217TEST_F(MemMapTest, MapAnonymousExactAddr) {
Mathieu Chartier6e88ef62014-10-14 15:01:24 -0700218 CommonInit();
Hiroshi Yamauchi4fb5df82014-03-13 15:10:27 -0700219 std::string error_msg;
Mathieu Chartier16d29f82015-11-10 10:32:52 -0800220 // Find a valid address.
221 uint8_t* valid_address = GetValidMapAddress(kPageSize, /*low_4gb*/false);
Hiroshi Yamauchi4fb5df82014-03-13 15:10:27 -0700222 // Map at an address that should work, which should succeed.
Ian Rogers700a4022014-05-19 16:49:03 -0700223 std::unique_ptr<MemMap> map0(MemMap::MapAnonymous("MapAnonymous0",
Mathieu Chartier16d29f82015-11-10 10:32:52 -0800224 valid_address,
Vladimir Marko5c42c292015-02-25 12:02:49 +0000225 kPageSize,
226 PROT_READ | PROT_WRITE,
227 false,
228 false,
229 &error_msg));
Hiroshi Yamauchi4fb5df82014-03-13 15:10:27 -0700230 ASSERT_TRUE(map0.get() != nullptr) << error_msg;
231 ASSERT_TRUE(error_msg.empty());
Mathieu Chartier16d29f82015-11-10 10:32:52 -0800232 ASSERT_TRUE(map0->BaseBegin() == valid_address);
Hiroshi Yamauchi4fb5df82014-03-13 15:10:27 -0700233 // Map at an unspecified address, which should succeed.
Ian Rogers700a4022014-05-19 16:49:03 -0700234 std::unique_ptr<MemMap> map1(MemMap::MapAnonymous("MapAnonymous1",
Vladimir Marko5c42c292015-02-25 12:02:49 +0000235 nullptr,
236 kPageSize,
237 PROT_READ | PROT_WRITE,
238 false,
239 false,
240 &error_msg));
Hiroshi Yamauchi4fb5df82014-03-13 15:10:27 -0700241 ASSERT_TRUE(map1.get() != nullptr) << error_msg;
242 ASSERT_TRUE(error_msg.empty());
243 ASSERT_TRUE(map1->BaseBegin() != nullptr);
244 // Attempt to map at the same address, which should fail.
Ian Rogers700a4022014-05-19 16:49:03 -0700245 std::unique_ptr<MemMap> map2(MemMap::MapAnonymous("MapAnonymous2",
Vladimir Marko5c42c292015-02-25 12:02:49 +0000246 reinterpret_cast<uint8_t*>(map1->BaseBegin()),
247 kPageSize,
248 PROT_READ | PROT_WRITE,
249 false,
250 false,
251 &error_msg));
Hiroshi Yamauchi4fb5df82014-03-13 15:10:27 -0700252 ASSERT_TRUE(map2.get() == nullptr) << error_msg;
253 ASSERT_TRUE(!error_msg.empty());
254}
255
Ian Rogersef7d42f2014-01-06 12:55:46 -0800256TEST_F(MemMapTest, RemapAtEnd) {
257 RemapAtEndTest(false);
258}
259
260#ifdef __LP64__
261TEST_F(MemMapTest, RemapAtEnd32bit) {
262 RemapAtEndTest(true);
263}
264#endif
Hiroshi Yamauchifd7e7f12013-10-22 14:17:48 -0700265
Qiming Shi84d49cc2014-04-24 15:38:41 +0800266TEST_F(MemMapTest, MapAnonymousExactAddr32bitHighAddr) {
Roland Levillain14306b82016-01-20 12:13:57 +0000267 // Some MIPS32 hardware (namely the Creator Ci20 development board)
268 // cannot allocate in the 2GB-4GB region.
269 TEST_DISABLED_FOR_MIPS();
270
Mathieu Chartier6e88ef62014-10-14 15:01:24 -0700271 CommonInit();
Andreas Gampe928f72b2014-09-09 19:53:48 -0700272 // This test may not work under valgrind.
Evgenii Stepanov1e133742015-05-20 12:30:59 -0700273 if (RUNNING_ON_MEMORY_TOOL == 0) {
Mathieu Chartier16d29f82015-11-10 10:32:52 -0800274 constexpr size_t size = 0x100000;
275 // Try all addresses starting from 2GB to 4GB.
276 size_t start_addr = 2 * GB;
Andreas Gampe928f72b2014-09-09 19:53:48 -0700277 std::string error_msg;
Mathieu Chartier16d29f82015-11-10 10:32:52 -0800278 std::unique_ptr<MemMap> map;
279 for (; start_addr <= std::numeric_limits<uint32_t>::max() - size; start_addr += size) {
280 map.reset(MemMap::MapAnonymous("MapAnonymousExactAddr32bitHighAddr",
281 reinterpret_cast<uint8_t*>(start_addr),
282 size,
283 PROT_READ | PROT_WRITE,
284 /*low_4gb*/true,
285 false,
286 &error_msg));
287 if (map != nullptr) {
288 break;
289 }
290 }
Andreas Gampe928f72b2014-09-09 19:53:48 -0700291 ASSERT_TRUE(map.get() != nullptr) << error_msg;
Roland Levillain8d026442016-01-19 17:30:33 +0000292 ASSERT_GE(reinterpret_cast<uintptr_t>(map->End()), 2u * GB);
Andreas Gampe928f72b2014-09-09 19:53:48 -0700293 ASSERT_TRUE(error_msg.empty());
Mathieu Chartier16d29f82015-11-10 10:32:52 -0800294 ASSERT_EQ(BaseBegin(map.get()), reinterpret_cast<void*>(start_addr));
Andreas Gampe928f72b2014-09-09 19:53:48 -0700295 }
Qiming Shi84d49cc2014-04-24 15:38:41 +0800296}
297
298TEST_F(MemMapTest, MapAnonymousOverflow) {
Mathieu Chartier6e88ef62014-10-14 15:01:24 -0700299 CommonInit();
Qiming Shi84d49cc2014-04-24 15:38:41 +0800300 std::string error_msg;
301 uintptr_t ptr = 0;
302 ptr -= kPageSize; // Now it's close to the top.
Ian Rogers700a4022014-05-19 16:49:03 -0700303 std::unique_ptr<MemMap> map(MemMap::MapAnonymous("MapAnonymousOverflow",
Vladimir Marko5c42c292015-02-25 12:02:49 +0000304 reinterpret_cast<uint8_t*>(ptr),
305 2 * kPageSize, // brings it over the top.
306 PROT_READ | PROT_WRITE,
307 false,
308 false,
309 &error_msg));
Qiming Shi84d49cc2014-04-24 15:38:41 +0800310 ASSERT_EQ(nullptr, map.get());
311 ASSERT_FALSE(error_msg.empty());
312}
313
314#ifdef __LP64__
315TEST_F(MemMapTest, MapAnonymousLow4GBExpectedTooHigh) {
Mathieu Chartier6e88ef62014-10-14 15:01:24 -0700316 CommonInit();
Qiming Shi84d49cc2014-04-24 15:38:41 +0800317 std::string error_msg;
Vladimir Marko5c42c292015-02-25 12:02:49 +0000318 std::unique_ptr<MemMap> map(
319 MemMap::MapAnonymous("MapAnonymousLow4GBExpectedTooHigh",
320 reinterpret_cast<uint8_t*>(UINT64_C(0x100000000)),
321 kPageSize,
322 PROT_READ | PROT_WRITE,
323 true,
324 false,
325 &error_msg));
Qiming Shi84d49cc2014-04-24 15:38:41 +0800326 ASSERT_EQ(nullptr, map.get());
327 ASSERT_FALSE(error_msg.empty());
328}
329
330TEST_F(MemMapTest, MapAnonymousLow4GBRangeTooHigh) {
Mathieu Chartier6e88ef62014-10-14 15:01:24 -0700331 CommonInit();
Qiming Shi84d49cc2014-04-24 15:38:41 +0800332 std::string error_msg;
Ian Rogers700a4022014-05-19 16:49:03 -0700333 std::unique_ptr<MemMap> map(MemMap::MapAnonymous("MapAnonymousLow4GBRangeTooHigh",
Vladimir Marko5c42c292015-02-25 12:02:49 +0000334 reinterpret_cast<uint8_t*>(0xF0000000),
335 0x20000000,
336 PROT_READ | PROT_WRITE,
337 true,
338 false,
339 &error_msg));
Qiming Shi84d49cc2014-04-24 15:38:41 +0800340 ASSERT_EQ(nullptr, map.get());
341 ASSERT_FALSE(error_msg.empty());
342}
343#endif
344
Vladimir Marko5c42c292015-02-25 12:02:49 +0000345TEST_F(MemMapTest, MapAnonymousReuse) {
346 CommonInit();
347 std::string error_msg;
348 std::unique_ptr<MemMap> map(MemMap::MapAnonymous("MapAnonymousReserve",
349 nullptr,
350 0x20000,
351 PROT_READ | PROT_WRITE,
352 false,
353 false,
354 &error_msg));
355 ASSERT_NE(nullptr, map.get());
356 ASSERT_TRUE(error_msg.empty());
357 std::unique_ptr<MemMap> map2(MemMap::MapAnonymous("MapAnonymousReused",
358 reinterpret_cast<uint8_t*>(map->BaseBegin()),
359 0x10000,
360 PROT_READ | PROT_WRITE,
361 false,
362 true,
363 &error_msg));
364 ASSERT_NE(nullptr, map2.get());
365 ASSERT_TRUE(error_msg.empty());
366}
367
Hiroshi Yamauchi3eed93d2014-06-04 11:43:59 -0700368TEST_F(MemMapTest, CheckNoGaps) {
Mathieu Chartier6e88ef62014-10-14 15:01:24 -0700369 CommonInit();
Hiroshi Yamauchi3eed93d2014-06-04 11:43:59 -0700370 std::string error_msg;
371 constexpr size_t kNumPages = 3;
372 // Map a 3-page mem map.
373 std::unique_ptr<MemMap> map(MemMap::MapAnonymous("MapAnonymous0",
374 nullptr,
375 kPageSize * kNumPages,
376 PROT_READ | PROT_WRITE,
377 false,
Vladimir Marko5c42c292015-02-25 12:02:49 +0000378 false,
Hiroshi Yamauchi3eed93d2014-06-04 11:43:59 -0700379 &error_msg));
380 ASSERT_TRUE(map.get() != nullptr) << error_msg;
381 ASSERT_TRUE(error_msg.empty());
382 // Record the base address.
Ian Rogers13735952014-10-08 12:43:28 -0700383 uint8_t* map_base = reinterpret_cast<uint8_t*>(map->BaseBegin());
Hiroshi Yamauchi3eed93d2014-06-04 11:43:59 -0700384 // Unmap it.
385 map.reset();
386
387 // Map at the same address, but in page-sized separate mem maps,
388 // assuming the space at the address is still available.
389 std::unique_ptr<MemMap> map0(MemMap::MapAnonymous("MapAnonymous0",
390 map_base,
391 kPageSize,
392 PROT_READ | PROT_WRITE,
393 false,
Vladimir Marko5c42c292015-02-25 12:02:49 +0000394 false,
Hiroshi Yamauchi3eed93d2014-06-04 11:43:59 -0700395 &error_msg));
396 ASSERT_TRUE(map0.get() != nullptr) << error_msg;
397 ASSERT_TRUE(error_msg.empty());
398 std::unique_ptr<MemMap> map1(MemMap::MapAnonymous("MapAnonymous1",
399 map_base + kPageSize,
400 kPageSize,
401 PROT_READ | PROT_WRITE,
402 false,
Vladimir Marko5c42c292015-02-25 12:02:49 +0000403 false,
Hiroshi Yamauchi3eed93d2014-06-04 11:43:59 -0700404 &error_msg));
405 ASSERT_TRUE(map1.get() != nullptr) << error_msg;
406 ASSERT_TRUE(error_msg.empty());
407 std::unique_ptr<MemMap> map2(MemMap::MapAnonymous("MapAnonymous2",
408 map_base + kPageSize * 2,
409 kPageSize,
410 PROT_READ | PROT_WRITE,
411 false,
Vladimir Marko5c42c292015-02-25 12:02:49 +0000412 false,
Hiroshi Yamauchi3eed93d2014-06-04 11:43:59 -0700413 &error_msg));
414 ASSERT_TRUE(map2.get() != nullptr) << error_msg;
415 ASSERT_TRUE(error_msg.empty());
416
417 // One-map cases.
418 ASSERT_TRUE(MemMap::CheckNoGaps(map0.get(), map0.get()));
419 ASSERT_TRUE(MemMap::CheckNoGaps(map1.get(), map1.get()));
420 ASSERT_TRUE(MemMap::CheckNoGaps(map2.get(), map2.get()));
421
422 // Two or three-map cases.
423 ASSERT_TRUE(MemMap::CheckNoGaps(map0.get(), map1.get()));
424 ASSERT_TRUE(MemMap::CheckNoGaps(map1.get(), map2.get()));
425 ASSERT_TRUE(MemMap::CheckNoGaps(map0.get(), map2.get()));
426
427 // Unmap the middle one.
428 map1.reset();
429
430 // Should return false now that there's a gap in the middle.
431 ASSERT_FALSE(MemMap::CheckNoGaps(map0.get(), map2.get()));
432}
433
Brian Carlstrom9004cb62013-07-26 15:48:31 -0700434} // namespace art