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

Side by Side Diff: mojo/edk/system/message_pipe_unittest.cc

Issue 1686243002: [mojo-edk] Re-enable ping pong multiprocess tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 | « mojo/edk/system/channel_posix.cc ('k') | mojo/edk/test/BUILD.gn » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "mojo/edk/system/test_utils.h" 8 #include "mojo/edk/system/test_utils.h"
9 #include "mojo/edk/test/mojo_test_base.h" 9 #include "mojo/edk/test/mojo_test_base.h"
10 #include "mojo/public/c/system/core.h" 10 #include "mojo/public/c/system/core.h"
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 hss = MojoHandleSignalsState(); 402 hss = MojoHandleSignalsState();
403 ASSERT_EQ(MOJO_RESULT_FAILED_PRECONDITION, 403 ASSERT_EQ(MOJO_RESULT_FAILED_PRECONDITION,
404 MojoWait(pipe1_, MOJO_HANDLE_SIGNAL_READABLE, 404 MojoWait(pipe1_, MOJO_HANDLE_SIGNAL_READABLE,
405 MOJO_DEADLINE_INDEFINITE, &hss)); 405 MOJO_DEADLINE_INDEFINITE, &hss));
406 ASSERT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfied_signals); 406 ASSERT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfied_signals);
407 ASSERT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfiable_signals); 407 ASSERT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfiable_signals);
408 } 408 }
409 409
410 #if !defined(OS_IOS) 410 #if !defined(OS_IOS)
411 411
412 const size_t kPingPongIterations = 50000; 412 const size_t kPingPongHandlesPerIteration = 50;
413 const size_t kPingPongIterations = 500;
413 414
414 DEFINE_TEST_CLIENT_TEST_WITH_PIPE(DataPipeHandlePingPong, MessagePipeTest, h) { 415 DEFINE_TEST_CLIENT_TEST_WITH_PIPE(HandlePingPong, MessagePipeTest, h) {
415 // Wait for the consumer to become readable. 416 // Waits for a handle to become readable and writes it back to the sender.
416 for (size_t i = 0; i < kPingPongIterations; i++) { 417 for (size_t i = 0; i < kPingPongIterations; i++) {
417 MojoHandle handle; 418 MojoHandle handles[kPingPongHandlesPerIteration];
418 ReadMessageWithHandles(h, &handle, 1); 419 ReadMessageWithHandles(h, handles, kPingPongHandlesPerIteration);
419 WriteMessageWithHandles(h, "", &handle, 1); 420 WriteMessageWithHandles(h, "", handles, kPingPongHandlesPerIteration);
420 } 421 }
422
423 EXPECT_EQ(MOJO_RESULT_OK, MojoWait(h, MOJO_HANDLE_SIGNAL_READABLE,
424 MOJO_DEADLINE_INDEFINITE, nullptr));
425 char msg[4];
426 uint32_t num_bytes = 4;
427 EXPECT_EQ(MOJO_RESULT_OK, ReadMessage(h, msg, &num_bytes));
421 } 428 }
422 429
423 // Test that sending a data pipe handle across processes doesn't leak resources. 430 #if defined(OS_ANDROID)
424 // Currently times out on multiple platforms. crbug.com/585784 431 // Android multi-process tests are not executing the new process. This is flaky.
425 TEST_F(MessagePipeTest, DISABLED_DataPipeConsumerHandlePingPong) { 432 #define MAYBE_DataPipeConsumerHandlePingPong \
426 MojoHandle p, c; 433 DISABLED_DataPipeConsumerHandlePingPong
427 EXPECT_EQ(MOJO_RESULT_OK, MojoCreateDataPipe(nullptr, &p, &c)); 434 #else
428 MojoClose(p); 435 #define MAYBE_DataPipeConsumerHandlePingPong DataPipeConsumerHandlePingPong
436 #endif
437 TEST_F(MessagePipeTest, MAYBE_DataPipeConsumerHandlePingPong) {
438 MojoHandle p, c[kPingPongHandlesPerIteration];
439 for (size_t i = 0; i < kPingPongHandlesPerIteration; ++i) {
440 EXPECT_EQ(MOJO_RESULT_OK, MojoCreateDataPipe(nullptr, &p, &c[i]));
441 MojoClose(p);
442 }
429 443
430 RUN_CHILD_ON_PIPE(DataPipeHandlePingPong, h) 444 RUN_CHILD_ON_PIPE(HandlePingPong, h)
431 for (size_t i = 0; i < kPingPongIterations; i++) { 445 for (size_t i = 0; i < kPingPongIterations; i++) {
432 WriteMessageWithHandles(h, "", &c, 1); 446 WriteMessageWithHandles(h, "", c, kPingPongHandlesPerIteration);
433 ReadMessageWithHandles(h, &c, 1); 447 ReadMessageWithHandles(h, c, kPingPongHandlesPerIteration);
434 } 448 }
449 WriteMessage(h, "quit", 4);
435 END_CHILD() 450 END_CHILD()
436 MojoClose(c); 451 for (size_t i = 0; i < kPingPongHandlesPerIteration; ++i)
452 MojoClose(c[i]);
437 } 453 }
438 454
439 // Currently times out on multiple platforms. crbug.com/585784 455 #if defined(OS_ANDROID)
440 TEST_F(MessagePipeTest, DISABLED_DataPipeProducerHandlePingPong) { 456 // Android multi-process tests are not executing the new process. This is flaky.
441 MojoHandle p, c; 457 #define MAYBE_DataPipeProducerHandlePingPong \
442 EXPECT_EQ(MOJO_RESULT_OK, MojoCreateDataPipe(nullptr, &p, &c)); 458 DISABLED_DataPipeProducerHandlePingPong
443 MojoClose(c); 459 #else
460 #define MAYBE_DataPipeProducerHandlePingPong DataPipeProducerHandlePingPong
461 #endif
462 TEST_F(MessagePipeTest, MAYBE_DataPipeProducerHandlePingPong) {
463 MojoHandle p[kPingPongHandlesPerIteration], c;
464 for (size_t i = 0; i < kPingPongHandlesPerIteration; ++i) {
465 EXPECT_EQ(MOJO_RESULT_OK, MojoCreateDataPipe(nullptr, &p[i], &c));
466 MojoClose(c);
467 }
444 468
445 RUN_CHILD_ON_PIPE(DataPipeHandlePingPong, h) 469 RUN_CHILD_ON_PIPE(HandlePingPong, h)
446 for (size_t i = 0; i < kPingPongIterations; i++) { 470 for (size_t i = 0; i < kPingPongIterations; i++) {
447 WriteMessageWithHandles(h, "", &p, 1); 471 WriteMessageWithHandles(h, "", p, kPingPongHandlesPerIteration);
448 ReadMessageWithHandles(h, &p, 1); 472 ReadMessageWithHandles(h, p, kPingPongHandlesPerIteration);
449 } 473 }
474 WriteMessage(h, "quit", 4);
450 END_CHILD() 475 END_CHILD()
451 MojoClose(p); 476 for (size_t i = 0; i < kPingPongHandlesPerIteration; ++i)
477 MojoClose(p[i]);
452 } 478 }
453 479
454 TEST_F(MessagePipeTest, DISABLED_SharedBufferHandlePingPong) { 480 #if defined(OS_ANDROID)
455 MojoHandle buffer; 481 // Android multi-process tests are not executing the new process. This is flaky.
456 EXPECT_EQ(MOJO_RESULT_OK, MojoCreateSharedBuffer(nullptr, 1, &buffer)); 482 #define MAYBE_SharedBufferHandlePingPong DISABLED_SharedBufferHandlePingPong
483 #else
484 #define MAYBE_SharedBufferHandlePingPong SharedBufferHandlePingPong
485 #endif
486 TEST_F(MessagePipeTest, MAYBE_SharedBufferHandlePingPong) {
487 MojoHandle buffers[kPingPongHandlesPerIteration];
488 for (size_t i = 0; i <kPingPongHandlesPerIteration; ++i)
489 EXPECT_EQ(MOJO_RESULT_OK, MojoCreateSharedBuffer(nullptr, 1, &buffers[i]));
457 490
458 RUN_CHILD_ON_PIPE(DataPipeHandlePingPong, h) 491 RUN_CHILD_ON_PIPE(HandlePingPong, h)
459 for (size_t i = 0; i < kPingPongIterations; i++) { 492 for (size_t i = 0; i < kPingPongIterations; i++) {
460 WriteMessageWithHandles(h, "", &buffer, 1); 493 WriteMessageWithHandles(h, "", buffers, kPingPongHandlesPerIteration);
461 ReadMessageWithHandles(h, &buffer, 1); 494 ReadMessageWithHandles(h, buffers, kPingPongHandlesPerIteration);
462 } 495 }
496 WriteMessage(h, "quit", 4);
463 END_CHILD() 497 END_CHILD()
464 MojoClose(buffer); 498 for (size_t i = 0; i < kPingPongHandlesPerIteration; ++i)
499 MojoClose(buffers[i]);
465 } 500 }
466 501
467 #endif // !defined(OS_IOS) 502 #endif // !defined(OS_IOS)
468 503
469 } // namespace 504 } // namespace
470 } // namespace edk 505 } // namespace edk
471 } // namespace mojo 506 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/channel_posix.cc ('k') | mojo/edk/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698