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

Unified Diff: base/shared_memory_unittest.cc

Issue 8585002: Give base::SharedMemory::CreateAnonymous an executable flag (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review changes Created 9 years, 1 month 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 9f69a5d7a942b4951d6ec76591913bfb2b15b149..41b8ba5c75c3b27526824fdfe0394fd08bdc8503 100644
--- a/base/shared_memory_unittest.cc
+++ b/base/shared_memory_unittest.cc
@@ -15,6 +15,10 @@
#include "base/mac/scoped_nsautorelease_pool.h"
#endif
+#if defined(OS_POSIX)
+#include <sys/mman.h>
+#endif
+
static const int kNumThreads = 5;
static const int kNumTasks = 5;
@@ -332,6 +336,24 @@ TEST(SharedMemoryTest, AnonymousPrivate) {
}
}
+#if defined(OS_POSIX)
+// Create a shared memory object, mmap it, and mprotect it to PROT_EXEC.
+TEST(SharedMemoryTest, AnonymousExecutable) {
+ const uint32 kTestSize = 1 << 16;
+
+ SharedMemory shared_memory;
+ SharedMemoryCreateOptions options;
+ options.size = kTestSize;
+ options.executable = true;
+
+ EXPECT_TRUE(shared_memory.Create(options));
+ EXPECT_TRUE(shared_memory.Map(shared_memory.created_size()));
+
+ EXPECT_EQ(0, mprotect(shared_memory.memory(), shared_memory.created_size(),
+ PROT_READ | PROT_EXEC));
+}
+#endif
+
// On POSIX it is especially important we test shmem across processes,
// not just across threads. But the test is enabled on all platforms.
class SharedMemoryProcessTest : public MultiProcessTest {

Powered by Google App Engine
This is Rietveld 408576698