| Index: base/shared_memory_unittest.cc
|
| diff --git a/base/shared_memory_unittest.cc b/base/shared_memory_unittest.cc
|
| index bd537692f4880febe1ce12dc9a18e91991296ca4..f02e2753130fafc3f1bde74351b099482f0b2b8c 100644
|
| --- a/base/shared_memory_unittest.cc
|
| +++ b/base/shared_memory_unittest.cc
|
| @@ -8,6 +8,7 @@
|
| #endif
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/shared_memory.h"
|
| +#include "base/sys_info.h"
|
| #include "base/test/multiprocess_test.h"
|
| #include "base/threading/platform_thread.h"
|
| #include "base/time.h"
|
| @@ -343,6 +344,33 @@ TEST(SharedMemoryTest, AnonymousPrivate) {
|
| }
|
| }
|
|
|
| +TEST(SharedMemoryTest, MapAt) {
|
| + ASSERT_TRUE(SysInfo::VMAllocationGranularity() >= sizeof(uint32));
|
| + const size_t kCount = SysInfo::VMAllocationGranularity();
|
| + const size_t kDataSize = kCount * sizeof(uint32);
|
| +
|
| + SharedMemory memory;
|
| + ASSERT_TRUE(memory.CreateAndMapAnonymous(kDataSize));
|
| + ASSERT_TRUE(memory.Map(kDataSize));
|
| + uint32* ptr = static_cast<uint32*>(memory.memory());
|
| + ASSERT_NE(ptr, static_cast<void*>(NULL));
|
| +
|
| + for (size_t i = 0; i < kCount; ++i) {
|
| + ptr[i] = i;
|
| + }
|
| +
|
| + memory.Unmap();
|
| +
|
| + off_t offset = SysInfo::VMAllocationGranularity();
|
| + ASSERT_TRUE(memory.MapAt(offset, kDataSize - offset));
|
| + offset /= sizeof(uint32);
|
| + ptr = static_cast<uint32*>(memory.memory());
|
| + ASSERT_NE(ptr, static_cast<void*>(NULL));
|
| + for (size_t i = offset; i < kCount; ++i) {
|
| + EXPECT_EQ(ptr[i - offset], i);
|
| + }
|
| +}
|
| +
|
| #if defined(OS_POSIX)
|
| // Create a shared memory object, mmap it, and mprotect it to PROT_EXEC.
|
| TEST(SharedMemoryTest, AnonymousExecutable) {
|
|
|