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

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

Issue 2733323002: Changing multiprocess test SpawnChild to return a struct. (Closed)
Patch Set: Fixed bots. Created 3 years, 9 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
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/memory/shared_memory.h" 5 #include "base/memory/shared_memory.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 ASSERT_TRUE(rv); 677 ASSERT_TRUE(rv);
678 rv = memory.Map(s_data_size_); 678 rv = memory.Map(s_data_size_);
679 ASSERT_TRUE(rv); 679 ASSERT_TRUE(rv);
680 int* ptr = static_cast<int*>(memory.memory()); 680 int* ptr = static_cast<int*>(memory.memory());
681 *ptr = 0; 681 *ptr = 0;
682 682
683 // Start |kNumTasks| processes, each of which atomically increments the first 683 // Start |kNumTasks| processes, each of which atomically increments the first
684 // word by 1. 684 // word by 1.
685 Process processes[kNumTasks]; 685 Process processes[kNumTasks];
686 for (int index = 0; index < kNumTasks; ++index) { 686 for (int index = 0; index < kNumTasks; ++index) {
687 processes[index] = SpawnChild("SharedMemoryTestMain"); 687 SpawnChildResult spawn_result = SpawnChild("SharedMemoryTestMain");
688 processes[index] = std::move(spawn_result.process);
688 ASSERT_TRUE(processes[index].IsValid()); 689 ASSERT_TRUE(processes[index].IsValid());
689 } 690 }
690 691
691 // Check that each process exited correctly. 692 // Check that each process exited correctly.
692 int exit_code = 0; 693 int exit_code = 0;
693 for (int index = 0; index < kNumTasks; ++index) { 694 for (int index = 0; index < kNumTasks; ++index) {
694 EXPECT_TRUE(processes[index].WaitForExit(&exit_code)); 695 EXPECT_TRUE(processes[index].WaitForExit(&exit_code));
695 EXPECT_EQ(0, exit_code); 696 EXPECT_EQ(0, exit_code);
696 } 697 }
697 698
698 // Check that the shared memory region reflects |kNumTasks| increments. 699 // Check that the shared memory region reflects |kNumTasks| increments.
699 ASSERT_EQ(kNumTasks, *ptr); 700 ASSERT_EQ(kNumTasks, *ptr);
700 701
701 memory.Close(); 702 memory.Close();
702 SharedMemoryProcessTest::CleanUp(); 703 SharedMemoryProcessTest::CleanUp();
703 } 704 }
704 705
705 MULTIPROCESS_TEST_MAIN(SharedMemoryTestMain) { 706 MULTIPROCESS_TEST_MAIN(SharedMemoryTestMain) {
706 return SharedMemoryProcessTest::TaskTestMain(); 707 return SharedMemoryProcessTest::TaskTestMain();
707 } 708 }
708 #endif // !defined(OS_IOS) && !defined(OS_ANDROID) && !defined(OS_MACOSX) 709 #endif // !defined(OS_IOS) && !defined(OS_ANDROID) && !defined(OS_MACOSX)
709 710
710 } // namespace base 711 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698