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

Side by Side Diff: util/test/mac/mach_multiprocess.cc

Issue 545053003: Add exc_server_variants including UniversalMachExcServer and its test (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Address review feedback Created 6 years, 3 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 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #include "util/test/mac/mach_multiprocess.h" 15 #include "util/test/mac/mach_multiprocess.h"
16 16
17 #include <AvailabilityMacros.h> 17 #include <AvailabilityMacros.h>
18 #include <bsm/libbsm.h> 18 #include <bsm/libbsm.h>
19 #include <servers/bootstrap.h> 19 #include <servers/bootstrap.h>
20 20
21 #include <string> 21 #include <string>
22 22
23 #include "base/auto_reset.h" 23 #include "base/auto_reset.h"
24 #include "base/logging.h" 24 #include "base/logging.h"
25 #include "base/mac/scoped_mach_port.h" 25 #include "base/mac/scoped_mach_port.h"
26 #include "base/memory/scoped_ptr.h" 26 #include "base/memory/scoped_ptr.h"
27 #include "base/rand_util.h" 27 #include "base/rand_util.h"
28 #include "gtest/gtest.h" 28 #include "gtest/gtest.h"
29 #include "util/mach/bootstrap.h" 29 #include "util/mach/bootstrap.h"
30 #include "util/mach/mach_extensions.h"
30 #include "util/misc/scoped_forbid_return.h" 31 #include "util/misc/scoped_forbid_return.h"
31 #include "util/test/errors.h" 32 #include "util/test/errors.h"
32 #include "util/test/mac/mach_errors.h" 33 #include "util/test/mac/mach_errors.h"
33 34
34 namespace { 35 namespace {
35 36
36 // The “hello” message contains a send right to the child process’ task port. 37 // The “hello” message contains a send right to the child process’ task port.
37 struct SendHelloMessage : public mach_msg_base_t { 38 struct SendHelloMessage : public mach_msg_base_t {
38 mach_msg_port_descriptor_t port_descriptor; 39 mach_msg_port_descriptor_t port_descriptor;
39 }; 40 };
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 99
99 mach_port_t local_port; 100 mach_port_t local_port;
100 kern_return_t kr = 101 kern_return_t kr =
101 BootstrapCheckIn(bootstrap_port, info_->service_name, &local_port); 102 BootstrapCheckIn(bootstrap_port, info_->service_name, &local_port);
102 ASSERT_EQ(BOOTSTRAP_SUCCESS, kr) 103 ASSERT_EQ(BOOTSTRAP_SUCCESS, kr)
103 << BootstrapErrorMessage(kr, "bootstrap_check_in"); 104 << BootstrapErrorMessage(kr, "bootstrap_check_in");
104 info_->local_port.reset(local_port); 105 info_->local_port.reset(local_port);
105 } 106 }
106 107
107 mach_port_t MachMultiprocess::LocalPort() const { 108 mach_port_t MachMultiprocess::LocalPort() const {
108 EXPECT_NE(static_cast<mach_port_t>(MACH_PORT_NULL), info_->local_port); 109 EXPECT_NE(kMachPortNull, info_->local_port);
109 return info_->local_port; 110 return info_->local_port;
110 } 111 }
111 112
112 mach_port_t MachMultiprocess::RemotePort() const { 113 mach_port_t MachMultiprocess::RemotePort() const {
113 EXPECT_NE(static_cast<mach_port_t>(MACH_PORT_NULL), info_->remote_port); 114 EXPECT_NE(kMachPortNull, info_->remote_port);
114 return info_->remote_port; 115 return info_->remote_port;
115 } 116 }
116 117
117 mach_port_t MachMultiprocess::ChildTask() const { 118 mach_port_t MachMultiprocess::ChildTask() const {
118 EXPECT_NE(static_cast<mach_port_t>(MACH_PORT_NULL), info_->child_task); 119 EXPECT_NE(kMachPortNull, info_->child_task);
119 return info_->child_task; 120 return info_->child_task;
120 } 121 }
121 122
122 void MachMultiprocess::MultiprocessParent() { 123 void MachMultiprocess::MultiprocessParent() {
123 ReceiveHelloMessage message = {}; 124 ReceiveHelloMessage message = {};
124 125
125 kern_return_t kr = 126 kern_return_t kr =
126 mach_msg(&message.header, 127 mach_msg(&message.header,
127 MACH_RCV_MSG | MACH_RCV_TRAILER_TYPE(MACH_MSG_TRAILER_FORMAT_0) | 128 MACH_RCV_MSG | MACH_RCV_TRAILER_TYPE(MACH_MSG_TRAILER_FORMAT_0) |
128 MACH_RCV_TRAILER_ELEMENTS(MACH_RCV_TRAILER_AUDIT), 129 MACH_RCV_TRAILER_ELEMENTS(MACH_RCV_TRAILER_AUDIT),
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 if (Test::HasFailure()) { 264 if (Test::HasFailure()) {
264 // Trigger the ScopedForbidReturn destructor. 265 // Trigger the ScopedForbidReturn destructor.
265 return; 266 return;
266 } 267 }
267 268
268 forbid_return.Disarm(); 269 forbid_return.Disarm();
269 } 270 }
270 271
271 } // namespace test 272 } // namespace test
272 } // namespace crashpad 273 } // namespace crashpad
OLDNEW
« no previous file with comments | « util/mach/mach_message_server_test.cc ('k') | util/util.gyp » ('j') | util/util.gyp » ('J')

Powered by Google App Engine
This is Rietveld 408576698