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

Side by Side Diff: base/shared_memory_unittest.cc

Issue 6001010: Move platform_thread to base/threading and put in the base namespace. I left ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 11 months 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/shared_memory_posix.cc ('k') | base/singleton.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/mac/scoped_nsautorelease_pool.h" 6 #include "base/mac/scoped_nsautorelease_pool.h"
7 #include "base/platform_thread.h"
8 #include "base/shared_memory.h" 7 #include "base/shared_memory.h"
9 #include "base/scoped_ptr.h" 8 #include "base/scoped_ptr.h"
10 #include "base/test/multiprocess_test.h" 9 #include "base/test/multiprocess_test.h"
10 #include "base/threading/platform_thread.h"
11 #include "base/time.h" 11 #include "base/time.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "testing/multiprocess_func_list.h" 13 #include "testing/multiprocess_func_list.h"
14 14
15 static const int kNumThreads = 5; 15 static const int kNumThreads = 5;
16 static const int kNumTasks = 5; 16 static const int kNumTasks = 5;
17 17
18 namespace base { 18 namespace base {
19 19
20 namespace { 20 namespace {
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 } 320 }
321 } 321 }
322 322
323 for (int i = 0; i < count; i++) { 323 for (int i = 0; i < count; i++) {
324 memories[i].Close(); 324 memories[i].Close();
325 } 325 }
326 } 326 }
327 327
328 // On POSIX it is especially important we test shmem across processes, 328 // On POSIX it is especially important we test shmem across processes,
329 // not just across threads. But the test is enabled on all platforms. 329 // not just across threads. But the test is enabled on all platforms.
330 class SharedMemoryProcessTest : public base::MultiProcessTest { 330 class SharedMemoryProcessTest : public MultiProcessTest {
331 public: 331 public:
332 332
333 static void CleanUp() { 333 static void CleanUp() {
334 SharedMemory memory; 334 SharedMemory memory;
335 memory.Delete(s_test_name_); 335 memory.Delete(s_test_name_);
336 } 336 }
337 337
338 static int TaskTestMain() { 338 static int TaskTestMain() {
339 int errors = 0; 339 int errors = 0;
340 mac::ScopedNSAutoreleasePool pool; // noop if not OSX 340 mac::ScopedNSAutoreleasePool pool; // noop if not OSX
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 373
374 #if defined(OS_MACOSX) 374 #if defined(OS_MACOSX)
375 #define MAYBE_Tasks FLAKY_Tasks 375 #define MAYBE_Tasks FLAKY_Tasks
376 #else 376 #else
377 #define MAYBE_Tasks Tasks 377 #define MAYBE_Tasks Tasks
378 #endif 378 #endif
379 379
380 TEST_F(SharedMemoryProcessTest, MAYBE_Tasks) { 380 TEST_F(SharedMemoryProcessTest, MAYBE_Tasks) {
381 SharedMemoryProcessTest::CleanUp(); 381 SharedMemoryProcessTest::CleanUp();
382 382
383 base::ProcessHandle handles[kNumTasks]; 383 ProcessHandle handles[kNumTasks];
384 for (int index = 0; index < kNumTasks; ++index) { 384 for (int index = 0; index < kNumTasks; ++index) {
385 handles[index] = SpawnChild("SharedMemoryTestMain", false); 385 handles[index] = SpawnChild("SharedMemoryTestMain", false);
386 } 386 }
387 387
388 int exit_code = 0; 388 int exit_code = 0;
389 for (int index = 0; index < kNumTasks; ++index) { 389 for (int index = 0; index < kNumTasks; ++index) {
390 EXPECT_TRUE(base::WaitForExitCode(handles[index], &exit_code)); 390 EXPECT_TRUE(WaitForExitCode(handles[index], &exit_code));
391 EXPECT_TRUE(exit_code == 0); 391 EXPECT_TRUE(exit_code == 0);
392 } 392 }
393 393
394 SharedMemoryProcessTest::CleanUp(); 394 SharedMemoryProcessTest::CleanUp();
395 } 395 }
396 396
397 MULTIPROCESS_TEST_MAIN(SharedMemoryTestMain) { 397 MULTIPROCESS_TEST_MAIN(SharedMemoryTestMain) {
398 return SharedMemoryProcessTest::TaskTestMain(); 398 return SharedMemoryProcessTest::TaskTestMain();
399 } 399 }
400 400
401 } // namespace base 401 } // namespace base
OLDNEW
« no previous file with comments | « base/shared_memory_posix.cc ('k') | base/singleton.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698