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

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

Issue 2596373002: [mojo] Fix some lint errors (Closed)
Patch Set: Created 4 years 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/core.cc ('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 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 MojoHandle handle; 436 MojoHandle handle;
437 ASSERT_EQ( 437 ASSERT_EQ(
438 CreatePlatformHandleWrapper( 438 CreatePlatformHandleWrapper(
439 ScopedPlatformHandle(test::PlatformHandleFromFILE(std::move(fp))), 439 ScopedPlatformHandle(test::PlatformHandleFromFILE(std::move(fp))),
440 &handle), 440 &handle),
441 MOJO_RESULT_OK); 441 MOJO_RESULT_OK);
442 handles.push_back(handle); 442 handles.push_back(handle);
443 } 443 }
444 444
445 char message[128]; 445 char message[128];
446 sprintf(message, "hello %d", static_cast<int>(pipe_count)); 446 snprintf(message, sizeof(message), "hello %d",
447 static_cast<int>(pipe_count));
447 ASSERT_EQ(MOJO_RESULT_OK, 448 ASSERT_EQ(MOJO_RESULT_OK,
448 MojoWriteMessage(h, message, 449 MojoWriteMessage(h, message,
449 static_cast<uint32_t>(strlen(message)), 450 static_cast<uint32_t>(strlen(message)),
450 &handles[0], 451 &handles[0],
451 static_cast<uint32_t>(handles.size()), 452 static_cast<uint32_t>(handles.size()),
452 MOJO_WRITE_MESSAGE_FLAG_NONE)); 453 MOJO_WRITE_MESSAGE_FLAG_NONE));
453 454
454 // Wait for it to become readable, which should fail. 455 // Wait for it to become readable, which should fail.
455 HandleSignalsState hss; 456 HandleSignalsState hss;
456 ASSERT_EQ(MOJO_RESULT_FAILED_PRECONDITION, 457 ASSERT_EQ(MOJO_RESULT_FAILED_PRECONDITION,
457 MojoWait(h, MOJO_HANDLE_SIGNAL_READABLE, 458 MojoWait(h, MOJO_HANDLE_SIGNAL_READABLE,
458 MOJO_DEADLINE_INDEFINITE, &hss)); 459 MOJO_DEADLINE_INDEFINITE, &hss));
459 ASSERT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfied_signals); 460 ASSERT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfied_signals);
460 ASSERT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfiable_signals); 461 ASSERT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfiable_signals);
461 END_CHILD() 462 END_CHILD()
462 } 463 }
463 464
464 // Android multi-process tests are not executing the new process. This is flaky. 465 // Android multi-process tests are not executing the new process. This is flaky.
465 #if !defined(OS_ANDROID) 466 #if !defined(OS_ANDROID)
466 INSTANTIATE_TEST_CASE_P(PipeCount, 467 INSTANTIATE_TEST_CASE_P(PipeCount,
467 MultiprocessMessagePipeTestWithPipeCount, 468 MultiprocessMessagePipeTestWithPipeCount,
468 // TODO: Re-enable the 140-pipe case when ChannelPosix 469 // TODO(rockot): Re-enable the 140-pipe case when
469 // has support for sending lots of handles. 470 // ChannelPosix has support for sending lots of handles.
470 testing::Values(1u, 128u/*, 140u*/)); 471 testing::Values(1u, 128u /*, 140u*/));
471 #endif 472 #endif
472 473
473 DEFINE_TEST_CLIENT_WITH_PIPE(CheckMessagePipe, MultiprocessMessagePipeTest, h) { 474 DEFINE_TEST_CLIENT_WITH_PIPE(CheckMessagePipe, MultiprocessMessagePipeTest, h) {
474 // Wait for the first message from our parent. 475 // Wait for the first message from our parent.
475 HandleSignalsState hss; 476 HandleSignalsState hss;
476 CHECK_EQ(MojoWait(h, MOJO_HANDLE_SIGNAL_READABLE, 477 CHECK_EQ(MojoWait(h, MOJO_HANDLE_SIGNAL_READABLE,
477 MOJO_DEADLINE_INDEFINITE, &hss), 478 MOJO_DEADLINE_INDEFINITE, &hss),
478 MOJO_RESULT_OK); 479 MOJO_RESULT_OK);
479 // In this test, the parent definitely doesn't close its end of the message 480 // In this test, the parent definitely doesn't close its end of the message
480 // pipe before we do. 481 // pipe before we do.
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 ReadMessageWithHandles(carrier, &p, 1); 991 ReadMessageWithHandles(carrier, &p, 1);
991 CHECK_NE(p, MOJO_HANDLE_INVALID); 992 CHECK_NE(p, MOJO_HANDLE_INVALID);
992 named_pipes[parts[1]] = p; 993 named_pipes[parts[1]] = p;
993 WriteMessage(h, "ok"); 994 WriteMessage(h, "ok");
994 } else if (command == "exit") { 995 } else if (command == "exit") {
995 CHECK_EQ(parts.size(), 1u); 996 CHECK_EQ(parts.size(), 1u);
996 break; 997 break;
997 } 998 }
998 } 999 }
999 1000
1000 for (auto& pipe: named_pipes) 1001 for (auto& pipe : named_pipes)
1001 CloseHandle(pipe.second); 1002 CloseHandle(pipe.second);
1002 1003
1003 return 0; 1004 return 0;
1004 } 1005 }
1005 1006
1006 TEST_F(MultiprocessMessagePipeTest, ChildToChildPipes) { 1007 TEST_F(MultiprocessMessagePipeTest, ChildToChildPipes) {
1007 RUN_CHILD_ON_PIPE(CommandDrivenClient, h0) 1008 RUN_CHILD_ON_PIPE(CommandDrivenClient, h0)
1008 RUN_CHILD_ON_PIPE(CommandDrivenClient, h1) 1009 RUN_CHILD_ON_PIPE(CommandDrivenClient, h1)
1009 CommandDrivenClientController a(h0); 1010 CommandDrivenClientController a(h0);
1010 CommandDrivenClientController b(h1); 1011 CommandDrivenClientController b(h1);
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
1420 INSTANTIATE_TEST_CASE_P( 1421 INSTANTIATE_TEST_CASE_P(
1421 , 1422 ,
1422 MultiprocessMessagePipeTestWithPeerSupport, 1423 MultiprocessMessagePipeTestWithPeerSupport,
1423 testing::Values(test::MojoTestBase::LaunchType::CHILD, 1424 testing::Values(test::MojoTestBase::LaunchType::CHILD,
1424 test::MojoTestBase::LaunchType::PEER, 1425 test::MojoTestBase::LaunchType::PEER,
1425 test::MojoTestBase::LaunchType::NAMED_CHILD, 1426 test::MojoTestBase::LaunchType::NAMED_CHILD,
1426 test::MojoTestBase::LaunchType::NAMED_PEER)); 1427 test::MojoTestBase::LaunchType::NAMED_PEER));
1427 } // namespace 1428 } // namespace
1428 } // namespace edk 1429 } // namespace edk
1429 } // namespace mojo 1430 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/core.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698