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

Side by Side Diff: sandbox/mac/xpc_message_server_unittest.cc

Issue 2733323002: Changing multiprocess test SpawnChild to return a struct. (Closed)
Patch Set: Synced 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
« no previous file with comments | « sandbox/mac/sandbox_mac_compiler_v2_unittest.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "sandbox/mac/xpc_message_server.h" 5 #include "sandbox/mac/xpc_message_server.h"
6 6
7 #include <Block.h> 7 #include <Block.h>
8 #include <mach/mach.h> 8 #include <mach/mach.h>
9 #include <servers/bootstrap.h> 9 #include <servers/bootstrap.h>
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 child_pid = xpc_dictionary_get_int64(request.xpc, "child_pid"); 140 child_pid = xpc_dictionary_get_int64(request.xpc, "child_pid");
141 })); 141 }));
142 142
143 #pragma GCC diagnostic push 143 #pragma GCC diagnostic push
144 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 144 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
145 kern_return_t kr = bootstrap_register(bootstrap_port, kGetSenderPID, 145 kern_return_t kr = bootstrap_register(bootstrap_port, kGetSenderPID,
146 server->GetServerPort()); 146 server->GetServerPort());
147 #pragma GCC diagnostic pop 147 #pragma GCC diagnostic pop
148 ASSERT_EQ(KERN_SUCCESS, kr); 148 ASSERT_EQ(KERN_SUCCESS, kr);
149 149
150 base::Process child = base::SpawnMultiProcessTestChild( 150 base::SpawnChildResult spawn_child = base::SpawnMultiProcessTestChild(
151 "GetSenderPID", 151 "GetSenderPID", base::GetMultiProcessTestChildBaseCommandLine(),
152 base::GetMultiProcessTestChildBaseCommandLine(),
153 base::LaunchOptions()); 152 base::LaunchOptions());
154 ASSERT_TRUE(child.IsValid()); 153 ASSERT_TRUE(spawn_child.process.IsValid());
155 154
156 int exit_code = -1; 155 int exit_code = -1;
157 ASSERT_TRUE(child.WaitForExit(&exit_code)); 156 ASSERT_TRUE(spawn_child.process.WaitForExit(&exit_code));
158 EXPECT_EQ(0, exit_code); 157 EXPECT_EQ(0, exit_code);
159 158
160 EXPECT_EQ(child.Pid(), sender_pid); 159 EXPECT_EQ(spawn_child.process.Pid(), sender_pid);
161 EXPECT_EQ(child.Pid(), child_pid); 160 EXPECT_EQ(spawn_child.process.Pid(), child_pid);
162 EXPECT_EQ(sender_pid, child_pid); 161 EXPECT_EQ(sender_pid, child_pid);
163 } 162 }
164 163
165 MULTIPROCESS_TEST_MAIN(GetSenderPID) { 164 MULTIPROCESS_TEST_MAIN(GetSenderPID) {
166 mach_port_t port = MACH_PORT_NULL; 165 mach_port_t port = MACH_PORT_NULL;
167 CHECK_EQ(KERN_SUCCESS, bootstrap_look_up(bootstrap_port, kGetSenderPID, 166 CHECK_EQ(KERN_SUCCESS, bootstrap_look_up(bootstrap_port, kGetSenderPID,
168 &port)); 167 &port));
169 base::mac::ScopedMachSendRight scoped_port(port); 168 base::mac::ScopedMachSendRight scoped_port(port);
170 169
171 xpc_pipe_t pipe = xpc_pipe_create_from_port(port, 0); 170 xpc_pipe_t pipe = xpc_pipe_create_from_port(port, 0);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 ASSERT_EQ(0, xpc_pipe_routine(first.pipe(), request, &reply)); 203 ASSERT_EQ(0, xpc_pipe_routine(first.pipe(), request, &reply));
205 204
206 EXPECT_EQ(1, xpc_dictionary_get_int64(reply, "seen_by_first")); 205 EXPECT_EQ(1, xpc_dictionary_get_int64(reply, "seen_by_first"));
207 EXPECT_EQ(2, xpc_dictionary_get_int64(reply, "seen_by_second")); 206 EXPECT_EQ(2, xpc_dictionary_get_int64(reply, "seen_by_second"));
208 207
209 xpc_release(request); 208 xpc_release(request);
210 xpc_release(reply); 209 xpc_release(reply);
211 } 210 }
212 211
213 } // namespace sandbox 212 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/mac/sandbox_mac_compiler_v2_unittest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698