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

Side by Side Diff: base/memory/shared_memory_unittest.cc

Issue 1474073002: Reland of base: Make shared memory backed by Mach primitives by default. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 unified diff | Download patch
« no previous file with comments | « base/memory/shared_memory_mac.cc ('k') | content/browser/loader/resource_buffer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/atomicops.h" 5 #include "base/atomicops.h"
6 #include "base/basictypes.h" 6 #include "base/basictypes.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/memory/shared_memory.h" 8 #include "base/memory/shared_memory.h"
9 #include "base/process/kill.h" 9 #include "base/process/kill.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 // This test is not applicable for iOS (crbug.com/399384). 466 // This test is not applicable for iOS (crbug.com/399384).
467 #if !defined(OS_IOS) 467 #if !defined(OS_IOS)
468 // Create a shared memory object, mmap it, and mprotect it to PROT_EXEC. 468 // Create a shared memory object, mmap it, and mprotect it to PROT_EXEC.
469 TEST(SharedMemoryTest, AnonymousExecutable) { 469 TEST(SharedMemoryTest, AnonymousExecutable) {
470 const uint32 kTestSize = 1 << 16; 470 const uint32 kTestSize = 1 << 16;
471 471
472 SharedMemory shared_memory; 472 SharedMemory shared_memory;
473 SharedMemoryCreateOptions options; 473 SharedMemoryCreateOptions options;
474 options.size = kTestSize; 474 options.size = kTestSize;
475 options.executable = true; 475 options.executable = true;
476 #if defined(OS_MACOSX) && !defined(OS_IOS)
477 // The Mach functionality is tested in shared_memory_mac_unittest.cc.
478 options.type = SharedMemoryHandle::POSIX;
479 #endif
476 480
477 EXPECT_TRUE(shared_memory.Create(options)); 481 EXPECT_TRUE(shared_memory.Create(options));
478 EXPECT_TRUE(shared_memory.Map(shared_memory.requested_size())); 482 EXPECT_TRUE(shared_memory.Map(shared_memory.requested_size()));
479 483
480 EXPECT_EQ(0, mprotect(shared_memory.memory(), shared_memory.requested_size(), 484 EXPECT_EQ(0, mprotect(shared_memory.memory(), shared_memory.requested_size(),
481 PROT_READ | PROT_EXEC)); 485 PROT_READ | PROT_EXEC));
482 } 486 }
483 #endif // !defined(OS_IOS) 487 #endif // !defined(OS_IOS)
484 488
485 // Android supports a different permission model than POSIX for its "ashmem" 489 // Android supports a different permission model than POSIX for its "ashmem"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 memory.Close(); 645 memory.Close();
642 SharedMemoryProcessTest::CleanUp(); 646 SharedMemoryProcessTest::CleanUp();
643 } 647 }
644 648
645 MULTIPROCESS_TEST_MAIN(SharedMemoryTestMain) { 649 MULTIPROCESS_TEST_MAIN(SharedMemoryTestMain) {
646 return SharedMemoryProcessTest::TaskTestMain(); 650 return SharedMemoryProcessTest::TaskTestMain();
647 } 651 }
648 #endif // !defined(OS_IOS) && !defined(OS_ANDROID) && !defined(OS_MACOSX) 652 #endif // !defined(OS_IOS) && !defined(OS_ANDROID) && !defined(OS_MACOSX)
649 653
650 } // namespace base 654 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/shared_memory_mac.cc ('k') | content/browser/loader/resource_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698