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

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

Issue 92173002: Merge 237541 "Revert of https://codereview.chromium.org/71013004/" (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1721/src/
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « base/base.gyp ('k') | base/process/launch.h » ('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/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/memory/shared_memory.h" 7 #include "base/memory/shared_memory.h"
8 #include "base/process/kill.h" 8 #include "base/process/kill.h"
9 #include "base/rand_util.h" 9 #include "base/rand_util.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 EXPECT_EQ(MAP_FAILED, writable) 418 EXPECT_EQ(MAP_FAILED, writable)
419 << "It shouldn't be possible to re-mmap the descriptor writable."; 419 << "It shouldn't be possible to re-mmap the descriptor writable.";
420 EXPECT_EQ(EACCES, mmap_errno) << strerror(mmap_errno); 420 EXPECT_EQ(EACCES, mmap_errno) << strerror(mmap_errno);
421 if (writable != MAP_FAILED) 421 if (writable != MAP_FAILED)
422 EXPECT_EQ(0, munmap(writable, readonly_shmem.mapped_size())); 422 EXPECT_EQ(0, munmap(writable, readonly_shmem.mapped_size()));
423 423
424 #elif defined(OS_WIN) 424 #elif defined(OS_WIN)
425 EXPECT_EQ(NULL, MapViewOfFile(handle, FILE_MAP_WRITE, 0, 0, 0)) 425 EXPECT_EQ(NULL, MapViewOfFile(handle, FILE_MAP_WRITE, 0, 0, 0))
426 << "Shouldn't be able to map memory writable."; 426 << "Shouldn't be able to map memory writable.";
427 427
428 HANDLE temp_handle; 428 base::win::ScopedHandle writable_handle;
429 BOOL rv = ::DuplicateHandle(GetCurrentProcess(), 429 EXPECT_EQ(0,
430 ::DuplicateHandle(GetCurrentProcess(),
430 handle, 431 handle,
431 GetCurrentProcess, 432 GetCurrentProcess,
432 &temp_handle, 433 writable_handle.Receive(),
433 FILE_MAP_ALL_ACCESS, 434 FILE_MAP_ALL_ACCESS,
434 false, 435 false,
435 0); 436 0))
436 EXPECT_EQ(FALSE, rv)
437 << "Shouldn't be able to duplicate the handle into a writable one."; 437 << "Shouldn't be able to duplicate the handle into a writable one.";
438 if (rv)
439 base::win::ScopedHandle writable_handle(temp_handle);
440 #else 438 #else
441 #error Unexpected platform; write a test that tries to make 'handle' writable. 439 #error Unexpected platform; write a test that tries to make 'handle' writable.
442 #endif // defined(OS_POSIX) || defined(OS_WIN) 440 #endif // defined(OS_POSIX) || defined(OS_WIN)
443 } 441 }
444 442
445 TEST(SharedMemoryTest, ShareToSelf) { 443 TEST(SharedMemoryTest, ShareToSelf) {
446 StringPiece contents = "Hello World"; 444 StringPiece contents = "Hello World";
447 445
448 SharedMemory shmem; 446 SharedMemory shmem;
449 ASSERT_TRUE(shmem.CreateAndMapAnonymous(contents.size())); 447 ASSERT_TRUE(shmem.CreateAndMapAnonymous(contents.size()));
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 SharedMemoryProcessTest::CleanUp(); 657 SharedMemoryProcessTest::CleanUp();
660 } 658 }
661 659
662 MULTIPROCESS_TEST_MAIN(SharedMemoryTestMain) { 660 MULTIPROCESS_TEST_MAIN(SharedMemoryTestMain) {
663 return SharedMemoryProcessTest::TaskTestMain(); 661 return SharedMemoryProcessTest::TaskTestMain();
664 } 662 }
665 663
666 #endif // !OS_IOS 664 #endif // !OS_IOS
667 665
668 } // namespace base 666 } // namespace base
OLDNEW
« no previous file with comments | « base/base.gyp ('k') | base/process/launch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698