OLD | NEW |
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 #include <stdio.h> | 6 #include <stdio.h> |
7 #include <string.h> | 7 #include <string.h> |
8 | |
9 #include <string> | 8 #include <string> |
| 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
15 #include "base/files/scoped_file.h" | 15 #include "base/files/scoped_file.h" |
16 #include "base/files/scoped_temp_dir.h" | 16 #include "base/files/scoped_temp_dir.h" |
17 #include "base/location.h" | 17 #include "base/location.h" |
18 #include "base/logging.h" | 18 #include "base/logging.h" |
19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
(...skipping 17 matching lines...) Expand all Loading... |
37 | 37 |
38 class MultiprocessMessagePipeTest | 38 class MultiprocessMessagePipeTest |
39 : public test::MultiprocessMessagePipeTestBase {}; | 39 : public test::MultiprocessMessagePipeTestBase {}; |
40 | 40 |
41 // For each message received, sends a reply message with the same contents | 41 // For each message received, sends a reply message with the same contents |
42 // repeated twice, until the other end is closed or it receives "quitquitquit" | 42 // repeated twice, until the other end is closed or it receives "quitquitquit" |
43 // (which it doesn't reply to). It'll return the number of messages received, | 43 // (which it doesn't reply to). It'll return the number of messages received, |
44 // not including any "quitquitquit" message, modulo 100. | 44 // not including any "quitquitquit" message, modulo 100. |
45 MOJO_MULTIPROCESS_TEST_CHILD_MAIN(EchoEcho) { | 45 MOJO_MULTIPROCESS_TEST_CHILD_MAIN(EchoEcho) { |
46 ScopedPlatformHandle client_platform_handle = | 46 ScopedPlatformHandle client_platform_handle = |
47 test::MultiprocessTestHelper::client_platform_handle.Pass(); | 47 std::move(test::MultiprocessTestHelper::client_platform_handle); |
48 CHECK(client_platform_handle.is_valid()); | 48 CHECK(client_platform_handle.is_valid()); |
49 ScopedMessagePipeHandle mp = | 49 ScopedMessagePipeHandle mp = |
50 CreateMessagePipe(client_platform_handle.Pass()); | 50 CreateMessagePipe(std::move(client_platform_handle)); |
51 | 51 |
52 const std::string quitquitquit("quitquitquit"); | 52 const std::string quitquitquit("quitquitquit"); |
53 int rv = 0; | 53 int rv = 0; |
54 for (;; rv = (rv + 1) % 100) { | 54 for (;; rv = (rv + 1) % 100) { |
55 // Wait for our end of the message pipe to be readable. | 55 // Wait for our end of the message pipe to be readable. |
56 HandleSignalsState hss; | 56 HandleSignalsState hss; |
57 MojoResult result = | 57 MojoResult result = |
58 MojoWait(mp.get().value(), MOJO_HANDLE_SIGNAL_READABLE, | 58 MojoWait(mp.get().value(), MOJO_HANDLE_SIGNAL_READABLE, |
59 MOJO_DEADLINE_INDEFINITE, &hss); | 59 MOJO_DEADLINE_INDEFINITE, &hss); |
60 if (result != MOJO_RESULT_OK) { | 60 if (result != MOJO_RESULT_OK) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 // Sends "hello" to child, and expects "hellohello" back. | 95 // Sends "hello" to child, and expects "hellohello" back. |
96 #if defined(OS_ANDROID) | 96 #if defined(OS_ANDROID) |
97 // Android multi-process tests are not executing the new process. This is flaky. | 97 // Android multi-process tests are not executing the new process. This is flaky. |
98 #define MAYBE_Basic DISABLED_Basic | 98 #define MAYBE_Basic DISABLED_Basic |
99 #else | 99 #else |
100 #define MAYBE_Basic Basic | 100 #define MAYBE_Basic Basic |
101 #endif // defined(OS_ANDROID) | 101 #endif // defined(OS_ANDROID) |
102 TEST_F(MultiprocessMessagePipeTest, MAYBE_Basic) { | 102 TEST_F(MultiprocessMessagePipeTest, MAYBE_Basic) { |
103 helper()->StartChild("EchoEcho"); | 103 helper()->StartChild("EchoEcho"); |
104 | 104 |
105 ScopedMessagePipeHandle mp = CreateMessagePipe( | 105 ScopedMessagePipeHandle mp = |
106 helper()->server_platform_handle.Pass()); | 106 CreateMessagePipe(std::move(helper()->server_platform_handle)); |
107 | 107 |
108 std::string hello("hello"); | 108 std::string hello("hello"); |
109 ASSERT_EQ(MOJO_RESULT_OK, | 109 ASSERT_EQ(MOJO_RESULT_OK, |
110 MojoWriteMessage(mp.get().value(), hello.data(), | 110 MojoWriteMessage(mp.get().value(), hello.data(), |
111 static_cast<uint32_t>(hello.size()), nullptr, 0u, | 111 static_cast<uint32_t>(hello.size()), nullptr, 0u, |
112 MOJO_WRITE_MESSAGE_FLAG_NONE)); | 112 MOJO_WRITE_MESSAGE_FLAG_NONE)); |
113 | 113 |
114 HandleSignalsState hss; | 114 HandleSignalsState hss; |
115 ASSERT_EQ(MOJO_RESULT_OK, | 115 ASSERT_EQ(MOJO_RESULT_OK, |
116 MojoWait(mp.get().value(), MOJO_HANDLE_SIGNAL_READABLE, | 116 MojoWait(mp.get().value(), MOJO_HANDLE_SIGNAL_READABLE, |
(...skipping 24 matching lines...) Expand all Loading... |
141 // for the child to close its end before quitting. | 141 // for the child to close its end before quitting. |
142 #if defined(OS_ANDROID) | 142 #if defined(OS_ANDROID) |
143 // Android multi-process tests are not executing the new process. This is flaky. | 143 // Android multi-process tests are not executing the new process. This is flaky. |
144 #define MAYBE_QueueMessages DISABLED_QueueMessages | 144 #define MAYBE_QueueMessages DISABLED_QueueMessages |
145 #else | 145 #else |
146 #define MAYBE_QueueMessages QueueMessages | 146 #define MAYBE_QueueMessages QueueMessages |
147 #endif // defined(OS_ANDROID) | 147 #endif // defined(OS_ANDROID) |
148 TEST_F(MultiprocessMessagePipeTest, MAYBE_QueueMessages) { | 148 TEST_F(MultiprocessMessagePipeTest, MAYBE_QueueMessages) { |
149 helper()->StartChild("EchoEcho"); | 149 helper()->StartChild("EchoEcho"); |
150 | 150 |
151 ScopedMessagePipeHandle mp = CreateMessagePipe( | 151 ScopedMessagePipeHandle mp = |
152 helper()->server_platform_handle.Pass()); | 152 CreateMessagePipe(std::move(helper()->server_platform_handle)); |
153 | 153 |
154 static const size_t kNumMessages = 1001; | 154 static const size_t kNumMessages = 1001; |
155 for (size_t i = 0; i < kNumMessages; i++) { | 155 for (size_t i = 0; i < kNumMessages; i++) { |
156 std::string write_buffer(i, 'A' + (i % 26)); | 156 std::string write_buffer(i, 'A' + (i % 26)); |
157 ASSERT_EQ(MOJO_RESULT_OK, | 157 ASSERT_EQ(MOJO_RESULT_OK, |
158 MojoWriteMessage(mp.get().value(), write_buffer.data(), | 158 MojoWriteMessage(mp.get().value(), write_buffer.data(), |
159 static_cast<uint32_t>(write_buffer.size()), | 159 static_cast<uint32_t>(write_buffer.size()), |
160 nullptr, 0u, MOJO_WRITE_MESSAGE_FLAG_NONE)); | 160 nullptr, 0u, MOJO_WRITE_MESSAGE_FLAG_NONE)); |
161 } | 161 } |
162 | 162 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 MOJO_DEADLINE_INDEFINITE, &hss)); | 196 MOJO_DEADLINE_INDEFINITE, &hss)); |
197 ASSERT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfied_signals); | 197 ASSERT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfied_signals); |
198 ASSERT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfiable_signals); | 198 ASSERT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfiable_signals); |
199 | 199 |
200 ASSERT_EQ(static_cast<int>(kNumMessages % 100), | 200 ASSERT_EQ(static_cast<int>(kNumMessages % 100), |
201 helper()->WaitForChildShutdown()); | 201 helper()->WaitForChildShutdown()); |
202 } | 202 } |
203 | 203 |
204 MOJO_MULTIPROCESS_TEST_CHILD_MAIN(CheckSharedBuffer) { | 204 MOJO_MULTIPROCESS_TEST_CHILD_MAIN(CheckSharedBuffer) { |
205 ScopedPlatformHandle client_platform_handle = | 205 ScopedPlatformHandle client_platform_handle = |
206 test::MultiprocessTestHelper::client_platform_handle.Pass(); | 206 std::move(test::MultiprocessTestHelper::client_platform_handle); |
207 CHECK(client_platform_handle.is_valid()); | 207 CHECK(client_platform_handle.is_valid()); |
208 ScopedMessagePipeHandle mp = | 208 ScopedMessagePipeHandle mp = |
209 CreateMessagePipe(client_platform_handle.Pass()); | 209 CreateMessagePipe(std::move(client_platform_handle)); |
210 | 210 |
211 // Wait for the first message from our parent. | 211 // Wait for the first message from our parent. |
212 HandleSignalsState hss; | 212 HandleSignalsState hss; |
213 CHECK_EQ(MojoWait(mp.get().value(), MOJO_HANDLE_SIGNAL_READABLE, | 213 CHECK_EQ(MojoWait(mp.get().value(), MOJO_HANDLE_SIGNAL_READABLE, |
214 MOJO_DEADLINE_INDEFINITE, &hss), | 214 MOJO_DEADLINE_INDEFINITE, &hss), |
215 MOJO_RESULT_OK); | 215 MOJO_RESULT_OK); |
216 // In this test, the parent definitely doesn't close its end of the message | 216 // In this test, the parent definitely doesn't close its end of the message |
217 // pipe before we do. | 217 // pipe before we do. |
218 CHECK_EQ(hss.satisfied_signals, | 218 CHECK_EQ(hss.satisfied_signals, |
219 MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_WRITABLE); | 219 MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_WRITABLE); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 | 284 |
285 #if defined(OS_ANDROID) | 285 #if defined(OS_ANDROID) |
286 // Android multi-process tests are not executing the new process. This is flaky. | 286 // Android multi-process tests are not executing the new process. This is flaky. |
287 #define MAYBE_SharedBufferPassing DISABLED_SharedBufferPassing | 287 #define MAYBE_SharedBufferPassing DISABLED_SharedBufferPassing |
288 #else | 288 #else |
289 #define MAYBE_SharedBufferPassing SharedBufferPassing | 289 #define MAYBE_SharedBufferPassing SharedBufferPassing |
290 #endif | 290 #endif |
291 TEST_F(MultiprocessMessagePipeTest, MAYBE_SharedBufferPassing) { | 291 TEST_F(MultiprocessMessagePipeTest, MAYBE_SharedBufferPassing) { |
292 helper()->StartChild("CheckSharedBuffer"); | 292 helper()->StartChild("CheckSharedBuffer"); |
293 | 293 |
294 ScopedMessagePipeHandle mp = CreateMessagePipe( | 294 ScopedMessagePipeHandle mp = |
295 helper()->server_platform_handle.Pass()); | 295 CreateMessagePipe(std::move(helper()->server_platform_handle)); |
296 | 296 |
297 // Make a shared buffer. | 297 // Make a shared buffer. |
298 MojoCreateSharedBufferOptions options; | 298 MojoCreateSharedBufferOptions options; |
299 options.struct_size = sizeof(options); | 299 options.struct_size = sizeof(options); |
300 options.flags = MOJO_CREATE_SHARED_BUFFER_OPTIONS_FLAG_NONE; | 300 options.flags = MOJO_CREATE_SHARED_BUFFER_OPTIONS_FLAG_NONE; |
301 | 301 |
302 MojoHandle shared_buffer; | 302 MojoHandle shared_buffer; |
303 ASSERT_EQ(MOJO_RESULT_OK, | 303 ASSERT_EQ(MOJO_RESULT_OK, |
304 MojoCreateSharedBuffer(&options, 100, &shared_buffer)); | 304 MojoCreateSharedBuffer(&options, 100, &shared_buffer)); |
305 | 305 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 ASSERT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfied_signals); | 365 ASSERT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfied_signals); |
366 ASSERT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfiable_signals); | 366 ASSERT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfiable_signals); |
367 | 367 |
368 MojoClose(mp.release().value()); | 368 MojoClose(mp.release().value()); |
369 | 369 |
370 ASSERT_EQ(0, helper()->WaitForChildShutdown()); | 370 ASSERT_EQ(0, helper()->WaitForChildShutdown()); |
371 } | 371 } |
372 | 372 |
373 MOJO_MULTIPROCESS_TEST_CHILD_MAIN(CheckPlatformHandleFile) { | 373 MOJO_MULTIPROCESS_TEST_CHILD_MAIN(CheckPlatformHandleFile) { |
374 ScopedPlatformHandle client_platform_handle = | 374 ScopedPlatformHandle client_platform_handle = |
375 test::MultiprocessTestHelper::client_platform_handle.Pass(); | 375 std::move(test::MultiprocessTestHelper::client_platform_handle); |
376 CHECK(client_platform_handle.is_valid()); | 376 CHECK(client_platform_handle.is_valid()); |
377 ScopedMessagePipeHandle mp = | 377 ScopedMessagePipeHandle mp = |
378 CreateMessagePipe(client_platform_handle.Pass()); | 378 CreateMessagePipe(std::move(client_platform_handle)); |
379 | 379 |
380 HandleSignalsState hss; | 380 HandleSignalsState hss; |
381 CHECK_EQ(MojoWait(mp.get().value(), MOJO_HANDLE_SIGNAL_READABLE, | 381 CHECK_EQ(MojoWait(mp.get().value(), MOJO_HANDLE_SIGNAL_READABLE, |
382 MOJO_DEADLINE_INDEFINITE, &hss), | 382 MOJO_DEADLINE_INDEFINITE, &hss), |
383 MOJO_RESULT_OK); | 383 MOJO_RESULT_OK); |
384 CHECK_EQ(hss.satisfied_signals, | 384 CHECK_EQ(hss.satisfied_signals, |
385 MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_WRITABLE); | 385 MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_WRITABLE); |
386 CHECK_EQ(hss.satisfiable_signals, MOJO_HANDLE_SIGNAL_READABLE | | 386 CHECK_EQ(hss.satisfiable_signals, MOJO_HANDLE_SIGNAL_READABLE | |
387 MOJO_HANDLE_SIGNAL_WRITABLE | | 387 MOJO_HANDLE_SIGNAL_WRITABLE | |
388 MOJO_HANDLE_SIGNAL_PEER_CLOSED); | 388 MOJO_HANDLE_SIGNAL_PEER_CLOSED); |
(...skipping 17 matching lines...) Expand all Loading... |
406 CHECK_GT(num_handles, 0); | 406 CHECK_GT(num_handles, 0); |
407 | 407 |
408 for (int i = 0; i < num_handles; ++i) { | 408 for (int i = 0; i < num_handles; ++i) { |
409 ScopedPlatformHandle h; | 409 ScopedPlatformHandle h; |
410 CHECK_EQ(PassWrappedPlatformHandle( | 410 CHECK_EQ(PassWrappedPlatformHandle( |
411 handles[i], &h), | 411 handles[i], &h), |
412 MOJO_RESULT_OK); | 412 MOJO_RESULT_OK); |
413 CHECK(h.is_valid()); | 413 CHECK(h.is_valid()); |
414 MojoClose(handles[i]); | 414 MojoClose(handles[i]); |
415 | 415 |
416 base::ScopedFILE fp(test::FILEFromPlatformHandle(h.Pass(), "r")); | 416 base::ScopedFILE fp(test::FILEFromPlatformHandle(std::move(h), "r")); |
417 CHECK(fp); | 417 CHECK(fp); |
418 std::string fread_buffer(100, '\0'); | 418 std::string fread_buffer(100, '\0'); |
419 size_t bytes_read = | 419 size_t bytes_read = |
420 fread(&fread_buffer[0], 1, fread_buffer.size(), fp.get()); | 420 fread(&fread_buffer[0], 1, fread_buffer.size(), fp.get()); |
421 fread_buffer.resize(bytes_read); | 421 fread_buffer.resize(bytes_read); |
422 CHECK_EQ(fread_buffer, "world"); | 422 CHECK_EQ(fread_buffer, "world"); |
423 } | 423 } |
424 | 424 |
425 return 0; | 425 return 0; |
426 } | 426 } |
427 | 427 |
428 class MultiprocessMessagePipeTestWithPipeCount | 428 class MultiprocessMessagePipeTestWithPipeCount |
429 : public test::MultiprocessMessagePipeTestBase, | 429 : public test::MultiprocessMessagePipeTestBase, |
430 public testing::WithParamInterface<size_t> {}; | 430 public testing::WithParamInterface<size_t> {}; |
431 | 431 |
432 TEST_P(MultiprocessMessagePipeTestWithPipeCount, PlatformHandlePassing) { | 432 TEST_P(MultiprocessMessagePipeTestWithPipeCount, PlatformHandlePassing) { |
433 base::ScopedTempDir temp_dir; | 433 base::ScopedTempDir temp_dir; |
434 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 434 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
435 | 435 |
436 helper()->StartChild("CheckPlatformHandleFile"); | 436 helper()->StartChild("CheckPlatformHandleFile"); |
437 ScopedMessagePipeHandle mp = CreateMessagePipe( | 437 ScopedMessagePipeHandle mp = |
438 helper()->server_platform_handle.Pass()); | 438 CreateMessagePipe(std::move(helper()->server_platform_handle)); |
439 | 439 |
440 std::vector<MojoHandle> handles; | 440 std::vector<MojoHandle> handles; |
441 | 441 |
442 size_t pipe_count = GetParam(); | 442 size_t pipe_count = GetParam(); |
443 for (size_t i = 0; i < pipe_count; ++i) { | 443 for (size_t i = 0; i < pipe_count; ++i) { |
444 base::FilePath unused; | 444 base::FilePath unused; |
445 base::ScopedFILE fp( | 445 base::ScopedFILE fp( |
446 CreateAndOpenTemporaryFileInDir(temp_dir.path(), &unused)); | 446 CreateAndOpenTemporaryFileInDir(temp_dir.path(), &unused)); |
447 const std::string world("world"); | 447 const std::string world("world"); |
448 CHECK_EQ(fwrite(&world[0], 1, world.size(), fp.get()), world.size()); | 448 CHECK_EQ(fwrite(&world[0], 1, world.size(), fp.get()), world.size()); |
449 fflush(fp.get()); | 449 fflush(fp.get()); |
450 rewind(fp.get()); | 450 rewind(fp.get()); |
451 MojoHandle handle; | 451 MojoHandle handle; |
452 ASSERT_EQ(CreatePlatformHandleWrapper( | 452 ASSERT_EQ( |
453 ScopedPlatformHandle(test::PlatformHandleFromFILE(fp.Pass())), | 453 CreatePlatformHandleWrapper( |
454 &handle), | 454 ScopedPlatformHandle(test::PlatformHandleFromFILE(std::move(fp))), |
455 MOJO_RESULT_OK); | 455 &handle), |
| 456 MOJO_RESULT_OK); |
456 handles.push_back(handle); | 457 handles.push_back(handle); |
457 } | 458 } |
458 | 459 |
459 char message[128]; | 460 char message[128]; |
460 sprintf(message, "hello %d", static_cast<int>(pipe_count)); | 461 sprintf(message, "hello %d", static_cast<int>(pipe_count)); |
461 ASSERT_EQ(MOJO_RESULT_OK, | 462 ASSERT_EQ(MOJO_RESULT_OK, |
462 MojoWriteMessage(mp.get().value(), message, | 463 MojoWriteMessage(mp.get().value(), message, |
463 static_cast<uint32_t>(strlen(message)), | 464 static_cast<uint32_t>(strlen(message)), |
464 &handles[0], static_cast<uint32_t>(handles.size()), | 465 &handles[0], static_cast<uint32_t>(handles.size()), |
465 MOJO_WRITE_MESSAGE_FLAG_NONE)); | 466 MOJO_WRITE_MESSAGE_FLAG_NONE)); |
(...skipping 13 matching lines...) Expand all Loading... |
479 | 480 |
480 // Android multi-process tests are not executing the new process. This is flaky. | 481 // Android multi-process tests are not executing the new process. This is flaky. |
481 #if !defined(OS_ANDROID) | 482 #if !defined(OS_ANDROID) |
482 INSTANTIATE_TEST_CASE_P(PipeCount, | 483 INSTANTIATE_TEST_CASE_P(PipeCount, |
483 MultiprocessMessagePipeTestWithPipeCount, | 484 MultiprocessMessagePipeTestWithPipeCount, |
484 testing::Values(1u, 128u, 140u)); | 485 testing::Values(1u, 128u, 140u)); |
485 #endif | 486 #endif |
486 | 487 |
487 MOJO_MULTIPROCESS_TEST_CHILD_MAIN(CheckMessagePipe) { | 488 MOJO_MULTIPROCESS_TEST_CHILD_MAIN(CheckMessagePipe) { |
488 ScopedPlatformHandle client_platform_handle = | 489 ScopedPlatformHandle client_platform_handle = |
489 test::MultiprocessTestHelper::client_platform_handle.Pass(); | 490 std::move(test::MultiprocessTestHelper::client_platform_handle); |
490 CHECK(client_platform_handle.is_valid()); | 491 CHECK(client_platform_handle.is_valid()); |
491 | 492 |
492 ScopedMessagePipeHandle mp = | 493 ScopedMessagePipeHandle mp = |
493 CreateMessagePipe(client_platform_handle.Pass()); | 494 CreateMessagePipe(std::move(client_platform_handle)); |
494 | 495 |
495 // Wait for the first message from our parent. | 496 // Wait for the first message from our parent. |
496 HandleSignalsState hss; | 497 HandleSignalsState hss; |
497 CHECK_EQ(MojoWait(mp.get().value(), MOJO_HANDLE_SIGNAL_READABLE, | 498 CHECK_EQ(MojoWait(mp.get().value(), MOJO_HANDLE_SIGNAL_READABLE, |
498 MOJO_DEADLINE_INDEFINITE, &hss), | 499 MOJO_DEADLINE_INDEFINITE, &hss), |
499 MOJO_RESULT_OK); | 500 MOJO_RESULT_OK); |
500 // In this test, the parent definitely doesn't close its end of the message | 501 // In this test, the parent definitely doesn't close its end of the message |
501 // pipe before we do. | 502 // pipe before we do. |
502 CHECK_EQ(hss.satisfied_signals, | 503 CHECK_EQ(hss.satisfied_signals, |
503 MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_WRITABLE); | 504 MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_WRITABLE); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 #if defined(OS_ANDROID) | 547 #if defined(OS_ANDROID) |
547 // Android multi-process tests are not executing the new process. This is flaky. | 548 // Android multi-process tests are not executing the new process. This is flaky. |
548 #define MAYBE_MessagePipePassing DISABLED_MessagePipePassing | 549 #define MAYBE_MessagePipePassing DISABLED_MessagePipePassing |
549 #else | 550 #else |
550 #define MAYBE_MessagePipePassing MessagePipePassing | 551 #define MAYBE_MessagePipePassing MessagePipePassing |
551 #endif | 552 #endif |
552 TEST_F(MultiprocessMessagePipeTest, MAYBE_MessagePipePassing) { | 553 TEST_F(MultiprocessMessagePipeTest, MAYBE_MessagePipePassing) { |
553 helper()->StartChild("CheckMessagePipe"); | 554 helper()->StartChild("CheckMessagePipe"); |
554 | 555 |
555 ScopedMessagePipeHandle mp = | 556 ScopedMessagePipeHandle mp = |
556 CreateMessagePipe(helper()->server_platform_handle.Pass()); | 557 CreateMessagePipe(std::move(helper()->server_platform_handle)); |
557 MojoCreateSharedBufferOptions options; | 558 MojoCreateSharedBufferOptions options; |
558 options.struct_size = sizeof(options); | 559 options.struct_size = sizeof(options); |
559 options.flags = MOJO_CREATE_SHARED_BUFFER_OPTIONS_FLAG_NONE; | 560 options.flags = MOJO_CREATE_SHARED_BUFFER_OPTIONS_FLAG_NONE; |
560 | 561 |
561 MojoHandle mp1, mp2; | 562 MojoHandle mp1, mp2; |
562 ASSERT_EQ(MOJO_RESULT_OK, | 563 ASSERT_EQ(MOJO_RESULT_OK, |
563 MojoCreateMessagePipe(nullptr, &mp1, &mp2)); | 564 MojoCreateMessagePipe(nullptr, &mp1, &mp2)); |
564 | 565 |
565 // Write a string into one end of the new message pipe and send the other end. | 566 // Write a string into one end of the new message pipe and send the other end. |
566 const std::string hello("hello"); | 567 const std::string hello("hello"); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 #if defined(OS_ANDROID) | 600 #if defined(OS_ANDROID) |
600 // Android multi-process tests are not executing the new process. This is flaky. | 601 // Android multi-process tests are not executing the new process. This is flaky. |
601 #define MAYBE_MessagePipeTwoPassing DISABLED_MessagePipeTwoPassing | 602 #define MAYBE_MessagePipeTwoPassing DISABLED_MessagePipeTwoPassing |
602 #else | 603 #else |
603 #define MAYBE_MessagePipeTwoPassing MessagePipeTwoPassing | 604 #define MAYBE_MessagePipeTwoPassing MessagePipeTwoPassing |
604 #endif | 605 #endif |
605 TEST_F(MultiprocessMessagePipeTest, MAYBE_MessagePipeTwoPassing) { | 606 TEST_F(MultiprocessMessagePipeTest, MAYBE_MessagePipeTwoPassing) { |
606 helper()->StartChild("CheckMessagePipe"); | 607 helper()->StartChild("CheckMessagePipe"); |
607 | 608 |
608 ScopedMessagePipeHandle mp = | 609 ScopedMessagePipeHandle mp = |
609 CreateMessagePipe(helper()->server_platform_handle.Pass()); | 610 CreateMessagePipe(std::move(helper()->server_platform_handle)); |
610 | 611 |
611 MojoHandle mp1, mp2; | 612 MojoHandle mp1, mp2; |
612 ASSERT_EQ(MOJO_RESULT_OK, | 613 ASSERT_EQ(MOJO_RESULT_OK, |
613 MojoCreateMessagePipe(nullptr, &mp2, &mp1)); | 614 MojoCreateMessagePipe(nullptr, &mp2, &mp1)); |
614 | 615 |
615 // Write a string into one end of the new message pipe and send the other end. | 616 // Write a string into one end of the new message pipe and send the other end. |
616 const std::string hello("hello"); | 617 const std::string hello("hello"); |
617 ASSERT_EQ(MOJO_RESULT_OK, | 618 ASSERT_EQ(MOJO_RESULT_OK, |
618 MojoWriteMessage(mp1, &hello[0], | 619 MojoWriteMessage(mp1, &hello[0], |
619 static_cast<uint32_t>(hello.size()), nullptr, 0u, | 620 static_cast<uint32_t>(hello.size()), nullptr, 0u, |
(...skipping 19 matching lines...) Expand all Loading... |
639 read_buffer.resize(read_buffer_size); | 640 read_buffer.resize(read_buffer_size); |
640 CHECK_EQ(read_buffer, std::string("world")); | 641 CHECK_EQ(read_buffer, std::string("world")); |
641 | 642 |
642 MojoClose(mp.release().value()); | 643 MojoClose(mp.release().value()); |
643 | 644 |
644 ASSERT_EQ(0, helper()->WaitForChildShutdown()); | 645 ASSERT_EQ(0, helper()->WaitForChildShutdown()); |
645 } | 646 } |
646 | 647 |
647 MOJO_MULTIPROCESS_TEST_CHILD_MAIN(DataPipeConsumer) { | 648 MOJO_MULTIPROCESS_TEST_CHILD_MAIN(DataPipeConsumer) { |
648 ScopedPlatformHandle client_platform_handle = | 649 ScopedPlatformHandle client_platform_handle = |
649 test::MultiprocessTestHelper::client_platform_handle.Pass(); | 650 std::move(test::MultiprocessTestHelper::client_platform_handle); |
650 CHECK(client_platform_handle.is_valid()); | 651 CHECK(client_platform_handle.is_valid()); |
651 | 652 |
652 ScopedMessagePipeHandle mp = | 653 ScopedMessagePipeHandle mp = |
653 CreateMessagePipe(client_platform_handle.Pass()); | 654 CreateMessagePipe(std::move(client_platform_handle)); |
654 | 655 |
655 // Wait for the first message from our parent. | 656 // Wait for the first message from our parent. |
656 HandleSignalsState hss; | 657 HandleSignalsState hss; |
657 CHECK_EQ(MojoWait(mp.get().value(), MOJO_HANDLE_SIGNAL_READABLE, | 658 CHECK_EQ(MojoWait(mp.get().value(), MOJO_HANDLE_SIGNAL_READABLE, |
658 MOJO_DEADLINE_INDEFINITE, &hss), | 659 MOJO_DEADLINE_INDEFINITE, &hss), |
659 MOJO_RESULT_OK); | 660 MOJO_RESULT_OK); |
660 // In this test, the parent definitely doesn't close its end of the message | 661 // In this test, the parent definitely doesn't close its end of the message |
661 // pipe before we do. | 662 // pipe before we do. |
662 CHECK_EQ(hss.satisfied_signals, | 663 CHECK_EQ(hss.satisfied_signals, |
663 MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_WRITABLE); | 664 MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_WRITABLE); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 #if defined(OS_ANDROID) | 707 #if defined(OS_ANDROID) |
707 // Android multi-process tests are not executing the new process. This is flaky. | 708 // Android multi-process tests are not executing the new process. This is flaky. |
708 #define MAYBE_DataPipeConsumer DISABLED_DataPipeConsumer | 709 #define MAYBE_DataPipeConsumer DISABLED_DataPipeConsumer |
709 #else | 710 #else |
710 #define MAYBE_DataPipeConsumer DataPipeConsumer | 711 #define MAYBE_DataPipeConsumer DataPipeConsumer |
711 #endif | 712 #endif |
712 TEST_F(MultiprocessMessagePipeTest, MAYBE_DataPipeConsumer) { | 713 TEST_F(MultiprocessMessagePipeTest, MAYBE_DataPipeConsumer) { |
713 helper()->StartChild("DataPipeConsumer"); | 714 helper()->StartChild("DataPipeConsumer"); |
714 | 715 |
715 ScopedMessagePipeHandle mp = | 716 ScopedMessagePipeHandle mp = |
716 CreateMessagePipe(helper()->server_platform_handle.Pass()); | 717 CreateMessagePipe(std::move(helper()->server_platform_handle)); |
717 MojoCreateSharedBufferOptions options; | 718 MojoCreateSharedBufferOptions options; |
718 options.struct_size = sizeof(options); | 719 options.struct_size = sizeof(options); |
719 options.flags = MOJO_CREATE_SHARED_BUFFER_OPTIONS_FLAG_NONE; | 720 options.flags = MOJO_CREATE_SHARED_BUFFER_OPTIONS_FLAG_NONE; |
720 | 721 |
721 MojoHandle mp1, mp2; | 722 MojoHandle mp1, mp2; |
722 ASSERT_EQ(MOJO_RESULT_OK, | 723 ASSERT_EQ(MOJO_RESULT_OK, |
723 MojoCreateMessagePipe(nullptr, &mp2, &mp1)); | 724 MojoCreateMessagePipe(nullptr, &mp2, &mp1)); |
724 | 725 |
725 // Write a string into one end of the new message pipe and send the other end. | 726 // Write a string into one end of the new message pipe and send the other end. |
726 const std::string hello("hello"); | 727 const std::string hello("hello"); |
(...skipping 24 matching lines...) Expand all Loading... |
751 | 752 |
752 MojoClose(mp1); | 753 MojoClose(mp1); |
753 MojoClose(mp.release().value()); | 754 MojoClose(mp.release().value()); |
754 | 755 |
755 ASSERT_EQ(0, helper()->WaitForChildShutdown()); | 756 ASSERT_EQ(0, helper()->WaitForChildShutdown()); |
756 } | 757 } |
757 | 758 |
758 } // namespace | 759 } // namespace |
759 } // namespace edk | 760 } // namespace edk |
760 } // namespace mojo | 761 } // namespace mojo |
OLD | NEW |