Index: mojo/edk/system/message_pipe_dispatcher_unittest.cc |
diff --git a/mojo/edk/system/message_pipe_dispatcher_unittest.cc b/mojo/edk/system/message_pipe_dispatcher_unittest.cc |
index 8076a99410d3ac68456e4d260026be2f17f337e2..ae651fa981d5f7f4caaf236a77f4148789398472 100644 |
--- a/mojo/edk/system/message_pipe_dispatcher_unittest.cc |
+++ b/mojo/edk/system/message_pipe_dispatcher_unittest.cc |
@@ -68,8 +68,10 @@ |
d0->AddWaiter(&w, MOJO_HANDLE_SIGNAL_READABLE, 1, nullptr)); |
buffer[0] = 123456789; |
EXPECT_EQ(MOJO_RESULT_OK, |
- d1->WriteMessage(UserPointer<const void>(buffer), kBufferSize, |
- nullptr, MOJO_WRITE_MESSAGE_FLAG_NONE)); |
+ d1->WriteMessage(UserPointer<const void>(buffer), |
+ kBufferSize, |
+ nullptr, |
+ MOJO_WRITE_MESSAGE_FLAG_NONE)); |
stopwatch.Start(); |
EXPECT_EQ(MOJO_RESULT_OK, w.Wait(MOJO_DEADLINE_INDEFINITE, &context)); |
EXPECT_EQ(1u, context); |
@@ -97,7 +99,9 @@ |
buffer_size = kBufferSize; |
EXPECT_EQ(MOJO_RESULT_OK, |
d0->ReadMessage(UserPointer<void>(buffer), |
- MakeUserPointer(&buffer_size), 0, nullptr, |
+ MakeUserPointer(&buffer_size), |
+ 0, |
+ nullptr, |
MOJO_READ_MESSAGE_FLAG_NONE)); |
EXPECT_EQ(kBufferSize, buffer_size); |
EXPECT_EQ(123456789, buffer[0]); |
@@ -153,7 +157,8 @@ |
// Huge buffer size. |
EXPECT_EQ(MOJO_RESULT_RESOURCE_EXHAUSTED, |
d0->WriteMessage(UserPointer<const void>(buffer), |
- std::numeric_limits<uint32_t>::max(), nullptr, |
+ std::numeric_limits<uint32_t>::max(), |
+ nullptr, |
MOJO_WRITE_MESSAGE_FLAG_NONE)); |
EXPECT_EQ(MOJO_RESULT_OK, d0->Close()); |
@@ -181,21 +186,26 @@ |
// |WriteMessage|: |
// Null buffer with nonzero buffer size. |
- EXPECT_DEATH_IF_SUPPORTED(d0->WriteMessage(NullUserPointer(), 1, nullptr, |
- MOJO_WRITE_MESSAGE_FLAG_NONE), |
- kMemoryCheckFailedRegex); |
+ EXPECT_DEATH_IF_SUPPORTED( |
+ d0->WriteMessage( |
+ NullUserPointer(), 1, nullptr, MOJO_WRITE_MESSAGE_FLAG_NONE), |
+ kMemoryCheckFailedRegex); |
// |ReadMessage|: |
// Null buffer with nonzero buffer size. |
// First write something so that we actually have something to read. |
EXPECT_EQ(MOJO_RESULT_OK, |
- d1->WriteMessage(UserPointer<const void>("x"), 1, nullptr, |
+ d1->WriteMessage(UserPointer<const void>("x"), |
+ 1, |
+ nullptr, |
MOJO_WRITE_MESSAGE_FLAG_NONE)); |
uint32_t buffer_size = 1; |
- EXPECT_DEATH_IF_SUPPORTED( |
- d0->ReadMessage(NullUserPointer(), MakeUserPointer(&buffer_size), 0, |
- nullptr, MOJO_READ_MESSAGE_FLAG_NONE), |
- kMemoryCheckFailedRegex); |
+ EXPECT_DEATH_IF_SUPPORTED(d0->ReadMessage(NullUserPointer(), |
+ MakeUserPointer(&buffer_size), |
+ 0, |
+ nullptr, |
+ MOJO_READ_MESSAGE_FLAG_NONE), |
+ kMemoryCheckFailedRegex); |
EXPECT_EQ(MOJO_RESULT_OK, d0->Close()); |
EXPECT_EQ(MOJO_RESULT_OK, d1->Close()); |
@@ -224,12 +234,16 @@ |
// Write (twice) to |d1|. |
buffer[0] = 123456789; |
EXPECT_EQ(MOJO_RESULT_OK, |
- d1->WriteMessage(UserPointer<const void>(buffer), kBufferSize, |
- nullptr, MOJO_WRITE_MESSAGE_FLAG_NONE)); |
+ d1->WriteMessage(UserPointer<const void>(buffer), |
+ kBufferSize, |
+ nullptr, |
+ MOJO_WRITE_MESSAGE_FLAG_NONE)); |
buffer[0] = 234567890; |
EXPECT_EQ(MOJO_RESULT_OK, |
- d1->WriteMessage(UserPointer<const void>(buffer), kBufferSize, |
- nullptr, MOJO_WRITE_MESSAGE_FLAG_NONE)); |
+ d1->WriteMessage(UserPointer<const void>(buffer), |
+ kBufferSize, |
+ nullptr, |
+ MOJO_WRITE_MESSAGE_FLAG_NONE)); |
// Try waiting for readable on |d0|; should fail (already satisfied). |
w.Init(); |
@@ -246,7 +260,9 @@ |
buffer_size = kBufferSize; |
EXPECT_EQ(MOJO_RESULT_SHOULD_WAIT, |
d1->ReadMessage(UserPointer<void>(buffer), |
- MakeUserPointer(&buffer_size), 0, nullptr, |
+ MakeUserPointer(&buffer_size), |
+ 0, |
+ nullptr, |
MOJO_READ_MESSAGE_FLAG_NONE)); |
// Close |d1|. |
@@ -265,7 +281,9 @@ |
buffer_size = kBufferSize; |
EXPECT_EQ(MOJO_RESULT_OK, |
d0->ReadMessage(UserPointer<void>(buffer), |
- MakeUserPointer(&buffer_size), 0, nullptr, |
+ MakeUserPointer(&buffer_size), |
+ 0, |
+ nullptr, |
MOJO_READ_MESSAGE_FLAG_NONE)); |
EXPECT_EQ(kBufferSize, buffer_size); |
EXPECT_EQ(123456789, buffer[0]); |
@@ -283,7 +301,9 @@ |
buffer_size = kBufferSize; |
EXPECT_EQ(MOJO_RESULT_OK, |
d0->ReadMessage(UserPointer<void>(buffer), |
- MakeUserPointer(&buffer_size), 0, nullptr, |
+ MakeUserPointer(&buffer_size), |
+ 0, |
+ nullptr, |
MOJO_READ_MESSAGE_FLAG_NONE)); |
EXPECT_EQ(kBufferSize, buffer_size); |
EXPECT_EQ(234567890, buffer[0]); |
@@ -310,14 +330,18 @@ |
buffer_size = kBufferSize; |
EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, |
d0->ReadMessage(UserPointer<void>(buffer), |
- MakeUserPointer(&buffer_size), 0, nullptr, |
+ MakeUserPointer(&buffer_size), |
+ 0, |
+ nullptr, |
MOJO_READ_MESSAGE_FLAG_NONE)); |
// Try writing to |d0|; should fail (other end closed). |
buffer[0] = 345678901; |
EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, |
- d0->WriteMessage(UserPointer<const void>(buffer), kBufferSize, |
- nullptr, MOJO_WRITE_MESSAGE_FLAG_NONE)); |
+ d0->WriteMessage(UserPointer<const void>(buffer), |
+ kBufferSize, |
+ nullptr, |
+ MOJO_WRITE_MESSAGE_FLAG_NONE)); |
EXPECT_EQ(MOJO_RESULT_OK, d0->Close()); |
} |
@@ -354,17 +378,24 @@ |
// Wait for readable on |d1|, which will become readable after some time. |
{ |
- test::WaiterThread thread(d1, MOJO_HANDLE_SIGNAL_READABLE, |
- MOJO_DEADLINE_INDEFINITE, 1, &did_wait, &result, |
- &context, &hss); |
+ test::WaiterThread thread(d1, |
+ MOJO_HANDLE_SIGNAL_READABLE, |
+ MOJO_DEADLINE_INDEFINITE, |
+ 1, |
+ &did_wait, |
+ &result, |
+ &context, |
+ &hss); |
stopwatch.Start(); |
thread.Start(); |
base::PlatformThread::Sleep(2 * test::EpsilonTimeout()); |
// Wake it up by writing to |d0|. |
buffer[0] = 123456789; |
EXPECT_EQ(MOJO_RESULT_OK, |
- d0->WriteMessage(UserPointer<const void>(buffer), kBufferSize, |
- nullptr, MOJO_WRITE_MESSAGE_FLAG_NONE)); |
+ d0->WriteMessage(UserPointer<const void>(buffer), |
+ kBufferSize, |
+ nullptr, |
+ MOJO_WRITE_MESSAGE_FLAG_NONE)); |
} // Joins the thread. |
elapsed = stopwatch.Elapsed(); |
EXPECT_GT(elapsed, (2 - 1) * test::EpsilonTimeout()); |
@@ -379,9 +410,14 @@ |
// Now |d1| is already readable. Try waiting for it again. |
{ |
- test::WaiterThread thread(d1, MOJO_HANDLE_SIGNAL_READABLE, |
- MOJO_DEADLINE_INDEFINITE, 2, &did_wait, &result, |
- &context, &hss); |
+ test::WaiterThread thread(d1, |
+ MOJO_HANDLE_SIGNAL_READABLE, |
+ MOJO_DEADLINE_INDEFINITE, |
+ 2, |
+ &did_wait, |
+ &result, |
+ &context, |
+ &hss); |
stopwatch.Start(); |
thread.Start(); |
} // Joins the thread. |
@@ -398,7 +434,9 @@ |
buffer_size = kBufferSize; |
EXPECT_EQ(MOJO_RESULT_OK, |
d1->ReadMessage(UserPointer<void>(buffer), |
- MakeUserPointer(&buffer_size), 0, nullptr, |
+ MakeUserPointer(&buffer_size), |
+ 0, |
+ nullptr, |
MOJO_READ_MESSAGE_FLAG_NONE)); |
EXPECT_EQ(kBufferSize, buffer_size); |
EXPECT_EQ(123456789, buffer[0]); |
@@ -406,9 +444,14 @@ |
// Wait for readable on |d1| and close |d0| after some time, which should |
// cancel that wait. |
{ |
- test::WaiterThread thread(d1, MOJO_HANDLE_SIGNAL_READABLE, |
- MOJO_DEADLINE_INDEFINITE, 3, &did_wait, &result, |
- &context, &hss); |
+ test::WaiterThread thread(d1, |
+ MOJO_HANDLE_SIGNAL_READABLE, |
+ MOJO_DEADLINE_INDEFINITE, |
+ 3, |
+ &did_wait, |
+ &result, |
+ &context, |
+ &hss); |
stopwatch.Start(); |
thread.Start(); |
base::PlatformThread::Sleep(2 * test::EpsilonTimeout()); |
@@ -440,9 +483,14 @@ |
// Wait for readable on |d1| and close |d1| after some time, which should |
// cancel that wait. |
{ |
- test::WaiterThread thread(d1, MOJO_HANDLE_SIGNAL_READABLE, |
- MOJO_DEADLINE_INDEFINITE, 4, &did_wait, &result, |
- &context, &hss); |
+ test::WaiterThread thread(d1, |
+ MOJO_HANDLE_SIGNAL_READABLE, |
+ MOJO_DEADLINE_INDEFINITE, |
+ 4, |
+ &did_wait, |
+ &result, |
+ &context, |
+ &hss); |
stopwatch.Start(); |
thread.Start(); |
base::PlatformThread::Sleep(2 * test::EpsilonTimeout()); |
@@ -498,15 +546,18 @@ |
base::RandInt(1, static_cast<int>(kMaxMessageSize))); |
EXPECT_EQ(MOJO_RESULT_OK, |
write_dispatcher_->WriteMessage(UserPointer<const void>(buffer), |
- bytes_to_write, nullptr, |
+ bytes_to_write, |
+ nullptr, |
MOJO_WRITE_MESSAGE_FLAG_NONE)); |
*bytes_written_ += bytes_to_write; |
} |
// Write one last "quit" message. |
- EXPECT_EQ(MOJO_RESULT_OK, write_dispatcher_->WriteMessage( |
- UserPointer<const void>("quit"), 4, nullptr, |
- MOJO_WRITE_MESSAGE_FLAG_NONE)); |
+ EXPECT_EQ(MOJO_RESULT_OK, |
+ write_dispatcher_->WriteMessage(UserPointer<const void>("quit"), |
+ 4, |
+ nullptr, |
+ MOJO_WRITE_MESSAGE_FLAG_NONE)); |
} |
const scoped_refptr<Dispatcher> write_dispatcher_; |
@@ -561,9 +612,11 @@ |
// Clear the buffer so that we can check the result. |
memset(buffer, 0, sizeof(buffer)); |
uint32_t buffer_size = static_cast<uint32_t>(sizeof(buffer)); |
- result = read_dispatcher_->ReadMessage( |
- UserPointer<void>(buffer), MakeUserPointer(&buffer_size), 0, nullptr, |
- MOJO_READ_MESSAGE_FLAG_NONE); |
+ result = read_dispatcher_->ReadMessage(UserPointer<void>(buffer), |
+ MakeUserPointer(&buffer_size), |
+ 0, |
+ nullptr, |
+ MOJO_READ_MESSAGE_FLAG_NONE); |
EXPECT_TRUE(result == MOJO_RESULT_OK || result == MOJO_RESULT_SHOULD_WAIT) |
<< "result: " << result; |
// We're racing with others to read, so maybe we failed. |