| Index: base/memory/shared_memory_unittest.cc
|
| diff --git a/base/memory/shared_memory_unittest.cc b/base/memory/shared_memory_unittest.cc
|
| index 6fe57060e6fcd6cd83853875fcea4c1595c52138..1aa88017dabe9c2d2f2e02e02c7f9e6a0221bcc5 100644
|
| --- a/base/memory/shared_memory_unittest.cc
|
| +++ b/base/memory/shared_memory_unittest.cc
|
| @@ -28,10 +28,6 @@
|
| #include <unistd.h>
|
| #endif
|
|
|
| -#if defined(OS_WIN)
|
| -#include "base/win/scoped_handle.h"
|
| -#endif
|
| -
|
| static const int kNumThreads = 5;
|
| #if !defined(OS_IOS) // iOS does not allow multiple processes.
|
| static const int kNumTasks = 5;
|
| @@ -90,56 +86,6 @@ class MultipleThreadMain : public PlatformThread::Delegate {
|
| const char* const MultipleThreadMain::s_test_name_ =
|
| "SharedMemoryOpenThreadTest";
|
|
|
| -// TODO(port):
|
| -// This test requires the ability to pass file descriptors between processes.
|
| -// We haven't done that yet in Chrome for POSIX.
|
| -#if defined(OS_WIN)
|
| -// Each thread will open the shared memory. Each thread will take the memory,
|
| -// and keep changing it while trying to lock it, with some small pauses in
|
| -// between. Verify that each thread's value in the shared memory is always
|
| -// correct.
|
| -class MultipleLockThread : public PlatformThread::Delegate {
|
| - public:
|
| - explicit MultipleLockThread(int id) : id_(id) {}
|
| - ~MultipleLockThread() override {}
|
| -
|
| - // PlatformThread::Delegate interface.
|
| - void ThreadMain() override {
|
| - const uint32 kDataSize = sizeof(int);
|
| - SharedMemoryHandle handle = NULL;
|
| - {
|
| - SharedMemory memory1;
|
| - EXPECT_TRUE(memory1.CreateNamedDeprecated(
|
| - "SharedMemoryMultipleLockThreadTest", true, kDataSize));
|
| - EXPECT_TRUE(memory1.ShareToProcess(GetCurrentProcess(), &handle));
|
| - // TODO(paulg): Implement this once we have a posix version of
|
| - // SharedMemory::ShareToProcess.
|
| - EXPECT_TRUE(true);
|
| - }
|
| -
|
| - SharedMemory memory2(handle, false);
|
| - EXPECT_TRUE(memory2.Map(kDataSize));
|
| - volatile int* const ptr = static_cast<int*>(memory2.memory());
|
| -
|
| - for (int idx = 0; idx < 20; idx++) {
|
| - memory2.LockDeprecated();
|
| - int i = (id_ << 16) + idx;
|
| - *ptr = i;
|
| - PlatformThread::Sleep(TimeDelta::FromMilliseconds(1));
|
| - EXPECT_EQ(*ptr, i);
|
| - memory2.UnlockDeprecated();
|
| - }
|
| -
|
| - memory2.Close();
|
| - }
|
| -
|
| - private:
|
| - int id_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(MultipleLockThread);
|
| -};
|
| -#endif
|
| -
|
| } // namespace
|
|
|
| // Android doesn't support SharedMemory::Open/Delete/
|
| @@ -320,34 +266,6 @@ TEST(SharedMemoryTest, MultipleThreads) {
|
| MultipleThreadMain::CleanUp();
|
| }
|
|
|
| -// TODO(port): this test requires the MultipleLockThread class
|
| -// (defined above), which requires the ability to pass file
|
| -// descriptors between processes. We haven't done that yet in Chrome
|
| -// for POSIX.
|
| -#if defined(OS_WIN)
|
| -// Create a set of threads to each open a shared memory segment and write to it
|
| -// with the lock held. Verify that they are always reading/writing consistent
|
| -// data.
|
| -TEST(SharedMemoryTest, Lock) {
|
| - PlatformThreadHandle thread_handles[kNumThreads];
|
| - MultipleLockThread* thread_delegates[kNumThreads];
|
| -
|
| - // Spawn the threads.
|
| - for (int index = 0; index < kNumThreads; ++index) {
|
| - PlatformThreadHandle pth;
|
| - thread_delegates[index] = new MultipleLockThread(index);
|
| - EXPECT_TRUE(PlatformThread::Create(0, thread_delegates[index], &pth));
|
| - thread_handles[index] = pth;
|
| - }
|
| -
|
| - // Wait for the threads to finish.
|
| - for (int index = 0; index < kNumThreads; ++index) {
|
| - PlatformThread::Join(thread_handles[index]);
|
| - delete thread_delegates[index];
|
| - }
|
| -}
|
| -#endif
|
| -
|
| // Allocate private (unique) shared memory with an empty string for a
|
| // name. Make sure several of them don't point to the same thing as
|
| // we might expect if the names are equal.
|
| @@ -449,37 +367,9 @@ TEST(SharedMemoryTest, ShareReadOnly) {
|
| EXPECT_EQ(EACCES, mmap_errno) << strerror(mmap_errno);
|
| if (writable != MAP_FAILED)
|
| EXPECT_EQ(0, munmap(writable, readonly_shmem.mapped_size()));
|
| -
|
| -#elif defined(OS_WIN)
|
| - EXPECT_EQ(NULL, MapViewOfFile(handle, FILE_MAP_WRITE, 0, 0, 0))
|
| - << "Shouldn't be able to map memory writable.";
|
| -
|
| - HANDLE temp_handle;
|
| - BOOL rv = ::DuplicateHandle(GetCurrentProcess(),
|
| - handle,
|
| - GetCurrentProcess(),
|
| - &temp_handle,
|
| - FILE_MAP_ALL_ACCESS,
|
| - false,
|
| - 0);
|
| - EXPECT_EQ(FALSE, rv)
|
| - << "Shouldn't be able to duplicate the handle into a writable one.";
|
| - if (rv)
|
| - base::win::ScopedHandle writable_handle(temp_handle);
|
| - rv = ::DuplicateHandle(GetCurrentProcess(),
|
| - handle,
|
| - GetCurrentProcess(),
|
| - &temp_handle,
|
| - FILE_MAP_READ,
|
| - false,
|
| - 0);
|
| - EXPECT_EQ(TRUE, rv)
|
| - << "Should be able to duplicate the handle into a readable one.";
|
| - if (rv)
|
| - base::win::ScopedHandle writable_handle(temp_handle);
|
| #else
|
| #error Unexpected platform; write a test that tries to make 'handle' writable.
|
| -#endif // defined(OS_POSIX) || defined(OS_WIN)
|
| +#endif // defined(OS_POSIX)
|
| }
|
|
|
| TEST(SharedMemoryTest, ShareToSelf) {
|
|
|