OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |