summaryrefslogtreecommitdiffstats
path: root/base/shared_memory_unittest.cc
diff options
context:
space:
mode:
authordalecurtis@chromium.org <dalecurtis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-18 02:17:26 +0000
committerdalecurtis@chromium.org <dalecurtis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-18 02:17:26 +0000
commit404a05868f5bf1ccdae11e1bed771d55320ad72a (patch)
treebc19e1512f942357ffedee212b4f40ea1b33e980 /base/shared_memory_unittest.cc
parent258082aba49773ac149a8df5803958ece232c870 (diff)
downloadchromium_src-404a05868f5bf1ccdae11e1bed771d55320ad72a.zip
chromium_src-404a05868f5bf1ccdae11e1bed771d55320ad72a.tar.gz
chromium_src-404a05868f5bf1ccdae11e1bed771d55320ad72a.tar.bz2
Advertise a minimum alignment for SharedMemory::Map().
No real changes, just adds a DCHECK() and unit test for a minimum alignment that callers can count on from Map(). Map() is already returning addresses which are aligned to the platform page size. Necessary for a media use case in which a wrapped shared memory object is passed around and is expected to have a certain alignment. BUG=none TEST=unittests, try bots. Review URL: https://chromiumcodereview.appspot.com/10827400 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152218 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/shared_memory_unittest.cc')
-rw-r--r--base/shared_memory_unittest.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/base/shared_memory_unittest.cc b/base/shared_memory_unittest.cc
index 759ce08..bd53769 100644
--- a/base/shared_memory_unittest.cc
+++ b/base/shared_memory_unittest.cc
@@ -361,6 +361,19 @@ TEST(SharedMemoryTest, AnonymousExecutable) {
}
#endif
+// Map() will return addresses which are aligned to the platform page size, this
+// varies from platform to platform though. Since we'd like to advertise a
+// minimum alignment that callers can count on, test for it here.
+TEST(SharedMemoryTest, MapMinimumAlignment) {
+ static const int kDataSize = 8192;
+
+ SharedMemory shared_memory;
+ ASSERT_TRUE(shared_memory.CreateAndMapAnonymous(kDataSize));
+ EXPECT_EQ(0U, reinterpret_cast<uintptr_t>(
+ shared_memory.memory()) & (SharedMemory::MAP_MINIMUM_ALIGNMENT - 1));
+ shared_memory.Close();
+}
+
#if !defined(OS_IOS) // iOS does not allow multiple processes.
// On POSIX it is especially important we test shmem across processes,