OLD | NEW |
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, |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 struct ReceiveLargeRequestMessage : public LargeRequestMessage { | 209 struct ReceiveLargeRequestMessage : public LargeRequestMessage { |
210 mach_msg_trailer_t trailer; | 210 mach_msg_trailer_t trailer; |
211 }; | 211 }; |
212 | 212 |
213 const ReceiveRequestMessage* request = | 213 const ReceiveRequestMessage* request = |
214 reinterpret_cast<const ReceiveRequestMessage*>(in); | 214 reinterpret_cast<const ReceiveRequestMessage*>(in); |
215 const mach_msg_bits_t expect_msgh_bits = | 215 const mach_msg_bits_t expect_msgh_bits = |
216 MACH_MSGH_BITS(MACH_MSG_TYPE_MOVE_SEND, MACH_MSG_TYPE_MOVE_SEND) | | 216 MACH_MSGH_BITS(MACH_MSG_TYPE_MOVE_SEND, MACH_MSG_TYPE_MOVE_SEND) | |
217 (options_.client_send_complex ? MACH_MSGH_BITS_COMPLEX : 0); | 217 (options_.client_send_complex ? MACH_MSGH_BITS_COMPLEX : 0); |
218 EXPECT_EQ(expect_msgh_bits, request->header.msgh_bits); | 218 EXPECT_EQ(expect_msgh_bits, request->header.msgh_bits); |
219 EXPECT_EQ(options_.client_send_large ? sizeof(LargeRequestMessage) : | 219 EXPECT_EQ(options_.client_send_large ? sizeof(LargeRequestMessage) |
220 sizeof(RequestMessage), | 220 : sizeof(RequestMessage), |
221 request->header.msgh_size); | 221 request->header.msgh_size); |
222 if (options_.client_reply_port_type == Options::kReplyPortNormal) { | 222 if (options_.client_reply_port_type == Options::kReplyPortNormal) { |
223 EXPECT_EQ(RemotePort(), request->header.msgh_remote_port); | 223 EXPECT_EQ(RemotePort(), request->header.msgh_remote_port); |
224 } | 224 } |
225 EXPECT_EQ(LocalPort(), request->header.msgh_local_port); | 225 EXPECT_EQ(LocalPort(), request->header.msgh_local_port); |
226 EXPECT_EQ(kRequestMessageID, request->header.msgh_id); | 226 EXPECT_EQ(kRequestMessageID, request->header.msgh_id); |
227 if (options_.client_send_complex) { | 227 if (options_.client_send_complex) { |
228 EXPECT_EQ(1u, request->body.msgh_descriptor_count); | 228 EXPECT_EQ(1u, request->body.msgh_descriptor_count); |
229 EXPECT_NE(kMachPortNull, request->port_descriptor.name); | 229 EXPECT_NE(kMachPortNull, request->port_descriptor.name); |
230 parent_complex_message_port_ = request->port_descriptor.name; | 230 parent_complex_message_port_ = request->port_descriptor.name; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 reply->Head.msgh_id = kReplyMessageID; | 270 reply->Head.msgh_id = kReplyMessageID; |
271 reply->NDR = NDR_record; | 271 reply->NDR = NDR_record; |
272 reply->RetCode = options_.server_mig_retcode; | 272 reply->RetCode = options_.server_mig_retcode; |
273 reply->number = replies_++; | 273 reply->number = replies_++; |
274 | 274 |
275 return true; | 275 return true; |
276 } | 276 } |
277 | 277 |
278 std::set<mach_msg_id_t> MachMessageServerRequestIDs() override { | 278 std::set<mach_msg_id_t> MachMessageServerRequestIDs() override { |
279 const mach_msg_id_t request_ids[] = {kRequestMessageID}; | 279 const mach_msg_id_t request_ids[] = {kRequestMessageID}; |
280 return std::set<mach_msg_id_t>( | 280 return std::set<mach_msg_id_t>(&request_ids[0], |
281 &request_ids[0], &request_ids[arraysize(request_ids)]); | 281 &request_ids[arraysize(request_ids)]); |
282 } | 282 } |
283 | 283 |
284 mach_msg_size_t MachMessageServerRequestSize() override { | 284 mach_msg_size_t MachMessageServerRequestSize() override { |
285 return sizeof(RequestMessage); | 285 return sizeof(RequestMessage); |
286 } | 286 } |
287 | 287 |
288 mach_msg_size_t MachMessageServerReplySize() override { | 288 mach_msg_size_t MachMessageServerReplySize() override { |
289 return sizeof(ReplyMessage); | 289 return sizeof(ReplyMessage); |
290 } | 290 } |
291 | 291 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 | 361 |
362 if (!options_.expect_server_destroyed_complex) { | 362 if (!options_.expect_server_destroyed_complex) { |
363 // MachMessageServer should not have destroyed the resources sent in the | 363 // MachMessageServer should not have destroyed the resources sent in the |
364 // complex request message. | 364 // complex request message. |
365 kr = mach_port_type( | 365 kr = mach_port_type( |
366 mach_task_self(), parent_complex_message_port_, &type); | 366 mach_task_self(), parent_complex_message_port_, &type); |
367 EXPECT_EQ(KERN_SUCCESS, kr) << MachErrorMessage(kr, "mach_port_type"); | 367 EXPECT_EQ(KERN_SUCCESS, kr) << MachErrorMessage(kr, "mach_port_type"); |
368 EXPECT_EQ(MACH_PORT_TYPE_SEND, type); | 368 EXPECT_EQ(MACH_PORT_TYPE_SEND, type); |
369 | 369 |
370 // Destroy the resources here. | 370 // Destroy the resources here. |
371 kr = mach_port_deallocate( | 371 kr = mach_port_deallocate(mach_task_self(), |
372 mach_task_self(), parent_complex_message_port_); | 372 parent_complex_message_port_); |
373 EXPECT_EQ(KERN_SUCCESS, kr) | 373 EXPECT_EQ(KERN_SUCCESS, kr) |
374 << MachErrorMessage(kr, "mach_port_deallocate"); | 374 << MachErrorMessage(kr, "mach_port_deallocate"); |
375 } | 375 } |
376 | 376 |
377 // The kernel won’t have reused the same name for another Mach port in | 377 // The kernel won’t have reused the same name for another Mach port in |
378 // this task so soon. It’s possible that something else in this task could | 378 // this task so soon. It’s possible that something else in this task could |
379 // have reused the name, but it’s unlikely for that to have happened in | 379 // have reused the name, but it’s unlikely for that to have happened in |
380 // this test environment. | 380 // this test environment. |
381 kr = mach_port_type( | 381 kr = |
382 mach_task_self(), parent_complex_message_port_, &type); | 382 mach_port_type(mach_task_self(), parent_complex_message_port_, &type); |
383 EXPECT_EQ(KERN_INVALID_NAME, kr) | 383 EXPECT_EQ(KERN_INVALID_NAME, kr) |
384 << MachErrorMessage(kr, "mach_port_type"); | 384 << MachErrorMessage(kr, "mach_port_type"); |
385 } | 385 } |
386 | 386 |
387 if (options_.child_wait_for_parent_pipe_late) { | 387 if (options_.child_wait_for_parent_pipe_late) { |
388 // Let the child know it’s safe to exit. | 388 // Let the child know it’s safe to exit. |
389 char c = '\0'; | 389 char c = '\0'; |
390 CheckedWriteFile(WritePipeHandle(), &c, 1); | 390 CheckedWriteFile(WritePipeHandle(), &c, 1); |
391 } | 391 } |
392 } | 392 } |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 options.expect_server_transaction_count = 0; | 845 options.expect_server_transaction_count = 0; |
846 options.client_send_large = true; | 846 options.client_send_large = true; |
847 options.client_expect_reply = false; | 847 options.client_expect_reply = false; |
848 TestMachMessageServer test_mach_message_server(options); | 848 TestMachMessageServer test_mach_message_server(options); |
849 test_mach_message_server.Test(); | 849 test_mach_message_server.Test(); |
850 } | 850 } |
851 | 851 |
852 } // namespace | 852 } // namespace |
853 } // namespace test | 853 } // namespace test |
854 } // namespace crashpad | 854 } // namespace crashpad |
OLD | NEW |