Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(486)

Unified Diff: base/shared_memory_unittest.cc

Issue 10827400: Advertise a minimum alignment for SharedMemory::Map(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/shared_memory_unittest.cc
diff --git a/base/shared_memory_unittest.cc b/base/shared_memory_unittest.cc
index 759ce086eee9c42cc91ee12a3ff66f8677264303..571c77a7a5b324c9ee12b372418ac346b2cdcbca 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::kMapMinimumAlignment - 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,

Powered by Google App Engine
This is Rietveld 408576698