Brian Carlstrom | 9004cb6 | 2013-07-26 15:48:31 -0700 | [diff] [blame] | 1 | /* |
| 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 Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 19 | #include <memory> |
| 20 | |
Andreas Gampe | 928f72b | 2014-09-09 19:53:48 -0700 | [diff] [blame] | 21 | #include <valgrind.h> |
| 22 | |
Brian Carlstrom | 9004cb6 | 2013-07-26 15:48:31 -0700 | [diff] [blame] | 23 | #include "gtest/gtest.h" |
| 24 | |
| 25 | namespace art { |
| 26 | |
Hiroshi Yamauchi | fd7e7f1 | 2013-10-22 14:17:48 -0700 | [diff] [blame] | 27 | class MemMapTest : public testing::Test { |
| 28 | public: |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 29 | static uint8_t* BaseBegin(MemMap* mem_map) { |
| 30 | return reinterpret_cast<uint8_t*>(mem_map->base_begin_); |
Hiroshi Yamauchi | fd7e7f1 | 2013-10-22 14:17:48 -0700 | [diff] [blame] | 31 | } |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 32 | static size_t BaseSize(MemMap* mem_map) { |
Hiroshi Yamauchi | fd7e7f1 | 2013-10-22 14:17:48 -0700 | [diff] [blame] | 33 | return mem_map->base_size_; |
| 34 | } |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 35 | |
| 36 | static void RemapAtEndTest(bool low_4gb) { |
| 37 | std::string error_msg; |
| 38 | // Cast the page size to size_t. |
| 39 | const size_t page_size = static_cast<size_t>(kPageSize); |
| 40 | // Map a two-page memory region. |
| 41 | MemMap* m0 = MemMap::MapAnonymous("MemMapTest_RemapAtEndTest_map0", |
| 42 | nullptr, |
| 43 | 2 * page_size, |
| 44 | PROT_READ | PROT_WRITE, |
| 45 | low_4gb, |
| 46 | &error_msg); |
| 47 | // Check its state and write to it. |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 48 | uint8_t* base0 = m0->Begin(); |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 49 | ASSERT_TRUE(base0 != nullptr) << error_msg; |
| 50 | size_t size0 = m0->Size(); |
| 51 | EXPECT_EQ(m0->Size(), 2 * page_size); |
| 52 | EXPECT_EQ(BaseBegin(m0), base0); |
| 53 | EXPECT_EQ(BaseSize(m0), size0); |
| 54 | memset(base0, 42, 2 * page_size); |
| 55 | // Remap the latter half into a second MemMap. |
| 56 | MemMap* m1 = m0->RemapAtEnd(base0 + page_size, |
| 57 | "MemMapTest_RemapAtEndTest_map1", |
| 58 | PROT_READ | PROT_WRITE, |
| 59 | &error_msg); |
| 60 | // Check the states of the two maps. |
| 61 | EXPECT_EQ(m0->Begin(), base0) << error_msg; |
| 62 | EXPECT_EQ(m0->Size(), page_size); |
| 63 | EXPECT_EQ(BaseBegin(m0), base0); |
| 64 | EXPECT_EQ(BaseSize(m0), page_size); |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 65 | uint8_t* base1 = m1->Begin(); |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 66 | size_t size1 = m1->Size(); |
| 67 | EXPECT_EQ(base1, base0 + page_size); |
| 68 | EXPECT_EQ(size1, page_size); |
| 69 | EXPECT_EQ(BaseBegin(m1), base1); |
| 70 | EXPECT_EQ(BaseSize(m1), size1); |
| 71 | // Write to the second region. |
| 72 | memset(base1, 43, page_size); |
| 73 | // Check the contents of the two regions. |
| 74 | for (size_t i = 0; i < page_size; ++i) { |
| 75 | EXPECT_EQ(base0[i], 42); |
| 76 | } |
| 77 | for (size_t i = 0; i < page_size; ++i) { |
| 78 | EXPECT_EQ(base1[i], 43); |
| 79 | } |
| 80 | // Unmap the first region. |
| 81 | delete m0; |
| 82 | // Make sure the second region is still accessible after the first |
| 83 | // region is unmapped. |
| 84 | for (size_t i = 0; i < page_size; ++i) { |
| 85 | EXPECT_EQ(base1[i], 43); |
| 86 | } |
| 87 | delete m1; |
| 88 | } |
Andreas Gampe | d8f26db | 2014-05-19 17:01:13 -0700 | [diff] [blame] | 89 | |
Mathieu Chartier | 6e88ef6 | 2014-10-14 15:01:24 -0700 | [diff] [blame] | 90 | void CommonInit() { |
| 91 | MemMap::Init(); |
| 92 | } |
| 93 | |
Andreas Gampe | d8f26db | 2014-05-19 17:01:13 -0700 | [diff] [blame] | 94 | #if defined(__LP64__) && !defined(__x86_64__) |
| 95 | static uintptr_t GetLinearScanPos() { |
| 96 | return MemMap::next_mem_pos_; |
| 97 | } |
| 98 | #endif |
Hiroshi Yamauchi | fd7e7f1 | 2013-10-22 14:17:48 -0700 | [diff] [blame] | 99 | }; |
Brian Carlstrom | 9004cb6 | 2013-07-26 15:48:31 -0700 | [diff] [blame] | 100 | |
Andreas Gampe | d8f26db | 2014-05-19 17:01:13 -0700 | [diff] [blame] | 101 | #if defined(__LP64__) && !defined(__x86_64__) |
| 102 | |
| 103 | #ifdef __BIONIC__ |
| 104 | extern uintptr_t CreateStartPos(uint64_t input); |
| 105 | #endif |
| 106 | |
| 107 | TEST_F(MemMapTest, Start) { |
Mathieu Chartier | 6e88ef6 | 2014-10-14 15:01:24 -0700 | [diff] [blame] | 108 | CommonInit(); |
Andreas Gampe | d8f26db | 2014-05-19 17:01:13 -0700 | [diff] [blame] | 109 | uintptr_t start = GetLinearScanPos(); |
| 110 | EXPECT_LE(64 * KB, start); |
| 111 | EXPECT_LT(start, static_cast<uintptr_t>(ART_BASE_ADDRESS)); |
Andreas Gampe | d8f26db | 2014-05-19 17:01:13 -0700 | [diff] [blame] | 112 | #ifdef __BIONIC__ |
| 113 | // Test a couple of values. Make sure they are different. |
| 114 | uintptr_t last = 0; |
| 115 | for (size_t i = 0; i < 100; ++i) { |
| 116 | uintptr_t random_start = CreateStartPos(i * kPageSize); |
| 117 | EXPECT_NE(last, random_start); |
| 118 | last = random_start; |
| 119 | } |
| 120 | |
| 121 | // Even on max, should be below ART_BASE_ADDRESS. |
| 122 | EXPECT_LT(CreateStartPos(~0), static_cast<uintptr_t>(ART_BASE_ADDRESS)); |
| 123 | #endif |
| 124 | // End of test. |
| 125 | } |
| 126 | #endif |
| 127 | |
Brian Carlstrom | 9004cb6 | 2013-07-26 15:48:31 -0700 | [diff] [blame] | 128 | TEST_F(MemMapTest, MapAnonymousEmpty) { |
Mathieu Chartier | 6e88ef6 | 2014-10-14 15:01:24 -0700 | [diff] [blame] | 129 | CommonInit(); |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 130 | std::string error_msg; |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 131 | std::unique_ptr<MemMap> map(MemMap::MapAnonymous("MapAnonymousEmpty", |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 132 | nullptr, |
Brian Carlstrom | 9004cb6 | 2013-07-26 15:48:31 -0700 | [diff] [blame] | 133 | 0, |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 134 | PROT_READ, |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 135 | false, |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 136 | &error_msg)); |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 137 | ASSERT_TRUE(map.get() != nullptr) << error_msg; |
| 138 | ASSERT_TRUE(error_msg.empty()); |
| 139 | map.reset(MemMap::MapAnonymous("MapAnonymousEmpty", |
| 140 | nullptr, |
| 141 | kPageSize, |
| 142 | PROT_READ | PROT_WRITE, |
| 143 | false, |
| 144 | &error_msg)); |
| 145 | ASSERT_TRUE(map.get() != nullptr) << error_msg; |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 146 | ASSERT_TRUE(error_msg.empty()); |
Brian Carlstrom | 9004cb6 | 2013-07-26 15:48:31 -0700 | [diff] [blame] | 147 | } |
| 148 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 149 | #ifdef __LP64__ |
| 150 | TEST_F(MemMapTest, MapAnonymousEmpty32bit) { |
Mathieu Chartier | 6e88ef6 | 2014-10-14 15:01:24 -0700 | [diff] [blame] | 151 | CommonInit(); |
Hiroshi Yamauchi | fd7e7f1 | 2013-10-22 14:17:48 -0700 | [diff] [blame] | 152 | std::string error_msg; |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 153 | std::unique_ptr<MemMap> map(MemMap::MapAnonymous("MapAnonymousEmpty", |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 154 | nullptr, |
| 155 | kPageSize, |
| 156 | PROT_READ | PROT_WRITE, |
| 157 | true, |
| 158 | &error_msg)); |
| 159 | ASSERT_TRUE(map.get() != nullptr) << error_msg; |
| 160 | ASSERT_TRUE(error_msg.empty()); |
| 161 | ASSERT_LT(reinterpret_cast<uintptr_t>(BaseBegin(map.get())), 1ULL << 32); |
Hiroshi Yamauchi | fd7e7f1 | 2013-10-22 14:17:48 -0700 | [diff] [blame] | 162 | } |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 163 | #endif |
| 164 | |
Hiroshi Yamauchi | 4fb5df8 | 2014-03-13 15:10:27 -0700 | [diff] [blame] | 165 | TEST_F(MemMapTest, MapAnonymousExactAddr) { |
Mathieu Chartier | 6e88ef6 | 2014-10-14 15:01:24 -0700 | [diff] [blame] | 166 | CommonInit(); |
Hiroshi Yamauchi | 4fb5df8 | 2014-03-13 15:10:27 -0700 | [diff] [blame] | 167 | std::string error_msg; |
| 168 | // Map at an address that should work, which should succeed. |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 169 | std::unique_ptr<MemMap> map0(MemMap::MapAnonymous("MapAnonymous0", |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 170 | reinterpret_cast<uint8_t*>(ART_BASE_ADDRESS), |
Hiroshi Yamauchi | 4fb5df8 | 2014-03-13 15:10:27 -0700 | [diff] [blame] | 171 | kPageSize, |
| 172 | PROT_READ | PROT_WRITE, |
| 173 | false, |
| 174 | &error_msg)); |
| 175 | ASSERT_TRUE(map0.get() != nullptr) << error_msg; |
| 176 | ASSERT_TRUE(error_msg.empty()); |
| 177 | ASSERT_TRUE(map0->BaseBegin() == reinterpret_cast<void*>(ART_BASE_ADDRESS)); |
| 178 | // Map at an unspecified address, which should succeed. |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 179 | std::unique_ptr<MemMap> map1(MemMap::MapAnonymous("MapAnonymous1", |
Hiroshi Yamauchi | 4fb5df8 | 2014-03-13 15:10:27 -0700 | [diff] [blame] | 180 | nullptr, |
| 181 | kPageSize, |
| 182 | PROT_READ | PROT_WRITE, |
| 183 | false, |
| 184 | &error_msg)); |
| 185 | ASSERT_TRUE(map1.get() != nullptr) << error_msg; |
| 186 | ASSERT_TRUE(error_msg.empty()); |
| 187 | ASSERT_TRUE(map1->BaseBegin() != nullptr); |
| 188 | // Attempt to map at the same address, which should fail. |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 189 | std::unique_ptr<MemMap> map2(MemMap::MapAnonymous("MapAnonymous2", |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 190 | reinterpret_cast<uint8_t*>(map1->BaseBegin()), |
Hiroshi Yamauchi | 4fb5df8 | 2014-03-13 15:10:27 -0700 | [diff] [blame] | 191 | kPageSize, |
| 192 | PROT_READ | PROT_WRITE, |
| 193 | false, |
| 194 | &error_msg)); |
| 195 | ASSERT_TRUE(map2.get() == nullptr) << error_msg; |
| 196 | ASSERT_TRUE(!error_msg.empty()); |
| 197 | } |
| 198 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 199 | TEST_F(MemMapTest, RemapAtEnd) { |
| 200 | RemapAtEndTest(false); |
| 201 | } |
| 202 | |
| 203 | #ifdef __LP64__ |
| 204 | TEST_F(MemMapTest, RemapAtEnd32bit) { |
| 205 | RemapAtEndTest(true); |
| 206 | } |
| 207 | #endif |
Hiroshi Yamauchi | fd7e7f1 | 2013-10-22 14:17:48 -0700 | [diff] [blame] | 208 | |
Qiming Shi | 84d49cc | 2014-04-24 15:38:41 +0800 | [diff] [blame] | 209 | TEST_F(MemMapTest, MapAnonymousExactAddr32bitHighAddr) { |
Mathieu Chartier | 6e88ef6 | 2014-10-14 15:01:24 -0700 | [diff] [blame] | 210 | CommonInit(); |
Andreas Gampe | 928f72b | 2014-09-09 19:53:48 -0700 | [diff] [blame] | 211 | // This test may not work under valgrind. |
| 212 | if (RUNNING_ON_VALGRIND == 0) { |
| 213 | uintptr_t start_addr = ART_BASE_ADDRESS + 0x1000000; |
| 214 | std::string error_msg; |
| 215 | std::unique_ptr<MemMap> map(MemMap::MapAnonymous("MapAnonymousExactAddr32bitHighAddr", |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 216 | reinterpret_cast<uint8_t*>(start_addr), |
Andreas Gampe | 928f72b | 2014-09-09 19:53:48 -0700 | [diff] [blame] | 217 | 0x21000000, |
| 218 | PROT_READ | PROT_WRITE, |
| 219 | true, |
| 220 | &error_msg)); |
| 221 | ASSERT_TRUE(map.get() != nullptr) << error_msg; |
| 222 | ASSERT_TRUE(error_msg.empty()); |
| 223 | ASSERT_EQ(reinterpret_cast<uintptr_t>(BaseBegin(map.get())), start_addr); |
| 224 | } |
Qiming Shi | 84d49cc | 2014-04-24 15:38:41 +0800 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | TEST_F(MemMapTest, MapAnonymousOverflow) { |
Mathieu Chartier | 6e88ef6 | 2014-10-14 15:01:24 -0700 | [diff] [blame] | 228 | CommonInit(); |
Qiming Shi | 84d49cc | 2014-04-24 15:38:41 +0800 | [diff] [blame] | 229 | std::string error_msg; |
| 230 | uintptr_t ptr = 0; |
| 231 | ptr -= kPageSize; // Now it's close to the top. |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 232 | std::unique_ptr<MemMap> map(MemMap::MapAnonymous("MapAnonymousOverflow", |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 233 | reinterpret_cast<uint8_t*>(ptr), |
Qiming Shi | 84d49cc | 2014-04-24 15:38:41 +0800 | [diff] [blame] | 234 | 2 * kPageSize, // brings it over the top. |
| 235 | PROT_READ | PROT_WRITE, |
| 236 | false, |
| 237 | &error_msg)); |
| 238 | ASSERT_EQ(nullptr, map.get()); |
| 239 | ASSERT_FALSE(error_msg.empty()); |
| 240 | } |
| 241 | |
| 242 | #ifdef __LP64__ |
| 243 | TEST_F(MemMapTest, MapAnonymousLow4GBExpectedTooHigh) { |
Mathieu Chartier | 6e88ef6 | 2014-10-14 15:01:24 -0700 | [diff] [blame] | 244 | CommonInit(); |
Qiming Shi | 84d49cc | 2014-04-24 15:38:41 +0800 | [diff] [blame] | 245 | std::string error_msg; |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 246 | std::unique_ptr<MemMap> map(MemMap::MapAnonymous("MapAnonymousLow4GBExpectedTooHigh", |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 247 | reinterpret_cast<uint8_t*>(UINT64_C(0x100000000)), |
Qiming Shi | 84d49cc | 2014-04-24 15:38:41 +0800 | [diff] [blame] | 248 | kPageSize, |
| 249 | PROT_READ | PROT_WRITE, |
| 250 | true, |
| 251 | &error_msg)); |
| 252 | ASSERT_EQ(nullptr, map.get()); |
| 253 | ASSERT_FALSE(error_msg.empty()); |
| 254 | } |
| 255 | |
| 256 | TEST_F(MemMapTest, MapAnonymousLow4GBRangeTooHigh) { |
Mathieu Chartier | 6e88ef6 | 2014-10-14 15:01:24 -0700 | [diff] [blame] | 257 | CommonInit(); |
Qiming Shi | 84d49cc | 2014-04-24 15:38:41 +0800 | [diff] [blame] | 258 | std::string error_msg; |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 259 | std::unique_ptr<MemMap> map(MemMap::MapAnonymous("MapAnonymousLow4GBRangeTooHigh", |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 260 | reinterpret_cast<uint8_t*>(0xF0000000), |
Qiming Shi | 84d49cc | 2014-04-24 15:38:41 +0800 | [diff] [blame] | 261 | 0x20000000, |
| 262 | PROT_READ | PROT_WRITE, |
| 263 | true, |
| 264 | &error_msg)); |
| 265 | ASSERT_EQ(nullptr, map.get()); |
| 266 | ASSERT_FALSE(error_msg.empty()); |
| 267 | } |
| 268 | #endif |
| 269 | |
Hiroshi Yamauchi | 3eed93d | 2014-06-04 11:43:59 -0700 | [diff] [blame] | 270 | TEST_F(MemMapTest, CheckNoGaps) { |
Mathieu Chartier | 6e88ef6 | 2014-10-14 15:01:24 -0700 | [diff] [blame] | 271 | CommonInit(); |
Hiroshi Yamauchi | 3eed93d | 2014-06-04 11:43:59 -0700 | [diff] [blame] | 272 | std::string error_msg; |
| 273 | constexpr size_t kNumPages = 3; |
| 274 | // Map a 3-page mem map. |
| 275 | std::unique_ptr<MemMap> map(MemMap::MapAnonymous("MapAnonymous0", |
| 276 | nullptr, |
| 277 | kPageSize * kNumPages, |
| 278 | PROT_READ | PROT_WRITE, |
| 279 | false, |
| 280 | &error_msg)); |
| 281 | ASSERT_TRUE(map.get() != nullptr) << error_msg; |
| 282 | ASSERT_TRUE(error_msg.empty()); |
| 283 | // Record the base address. |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 284 | uint8_t* map_base = reinterpret_cast<uint8_t*>(map->BaseBegin()); |
Hiroshi Yamauchi | 3eed93d | 2014-06-04 11:43:59 -0700 | [diff] [blame] | 285 | // Unmap it. |
| 286 | map.reset(); |
| 287 | |
| 288 | // Map at the same address, but in page-sized separate mem maps, |
| 289 | // assuming the space at the address is still available. |
| 290 | std::unique_ptr<MemMap> map0(MemMap::MapAnonymous("MapAnonymous0", |
| 291 | map_base, |
| 292 | kPageSize, |
| 293 | PROT_READ | PROT_WRITE, |
| 294 | false, |
| 295 | &error_msg)); |
| 296 | ASSERT_TRUE(map0.get() != nullptr) << error_msg; |
| 297 | ASSERT_TRUE(error_msg.empty()); |
| 298 | std::unique_ptr<MemMap> map1(MemMap::MapAnonymous("MapAnonymous1", |
| 299 | map_base + kPageSize, |
| 300 | kPageSize, |
| 301 | PROT_READ | PROT_WRITE, |
| 302 | false, |
| 303 | &error_msg)); |
| 304 | ASSERT_TRUE(map1.get() != nullptr) << error_msg; |
| 305 | ASSERT_TRUE(error_msg.empty()); |
| 306 | std::unique_ptr<MemMap> map2(MemMap::MapAnonymous("MapAnonymous2", |
| 307 | map_base + kPageSize * 2, |
| 308 | kPageSize, |
| 309 | PROT_READ | PROT_WRITE, |
| 310 | false, |
| 311 | &error_msg)); |
| 312 | ASSERT_TRUE(map2.get() != nullptr) << error_msg; |
| 313 | ASSERT_TRUE(error_msg.empty()); |
| 314 | |
| 315 | // One-map cases. |
| 316 | ASSERT_TRUE(MemMap::CheckNoGaps(map0.get(), map0.get())); |
| 317 | ASSERT_TRUE(MemMap::CheckNoGaps(map1.get(), map1.get())); |
| 318 | ASSERT_TRUE(MemMap::CheckNoGaps(map2.get(), map2.get())); |
| 319 | |
| 320 | // Two or three-map cases. |
| 321 | ASSERT_TRUE(MemMap::CheckNoGaps(map0.get(), map1.get())); |
| 322 | ASSERT_TRUE(MemMap::CheckNoGaps(map1.get(), map2.get())); |
| 323 | ASSERT_TRUE(MemMap::CheckNoGaps(map0.get(), map2.get())); |
| 324 | |
| 325 | // Unmap the middle one. |
| 326 | map1.reset(); |
| 327 | |
| 328 | // Should return false now that there's a gap in the middle. |
| 329 | ASSERT_FALSE(MemMap::CheckNoGaps(map0.get(), map2.get())); |
| 330 | } |
| 331 | |
Brian Carlstrom | 9004cb6 | 2013-07-26 15:48:31 -0700 | [diff] [blame] | 332 | } // namespace art |