summaryrefslogtreecommitdiff
path: root/libartbase/base/mem_map_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libartbase/base/mem_map_test.cc')
-rw-r--r--libartbase/base/mem_map_test.cc66
1 files changed, 33 insertions, 33 deletions
diff --git a/libartbase/base/mem_map_test.cc b/libartbase/base/mem_map_test.cc
index d6b869d19a..56dd35d9dc 100644
--- a/libartbase/base/mem_map_test.cc
+++ b/libartbase/base/mem_map_test.cc
@@ -382,10 +382,10 @@ TEST_F(MemMapTest, MapFile32Bit) {
CommonInit();
std::string error_msg;
ScratchFile scratch_file;
- constexpr size_t kMapSize = kPageSize;
- std::unique_ptr<uint8_t[]> data(new uint8_t[kMapSize]());
- ASSERT_TRUE(scratch_file.GetFile()->WriteFully(&data[0], kMapSize));
- MemMap map = MemMap::MapFile(/*byte_count=*/kMapSize,
+ const size_t map_size = kPageSize;
+ std::unique_ptr<uint8_t[]> data(new uint8_t[map_size]());
+ ASSERT_TRUE(scratch_file.GetFile()->WriteFully(&data[0], map_size));
+ MemMap map = MemMap::MapFile(/*byte_count=*/map_size,
PROT_READ,
MAP_PRIVATE,
scratch_file.GetFd(),
@@ -395,7 +395,7 @@ TEST_F(MemMapTest, MapFile32Bit) {
&error_msg);
ASSERT_TRUE(map.IsValid()) << error_msg;
ASSERT_TRUE(error_msg.empty());
- ASSERT_EQ(map.Size(), kMapSize);
+ ASSERT_EQ(map.Size(), map_size);
ASSERT_LT(reinterpret_cast<uintptr_t>(map.BaseBegin()), 1ULL << 32);
}
#endif
@@ -461,15 +461,15 @@ TEST_F(MemMapTest, RemapFileViewAtEnd) {
ScratchFile scratch_file;
// Create a scratch file 3 pages large.
- constexpr size_t kMapSize = 3 * kPageSize;
- std::unique_ptr<uint8_t[]> data(new uint8_t[kMapSize]());
+ const size_t map_size = 3 * kPageSize;
+ std::unique_ptr<uint8_t[]> data(new uint8_t[map_size]());
memset(data.get(), 1, kPageSize);
memset(&data[0], 0x55, kPageSize);
memset(&data[kPageSize], 0x5a, kPageSize);
memset(&data[2 * kPageSize], 0xaa, kPageSize);
- ASSERT_TRUE(scratch_file.GetFile()->WriteFully(&data[0], kMapSize));
+ ASSERT_TRUE(scratch_file.GetFile()->WriteFully(&data[0], map_size));
- MemMap map = MemMap::MapFile(/*byte_count=*/kMapSize,
+ MemMap map = MemMap::MapFile(/*byte_count=*/map_size,
PROT_READ,
MAP_PRIVATE,
scratch_file.GetFd(),
@@ -479,7 +479,7 @@ TEST_F(MemMapTest, RemapFileViewAtEnd) {
&error_msg);
ASSERT_TRUE(map.IsValid()) << error_msg;
ASSERT_TRUE(error_msg.empty());
- ASSERT_EQ(map.Size(), kMapSize);
+ ASSERT_EQ(map.Size(), map_size);
ASSERT_LT(reinterpret_cast<uintptr_t>(map.BaseBegin()), 1ULL << 32);
ASSERT_EQ(data[0], *map.Begin());
ASSERT_EQ(data[kPageSize], *(map.Begin() + kPageSize));
@@ -773,12 +773,12 @@ TEST_F(MemMapTest, Reservation) {
CommonInit();
std::string error_msg;
ScratchFile scratch_file;
- constexpr size_t kMapSize = 5 * kPageSize;
- std::unique_ptr<uint8_t[]> data(new uint8_t[kMapSize]());
- ASSERT_TRUE(scratch_file.GetFile()->WriteFully(&data[0], kMapSize));
+ const size_t map_size = 5 * kPageSize;
+ std::unique_ptr<uint8_t[]> data(new uint8_t[map_size]());
+ ASSERT_TRUE(scratch_file.GetFile()->WriteFully(&data[0], map_size));
MemMap reservation = MemMap::MapAnonymous("Test reservation",
- kMapSize,
+ map_size,
PROT_NONE,
/*low_4gb=*/ false,
&error_msg);
@@ -786,11 +786,11 @@ TEST_F(MemMapTest, Reservation) {
ASSERT_TRUE(error_msg.empty());
// Map first part of the reservation.
- constexpr size_t kChunk1Size = kPageSize - 1u;
- ASSERT_LT(kChunk1Size, kMapSize) << "We want to split the reservation.";
+ const size_t chunk1_size = kPageSize - 1u;
+ ASSERT_LT(chunk1_size, map_size) << "We want to split the reservation.";
uint8_t* addr1 = reservation.Begin();
MemMap map1 = MemMap::MapFileAtAddress(addr1,
- /*byte_count=*/ kChunk1Size,
+ /*byte_count=*/ chunk1_size,
PROT_READ,
MAP_PRIVATE,
scratch_file.GetFd(),
@@ -802,7 +802,7 @@ TEST_F(MemMapTest, Reservation) {
&error_msg);
ASSERT_TRUE(map1.IsValid()) << error_msg;
ASSERT_TRUE(error_msg.empty());
- ASSERT_EQ(map1.Size(), kChunk1Size);
+ ASSERT_EQ(map1.Size(), chunk1_size);
ASSERT_EQ(addr1, map1.Begin());
ASSERT_TRUE(reservation.IsValid());
// Entire pages are taken from the `reservation`.
@@ -810,12 +810,12 @@ TEST_F(MemMapTest, Reservation) {
ASSERT_EQ(map1.BaseEnd(), reservation.Begin());
// Map second part as an anonymous mapping.
- constexpr size_t kChunk2Size = 2 * kPageSize;
- DCHECK_LT(kChunk2Size, reservation.Size()); // We want to split the reservation.
+ const size_t chunk2_size = 2 * kPageSize;
+ DCHECK_LT(chunk2_size, reservation.Size()); // We want to split the reservation.
uint8_t* addr2 = reservation.Begin();
MemMap map2 = MemMap::MapAnonymous("MiddleReservation",
addr2,
- /*byte_count=*/ kChunk2Size,
+ /*byte_count=*/ chunk2_size,
PROT_READ,
/*low_4gb=*/ false,
/*reuse=*/ false,
@@ -823,16 +823,16 @@ TEST_F(MemMapTest, Reservation) {
&error_msg);
ASSERT_TRUE(map2.IsValid()) << error_msg;
ASSERT_TRUE(error_msg.empty());
- ASSERT_EQ(map2.Size(), kChunk2Size);
+ ASSERT_EQ(map2.Size(), chunk2_size);
ASSERT_EQ(addr2, map2.Begin());
- ASSERT_EQ(map2.End(), map2.BaseEnd()); // kChunk2Size is page aligned.
+ ASSERT_EQ(map2.End(), map2.BaseEnd()); // chunk2_size is page aligned.
ASSERT_EQ(map2.BaseEnd(), reservation.Begin());
// Map the rest of the reservation except the last byte.
- const size_t kChunk3Size = reservation.Size() - 1u;
+ const size_t chunk3_size = reservation.Size() - 1u;
uint8_t* addr3 = reservation.Begin();
MemMap map3 = MemMap::MapFileAtAddress(addr3,
- /*byte_count=*/ kChunk3Size,
+ /*byte_count=*/ chunk3_size,
PROT_READ,
MAP_PRIVATE,
scratch_file.GetFd(),
@@ -844,30 +844,30 @@ TEST_F(MemMapTest, Reservation) {
&error_msg);
ASSERT_TRUE(map3.IsValid()) << error_msg;
ASSERT_TRUE(error_msg.empty());
- ASSERT_EQ(map3.Size(), kChunk3Size);
+ ASSERT_EQ(map3.Size(), chunk3_size);
ASSERT_EQ(addr3, map3.Begin());
// Entire pages are taken from the `reservation`, so it's now exhausted.
ASSERT_FALSE(reservation.IsValid());
// Now split the MiddleReservation.
- constexpr size_t kChunk2ASize = kPageSize - 1u;
- DCHECK_LT(kChunk2ASize, map2.Size()); // We want to split the reservation.
- MemMap map2a = map2.TakeReservedMemory(kChunk2ASize);
+ const size_t chunk2a_size = kPageSize - 1u;
+ DCHECK_LT(chunk2a_size, map2.Size()); // We want to split the reservation.
+ MemMap map2a = map2.TakeReservedMemory(chunk2a_size);
ASSERT_TRUE(map2a.IsValid()) << error_msg;
ASSERT_TRUE(error_msg.empty());
- ASSERT_EQ(map2a.Size(), kChunk2ASize);
+ ASSERT_EQ(map2a.Size(), chunk2a_size);
ASSERT_EQ(addr2, map2a.Begin());
ASSERT_TRUE(map2.IsValid());
ASSERT_LT(map2a.End(), map2a.BaseEnd());
ASSERT_EQ(map2a.BaseEnd(), map2.Begin());
// And take the rest of the middle reservation.
- const size_t kChunk2BSize = map2.Size() - 1u;
+ const size_t chunk2b_size = map2.Size() - 1u;
uint8_t* addr2b = map2.Begin();
- MemMap map2b = map2.TakeReservedMemory(kChunk2BSize);
+ MemMap map2b = map2.TakeReservedMemory(chunk2b_size);
ASSERT_TRUE(map2b.IsValid()) << error_msg;
ASSERT_TRUE(error_msg.empty());
- ASSERT_EQ(map2b.Size(), kChunk2ASize);
+ ASSERT_EQ(map2b.Size(), chunk2a_size);
ASSERT_EQ(addr2b, map2b.Begin());
ASSERT_FALSE(map2.IsValid());
}