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

Side by Side Diff: util/mach/mach_message_server_test.cc

Issue 880763002: Reorganize Multiprocess and implement for Windows (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: fixes 2 Created 5 years, 10 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 | « util/mach/exception_ports_test.cc ('k') | util/net/http_transport_test.cc » ('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 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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 MACH_PORT_LIMITS_INFO, 328 MACH_PORT_LIMITS_INFO,
329 reinterpret_cast<mach_port_info_t>(&limits), 329 reinterpret_cast<mach_port_info_t>(&limits),
330 MACH_PORT_LIMITS_INFO_COUNT); 330 MACH_PORT_LIMITS_INFO_COUNT);
331 ASSERT_EQ(KERN_SUCCESS, kr) 331 ASSERT_EQ(KERN_SUCCESS, kr)
332 << MachErrorMessage(kr, "mach_port_set_attributes"); 332 << MachErrorMessage(kr, "mach_port_set_attributes");
333 } 333 }
334 334
335 if (options_.child_wait_for_parent_pipe_early) { 335 if (options_.child_wait_for_parent_pipe_early) {
336 // Tell the child to begin sending messages. 336 // Tell the child to begin sending messages.
337 char c = '\0'; 337 char c = '\0';
338 CheckedWriteFile(WritePipeFD(), &c, 1); 338 CheckedWriteFile(WritePipeHandle(), &c, 1);
339 } 339 }
340 340
341 if (options_.parent_wait_for_child_pipe) { 341 if (options_.parent_wait_for_child_pipe) {
342 // Wait until the child is done sending what it’s going to send. 342 // Wait until the child is done sending what it’s going to send.
343 char c; 343 char c;
344 CheckedReadFile(ReadPipeFD(), &c, 1); 344 CheckedReadFile(ReadPipeHandle(), &c, 1);
345 EXPECT_EQ('\0', c); 345 EXPECT_EQ('\0', c);
346 } 346 }
347 347
348 ASSERT_EQ(options_.expect_server_result, 348 ASSERT_EQ(options_.expect_server_result,
349 (kr = MachMessageServer::Run(this, 349 (kr = MachMessageServer::Run(this,
350 local_port, 350 local_port,
351 options_.server_options, 351 options_.server_options,
352 options_.server_persistent, 352 options_.server_persistent,
353 options_.server_receive_large, 353 options_.server_receive_large,
354 options_.server_timeout_ms))) 354 options_.server_timeout_ms)))
(...skipping 24 matching lines...) Expand all
379 // this test environment. 379 // this test environment.
380 kr = mach_port_type( 380 kr = mach_port_type(
381 mach_task_self(), parent_complex_message_port_, &type); 381 mach_task_self(), parent_complex_message_port_, &type);
382 EXPECT_EQ(KERN_INVALID_NAME, kr) 382 EXPECT_EQ(KERN_INVALID_NAME, kr)
383 << MachErrorMessage(kr, "mach_port_type"); 383 << MachErrorMessage(kr, "mach_port_type");
384 } 384 }
385 385
386 if (options_.child_wait_for_parent_pipe_late) { 386 if (options_.child_wait_for_parent_pipe_late) {
387 // Let the child know it’s safe to exit. 387 // Let the child know it’s safe to exit.
388 char c = '\0'; 388 char c = '\0';
389 CheckedWriteFile(WritePipeFD(), &c, 1); 389 CheckedWriteFile(WritePipeHandle(), &c, 1);
390 } 390 }
391 } 391 }
392 392
393 void MachMultiprocessChild() override { 393 void MachMultiprocessChild() override {
394 if (options_.child_wait_for_parent_pipe_early) { 394 if (options_.child_wait_for_parent_pipe_early) {
395 // Wait until the parent is done setting things up on its end. 395 // Wait until the parent is done setting things up on its end.
396 char c; 396 char c;
397 CheckedReadFile(ReadPipeFD(), &c, 1); 397 CheckedReadFile(ReadPipeHandle(), &c, 1);
398 EXPECT_EQ('\0', c); 398 EXPECT_EQ('\0', c);
399 } 399 }
400 400
401 for (size_t index = 0; 401 for (size_t index = 0;
402 index < options_.client_send_request_count; 402 index < options_.client_send_request_count;
403 ++index) { 403 ++index) {
404 if (options_.child_send_all_requests_before_receiving_any_replies) { 404 if (options_.child_send_all_requests_before_receiving_any_replies) {
405 // For this test, all of the messages need to go into the queue before 405 // For this test, all of the messages need to go into the queue before
406 // the parent is allowed to start processing them. Don’t attempt to 406 // the parent is allowed to start processing them. Don’t attempt to
407 // process replies before all of the requests are sent, because the 407 // process replies before all of the requests are sent, because the
(...skipping 13 matching lines...) Expand all
421 421
422 for (size_t index = 0; 422 for (size_t index = 0;
423 index < options_.client_send_request_count; 423 index < options_.client_send_request_count;
424 ++index) { 424 ++index) {
425 ASSERT_NO_FATAL_FAILURE(ChildWaitForReply()); 425 ASSERT_NO_FATAL_FAILURE(ChildWaitForReply());
426 } 426 }
427 } 427 }
428 428
429 if (options_.child_wait_for_parent_pipe_late) { 429 if (options_.child_wait_for_parent_pipe_late) {
430 char c; 430 char c;
431 CheckedReadFile(ReadPipeFD(), &c, 1); 431 CheckedReadFile(ReadPipeHandle(), &c, 1);
432 ASSERT_EQ('\0', c); 432 ASSERT_EQ('\0', c);
433 } 433 }
434 } 434 }
435 435
436 // In the child process, sends a request message to the server. 436 // In the child process, sends a request message to the server.
437 void ChildSendRequest() { 437 void ChildSendRequest() {
438 // local_receive_port_owner will the receive right that is created in this 438 // local_receive_port_owner will the receive right that is created in this
439 // scope and intended to be destroyed when leaving this scope, after it has 439 // scope and intended to be destroyed when leaving this scope, after it has
440 // been carried in a Mach message. 440 // been carried in a Mach message.
441 base::mac::ScopedMachReceiveRight local_receive_port_owner; 441 base::mac::ScopedMachReceiveRight local_receive_port_owner;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 543
544 ++replies_; 544 ++replies_;
545 } 545 }
546 546
547 // For test types where the child needs to notify the server in the parent 547 // For test types where the child needs to notify the server in the parent
548 // that the child is ready, this method will send a byte via the POSIX pipe. 548 // that the child is ready, this method will send a byte via the POSIX pipe.
549 // The parent will be waiting in a read() on this pipe, and will proceed to 549 // The parent will be waiting in a read() on this pipe, and will proceed to
550 // running MachMessageServer() once it’s received. 550 // running MachMessageServer() once it’s received.
551 void ChildNotifyParentViaPipe() { 551 void ChildNotifyParentViaPipe() {
552 char c = '\0'; 552 char c = '\0';
553 CheckedWriteFile(WritePipeFD(), &c, 1); 553 CheckedWriteFile(WritePipeHandle(), &c, 1);
554 } 554 }
555 555
556 // In the child process, sends a request message to the server and then 556 // In the child process, sends a request message to the server and then
557 // receives a reply message. 557 // receives a reply message.
558 void ChildSendRequestAndWaitForReply() { 558 void ChildSendRequestAndWaitForReply() {
559 ASSERT_NO_FATAL_FAILURE(ChildSendRequest()); 559 ASSERT_NO_FATAL_FAILURE(ChildSendRequest());
560 560
561 if (options_.parent_wait_for_child_pipe && 561 if (options_.parent_wait_for_child_pipe &&
562 !options_.child_send_all_requests_before_receiving_any_replies) { 562 !options_.child_send_all_requests_before_receiving_any_replies) {
563 // The parent is waiting to read a byte to indicate that the message has 563 // The parent is waiting to read a byte to indicate that the message has
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 options.expect_server_transaction_count = 0; 844 options.expect_server_transaction_count = 0;
845 options.client_send_large = true; 845 options.client_send_large = true;
846 options.client_expect_reply = false; 846 options.client_expect_reply = false;
847 TestMachMessageServer test_mach_message_server(options); 847 TestMachMessageServer test_mach_message_server(options);
848 test_mach_message_server.Test(); 848 test_mach_message_server.Test();
849 } 849 }
850 850
851 } // namespace 851 } // namespace
852 } // namespace test 852 } // namespace test
853 } // namespace crashpad 853 } // namespace crashpad
OLDNEW
« no previous file with comments | « util/mach/exception_ports_test.cc ('k') | util/net/http_transport_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698