summaryrefslogtreecommitdiff
path: root/runtime/mem_map_test.cc
diff options
context:
space:
mode:
author Mathieu Chartier <mathieuc@google.com> 2015-11-09 15:16:56 -0800
committer Mathieu Chartier <mathieuc@google.com> 2015-11-09 17:18:58 -0800
commit42bddcec51e71d206f6d3b30a881ee6c1d50a63c (patch)
tree2035b4dd7dcbefbe83c04d41987e520eeb8798f0 /runtime/mem_map_test.cc
parent78232f2482e71fef255796633da68bb769baa93a (diff)
Add low_4gb support to MapFile and MapFileAtAddress
Motivation is to use this for loading app images in low 4GB at a non fixed address. Added test. Bug: 22858531 Change-Id: I0f79a4a7bfbfbdfc112e41b25c8682b1fb932ab7
Diffstat (limited to 'runtime/mem_map_test.cc')
-rw-r--r--runtime/mem_map_test.cc26
1 files changed, 23 insertions, 3 deletions
diff --git a/runtime/mem_map_test.cc b/runtime/mem_map_test.cc
index 13bf5b7698..3790e53fe3 100644
--- a/runtime/mem_map_test.cc
+++ b/runtime/mem_map_test.cc
@@ -18,13 +18,13 @@
#include <memory>
+#include "common_runtime_test.h"
#include "base/memory_tool.h"
-
-#include "gtest/gtest.h"
+#include "base/unix_file/fd_file.h"
namespace art {
-class MemMapTest : public testing::Test {
+class MemMapTest : public CommonRuntimeTest {
public:
static uint8_t* BaseBegin(MemMap* mem_map) {
return reinterpret_cast<uint8_t*>(mem_map->base_begin_);
@@ -164,6 +164,26 @@ TEST_F(MemMapTest, MapAnonymousEmpty32bit) {
ASSERT_TRUE(error_msg.empty());
ASSERT_LT(reinterpret_cast<uintptr_t>(BaseBegin(map.get())), 1ULL << 32);
}
+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));
+ std::unique_ptr<MemMap> map(MemMap::MapFile(/*byte_count*/kMapSize,
+ PROT_READ,
+ MAP_PRIVATE,
+ scratch_file.GetFd(),
+ /*start*/0,
+ /*low_4gb*/true,
+ scratch_file.GetFilename().c_str(),
+ &error_msg));
+ ASSERT_TRUE(map != nullptr) << error_msg;
+ ASSERT_TRUE(error_msg.empty());
+ ASSERT_EQ(map->Size(), kMapSize);
+ ASSERT_LT(reinterpret_cast<uintptr_t>(BaseBegin(map.get())), 1ULL << 32);
+}
#endif
TEST_F(MemMapTest, MapAnonymousExactAddr) {