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

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

Issue 924793003: Cleanup: Convert const char* kFoo to const char kFoo[]. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase again 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 | « no previous file | chrome/browser/content_settings/content_settings_browsertest.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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 65 }
66 // Reset back to 0 for the next test that uses the same name. 66 // Reset back to 0 for the next test that uses the same name.
67 *ptr = 0; 67 *ptr = 0;
68 68
69 memory.Close(); 69 memory.Close();
70 } 70 }
71 71
72 private: 72 private:
73 int16 id_; 73 int16 id_;
74 74
75 static const char* const s_test_name_; 75 static const char s_test_name_[];
76 76
77 DISALLOW_COPY_AND_ASSIGN(MultipleThreadMain); 77 DISALLOW_COPY_AND_ASSIGN(MultipleThreadMain);
78 }; 78 };
79 79
80 const char* const MultipleThreadMain::s_test_name_ = 80 const char MultipleThreadMain::s_test_name_[] =
81 "SharedMemoryOpenThreadTest"; 81 "SharedMemoryOpenThreadTest";
82 #endif // !defined(OS_MACOSX) 82 #endif // !defined(OS_MACOSX)
83 83
84 } // namespace 84 } // namespace
85 85
86 // Android/Mac doesn't support SharedMemory::Open/Delete/ 86 // Android/Mac doesn't support SharedMemory::Open/Delete/
87 // CreateNamedDeprecated(openExisting=true) 87 // CreateNamedDeprecated(openExisting=true)
88 #if !defined(OS_ANDROID) && !defined(OS_MACOSX) 88 #if !defined(OS_ANDROID) && !defined(OS_MACOSX)
89 TEST(SharedMemoryTest, OpenClose) { 89 TEST(SharedMemoryTest, OpenClose) {
90 const uint32 kDataSize = 1024; 90 const uint32 kDataSize = 1024;
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 if (rv != true) 596 if (rv != true)
597 errors++; 597 errors++;
598 int* ptr = static_cast<int*>(memory.memory()); 598 int* ptr = static_cast<int*>(memory.memory());
599 599
600 // This runs concurrently in multiple processes. Writes need to be atomic. 600 // This runs concurrently in multiple processes. Writes need to be atomic.
601 subtle::Barrier_AtomicIncrement(ptr, 1); 601 subtle::Barrier_AtomicIncrement(ptr, 1);
602 memory.Close(); 602 memory.Close();
603 return errors; 603 return errors;
604 } 604 }
605 605
606 static const char* const s_test_name_; 606 static const char s_test_name_[];
607 static const uint32 s_data_size_; 607 static const uint32 s_data_size_;
608 }; 608 };
609 609
610 const char* const SharedMemoryProcessTest::s_test_name_ = "MPMem"; 610 const char SharedMemoryProcessTest::s_test_name_[] = "MPMem";
611 const uint32 SharedMemoryProcessTest::s_data_size_ = 1024; 611 const uint32 SharedMemoryProcessTest::s_data_size_ = 1024;
612 612
613 TEST_F(SharedMemoryProcessTest, SharedMemoryAcrossProcesses) { 613 TEST_F(SharedMemoryProcessTest, SharedMemoryAcrossProcesses) {
614 const int kNumTasks = 5; 614 const int kNumTasks = 5;
615 615
616 SharedMemoryProcessTest::CleanUp(); 616 SharedMemoryProcessTest::CleanUp();
617 617
618 // Create a shared memory region. Set the first word to 0. 618 // Create a shared memory region. Set the first word to 0.
619 SharedMemory memory; 619 SharedMemory memory;
620 bool rv = memory.CreateNamedDeprecated(s_test_name_, true, s_data_size_); 620 bool rv = memory.CreateNamedDeprecated(s_test_name_, true, s_data_size_);
(...skipping 24 matching lines...) Expand all
645 memory.Close(); 645 memory.Close();
646 SharedMemoryProcessTest::CleanUp(); 646 SharedMemoryProcessTest::CleanUp();
647 } 647 }
648 648
649 MULTIPROCESS_TEST_MAIN(SharedMemoryTestMain) { 649 MULTIPROCESS_TEST_MAIN(SharedMemoryTestMain) {
650 return SharedMemoryProcessTest::TaskTestMain(); 650 return SharedMemoryProcessTest::TaskTestMain();
651 } 651 }
652 #endif // !defined(OS_IOS) && !defined(OS_ANDROID) && !defined(OS_MACOSX) 652 #endif // !defined(OS_IOS) && !defined(OS_ANDROID) && !defined(OS_MACOSX)
653 653
654 } // namespace base 654 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/content_settings/content_settings_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698