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

Unified Diff: mojo/edk/system/message_pipe_unittest.cc

Issue 728043002: Revert of Update mojo sdk to rev afb4440fd5a10cba980878c326180b7ad7960480 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/edk/system/message_pipe_test_utils.cc ('k') | mojo/edk/system/multiprocess_message_pipe_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/message_pipe_unittest.cc
diff --git a/mojo/edk/system/message_pipe_unittest.cc b/mojo/edk/system/message_pipe_unittest.cc
index 030084b6ee5a3e7d08de1894e641b8ec2246b5b5..dbffb4c4e48b0eca3b370e6c4f480b29b7e09107 100644
--- a/mojo/edk/system/message_pipe_unittest.cc
+++ b/mojo/edk/system/message_pipe_unittest.cc
@@ -39,8 +39,11 @@
buffer[1] = 456;
buffer_size = kBufferSize;
EXPECT_EQ(MOJO_RESULT_SHOULD_WAIT,
- mp->ReadMessage(0, UserPointer<void>(buffer),
- MakeUserPointer(&buffer_size), 0, nullptr,
+ mp->ReadMessage(0,
+ UserPointer<void>(buffer),
+ MakeUserPointer(&buffer_size),
+ 0,
+ nullptr,
MOJO_READ_MESSAGE_FLAG_NONE));
EXPECT_EQ(kBufferSize, buffer_size);
EXPECT_EQ(123, buffer[0]);
@@ -51,16 +54,21 @@
buffer[1] = 456;
buffer_size = kBufferSize;
EXPECT_EQ(MOJO_RESULT_SHOULD_WAIT,
- mp->ReadMessage(1, UserPointer<void>(buffer),
- MakeUserPointer(&buffer_size), 0, nullptr,
+ mp->ReadMessage(1,
+ UserPointer<void>(buffer),
+ MakeUserPointer(&buffer_size),
+ 0,
+ nullptr,
MOJO_READ_MESSAGE_FLAG_NONE));
// Write from port 1 (to port 0).
buffer[0] = 789012345;
buffer[1] = 0;
EXPECT_EQ(MOJO_RESULT_OK,
- mp->WriteMessage(1, UserPointer<const void>(buffer),
- static_cast<uint32_t>(sizeof(buffer[0])), nullptr,
+ mp->WriteMessage(1,
+ UserPointer<const void>(buffer),
+ static_cast<uint32_t>(sizeof(buffer[0])),
+ nullptr,
MOJO_WRITE_MESSAGE_FLAG_NONE));
// Read from port 0.
@@ -68,8 +76,11 @@
buffer[1] = 456;
buffer_size = kBufferSize;
EXPECT_EQ(MOJO_RESULT_OK,
- mp->ReadMessage(0, UserPointer<void>(buffer),
- MakeUserPointer(&buffer_size), 0, nullptr,
+ mp->ReadMessage(0,
+ UserPointer<void>(buffer),
+ MakeUserPointer(&buffer_size),
+ 0,
+ nullptr,
MOJO_READ_MESSAGE_FLAG_NONE));
EXPECT_EQ(static_cast<uint32_t>(sizeof(buffer[0])), buffer_size);
EXPECT_EQ(789012345, buffer[0]);
@@ -78,30 +89,41 @@
// Read again from port 0 -- it should be empty.
buffer_size = kBufferSize;
EXPECT_EQ(MOJO_RESULT_SHOULD_WAIT,
- mp->ReadMessage(0, UserPointer<void>(buffer),
- MakeUserPointer(&buffer_size), 0, nullptr,
+ mp->ReadMessage(0,
+ UserPointer<void>(buffer),
+ MakeUserPointer(&buffer_size),
+ 0,
+ nullptr,
MOJO_READ_MESSAGE_FLAG_NONE));
// Write two messages from port 0 (to port 1).
buffer[0] = 123456789;
buffer[1] = 0;
EXPECT_EQ(MOJO_RESULT_OK,
- mp->WriteMessage(0, UserPointer<const void>(buffer),
- static_cast<uint32_t>(sizeof(buffer[0])), nullptr,
+ mp->WriteMessage(0,
+ UserPointer<const void>(buffer),
+ static_cast<uint32_t>(sizeof(buffer[0])),
+ nullptr,
MOJO_WRITE_MESSAGE_FLAG_NONE));
buffer[0] = 234567890;
buffer[1] = 0;
EXPECT_EQ(MOJO_RESULT_OK,
- mp->WriteMessage(0, UserPointer<const void>(buffer),
- static_cast<uint32_t>(sizeof(buffer[0])), nullptr,
+ mp->WriteMessage(0,
+ UserPointer<const void>(buffer),
+ static_cast<uint32_t>(sizeof(buffer[0])),
+ nullptr,
MOJO_WRITE_MESSAGE_FLAG_NONE));
// Read from port 1 with buffer size 0 (should get the size of next message).
// Also test that giving a null buffer is okay when the buffer size is 0.
buffer_size = 0;
EXPECT_EQ(MOJO_RESULT_RESOURCE_EXHAUSTED,
- mp->ReadMessage(1, NullUserPointer(), MakeUserPointer(&buffer_size),
- 0, nullptr, MOJO_READ_MESSAGE_FLAG_NONE));
+ mp->ReadMessage(1,
+ NullUserPointer(),
+ MakeUserPointer(&buffer_size),
+ 0,
+ nullptr,
+ MOJO_READ_MESSAGE_FLAG_NONE));
EXPECT_EQ(static_cast<uint32_t>(sizeof(buffer[0])), buffer_size);
// Read from port 1 with buffer size 1 (too small; should get the size of next
@@ -110,8 +132,11 @@
buffer[1] = 456;
buffer_size = 1;
EXPECT_EQ(MOJO_RESULT_RESOURCE_EXHAUSTED,
- mp->ReadMessage(1, UserPointer<void>(buffer),
- MakeUserPointer(&buffer_size), 0, nullptr,
+ mp->ReadMessage(1,
+ UserPointer<void>(buffer),
+ MakeUserPointer(&buffer_size),
+ 0,
+ nullptr,
MOJO_READ_MESSAGE_FLAG_NONE));
EXPECT_EQ(static_cast<uint32_t>(sizeof(buffer[0])), buffer_size);
EXPECT_EQ(123, buffer[0]);
@@ -122,8 +147,11 @@
buffer[1] = 456;
buffer_size = kBufferSize;
EXPECT_EQ(MOJO_RESULT_OK,
- mp->ReadMessage(1, UserPointer<void>(buffer),
- MakeUserPointer(&buffer_size), 0, nullptr,
+ mp->ReadMessage(1,
+ UserPointer<void>(buffer),
+ MakeUserPointer(&buffer_size),
+ 0,
+ nullptr,
MOJO_READ_MESSAGE_FLAG_NONE));
EXPECT_EQ(static_cast<uint32_t>(sizeof(buffer[0])), buffer_size);
EXPECT_EQ(123456789, buffer[0]);
@@ -134,8 +162,11 @@
buffer[1] = 456;
buffer_size = kBufferSize;
EXPECT_EQ(MOJO_RESULT_OK,
- mp->ReadMessage(1, UserPointer<void>(buffer),
- MakeUserPointer(&buffer_size), 0, nullptr,
+ mp->ReadMessage(1,
+ UserPointer<void>(buffer),
+ MakeUserPointer(&buffer_size),
+ 0,
+ nullptr,
MOJO_READ_MESSAGE_FLAG_NONE));
EXPECT_EQ(static_cast<uint32_t>(sizeof(buffer[0])), buffer_size);
EXPECT_EQ(234567890, buffer[0]);
@@ -144,16 +175,21 @@
// Read again from port 1 -- it should be empty.
buffer_size = kBufferSize;
EXPECT_EQ(MOJO_RESULT_SHOULD_WAIT,
- mp->ReadMessage(1, UserPointer<void>(buffer),
- MakeUserPointer(&buffer_size), 0, nullptr,
+ mp->ReadMessage(1,
+ UserPointer<void>(buffer),
+ MakeUserPointer(&buffer_size),
+ 0,
+ nullptr,
MOJO_READ_MESSAGE_FLAG_NONE));
// Write from port 0 (to port 1).
buffer[0] = 345678901;
buffer[1] = 0;
EXPECT_EQ(MOJO_RESULT_OK,
- mp->WriteMessage(0, UserPointer<const void>(buffer),
- static_cast<uint32_t>(sizeof(buffer[0])), nullptr,
+ mp->WriteMessage(0,
+ UserPointer<const void>(buffer),
+ static_cast<uint32_t>(sizeof(buffer[0])),
+ nullptr,
MOJO_WRITE_MESSAGE_FLAG_NONE));
// Close port 0.
@@ -163,8 +199,10 @@
buffer[0] = 456789012;
buffer[1] = 0;
EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION,
- mp->WriteMessage(1, UserPointer<const void>(buffer),
- static_cast<uint32_t>(sizeof(buffer[0])), nullptr,
+ mp->WriteMessage(1,
+ UserPointer<const void>(buffer),
+ static_cast<uint32_t>(sizeof(buffer[0])),
+ nullptr,
MOJO_WRITE_MESSAGE_FLAG_NONE));
// Read from port 1; should still get message (even though port 0 was closed).
@@ -172,8 +210,11 @@
buffer[1] = 456;
buffer_size = kBufferSize;
EXPECT_EQ(MOJO_RESULT_OK,
- mp->ReadMessage(1, UserPointer<void>(buffer),
- MakeUserPointer(&buffer_size), 0, nullptr,
+ mp->ReadMessage(1,
+ UserPointer<void>(buffer),
+ MakeUserPointer(&buffer_size),
+ 0,
+ nullptr,
MOJO_READ_MESSAGE_FLAG_NONE));
EXPECT_EQ(static_cast<uint32_t>(sizeof(buffer[0])), buffer_size);
EXPECT_EQ(345678901, buffer[0]);
@@ -182,8 +223,11 @@
// Read again from port 1 -- it should be empty (and port 0 is closed).
buffer_size = kBufferSize;
EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION,
- mp->ReadMessage(1, UserPointer<void>(buffer),
- MakeUserPointer(&buffer_size), 0, nullptr,
+ mp->ReadMessage(1,
+ UserPointer<void>(buffer),
+ MakeUserPointer(&buffer_size),
+ 0,
+ nullptr,
MOJO_READ_MESSAGE_FLAG_NONE));
mp->Close(1);
@@ -200,15 +244,22 @@
for (int32_t i = 0; i < 5; i++) {
buffer[0] = i;
EXPECT_EQ(MOJO_RESULT_OK,
- mp->WriteMessage(1, UserPointer<const void>(buffer), kBufferSize,
- nullptr, MOJO_WRITE_MESSAGE_FLAG_NONE));
+ mp->WriteMessage(1,
+ UserPointer<const void>(buffer),
+ kBufferSize,
+ nullptr,
+ MOJO_WRITE_MESSAGE_FLAG_NONE));
}
// Port 0 shouldn't be empty.
buffer_size = 0;
EXPECT_EQ(MOJO_RESULT_RESOURCE_EXHAUSTED,
- mp->ReadMessage(0, NullUserPointer(), MakeUserPointer(&buffer_size),
- 0, nullptr, MOJO_READ_MESSAGE_FLAG_NONE));
+ mp->ReadMessage(0,
+ NullUserPointer(),
+ MakeUserPointer(&buffer_size),
+ 0,
+ nullptr,
+ MOJO_READ_MESSAGE_FLAG_NONE));
EXPECT_EQ(kBufferSize, buffer_size);
// Close port 0 first, which should have outstanding (incoming) messages.
@@ -227,30 +278,41 @@
buffer[0] = 789012345;
buffer[1] = 0;
EXPECT_EQ(MOJO_RESULT_OK,
- mp->WriteMessage(1, UserPointer<const void>(buffer),
- static_cast<uint32_t>(sizeof(buffer[0])), nullptr,
+ mp->WriteMessage(1,
+ UserPointer<const void>(buffer),
+ static_cast<uint32_t>(sizeof(buffer[0])),
+ nullptr,
MOJO_WRITE_MESSAGE_FLAG_NONE));
// Read/discard from port 0 (no buffer); get size.
buffer_size = 0;
EXPECT_EQ(MOJO_RESULT_RESOURCE_EXHAUSTED,
- mp->ReadMessage(0, NullUserPointer(), MakeUserPointer(&buffer_size),
- 0, nullptr, MOJO_READ_MESSAGE_FLAG_MAY_DISCARD));
+ mp->ReadMessage(0,
+ NullUserPointer(),
+ MakeUserPointer(&buffer_size),
+ 0,
+ nullptr,
+ MOJO_READ_MESSAGE_FLAG_MAY_DISCARD));
EXPECT_EQ(static_cast<uint32_t>(sizeof(buffer[0])), buffer_size);
// Read again from port 0 -- it should be empty.
buffer_size = kBufferSize;
EXPECT_EQ(MOJO_RESULT_SHOULD_WAIT,
- mp->ReadMessage(0, UserPointer<void>(buffer),
- MakeUserPointer(&buffer_size), 0, nullptr,
+ mp->ReadMessage(0,
+ UserPointer<void>(buffer),
+ MakeUserPointer(&buffer_size),
+ 0,
+ nullptr,
MOJO_READ_MESSAGE_FLAG_MAY_DISCARD));
// Write from port 1 (to port 0).
buffer[0] = 890123456;
buffer[1] = 0;
EXPECT_EQ(MOJO_RESULT_OK,
- mp->WriteMessage(1, UserPointer<const void>(buffer),
- static_cast<uint32_t>(sizeof(buffer[0])), nullptr,
+ mp->WriteMessage(1,
+ UserPointer<const void>(buffer),
+ static_cast<uint32_t>(sizeof(buffer[0])),
+ nullptr,
MOJO_WRITE_MESSAGE_FLAG_NONE));
// Read from port 0 (buffer big enough).
@@ -258,8 +320,11 @@
buffer[1] = 456;
buffer_size = kBufferSize;
EXPECT_EQ(MOJO_RESULT_OK,
- mp->ReadMessage(0, UserPointer<void>(buffer),
- MakeUserPointer(&buffer_size), 0, nullptr,
+ mp->ReadMessage(0,
+ UserPointer<void>(buffer),
+ MakeUserPointer(&buffer_size),
+ 0,
+ nullptr,
MOJO_READ_MESSAGE_FLAG_MAY_DISCARD));
EXPECT_EQ(static_cast<uint32_t>(sizeof(buffer[0])), buffer_size);
EXPECT_EQ(890123456, buffer[0]);
@@ -268,52 +333,72 @@
// Read again from port 0 -- it should be empty.
buffer_size = kBufferSize;
EXPECT_EQ(MOJO_RESULT_SHOULD_WAIT,
- mp->ReadMessage(0, UserPointer<void>(buffer),
- MakeUserPointer(&buffer_size), 0, nullptr,
+ mp->ReadMessage(0,
+ UserPointer<void>(buffer),
+ MakeUserPointer(&buffer_size),
+ 0,
+ nullptr,
MOJO_READ_MESSAGE_FLAG_MAY_DISCARD));
// Write from port 1 (to port 0).
buffer[0] = 901234567;
buffer[1] = 0;
EXPECT_EQ(MOJO_RESULT_OK,
- mp->WriteMessage(1, UserPointer<const void>(buffer),
- static_cast<uint32_t>(sizeof(buffer[0])), nullptr,
+ mp->WriteMessage(1,
+ UserPointer<const void>(buffer),
+ static_cast<uint32_t>(sizeof(buffer[0])),
+ nullptr,
MOJO_WRITE_MESSAGE_FLAG_NONE));
// Read/discard from port 0 (buffer too small); get size.
buffer_size = 1;
EXPECT_EQ(MOJO_RESULT_RESOURCE_EXHAUSTED,
- mp->ReadMessage(0, UserPointer<void>(buffer),
- MakeUserPointer(&buffer_size), 0, nullptr,
+ mp->ReadMessage(0,
+ UserPointer<void>(buffer),
+ MakeUserPointer(&buffer_size),
+ 0,
+ nullptr,
MOJO_READ_MESSAGE_FLAG_MAY_DISCARD));
EXPECT_EQ(static_cast<uint32_t>(sizeof(buffer[0])), buffer_size);
// Read again from port 0 -- it should be empty.
buffer_size = kBufferSize;
EXPECT_EQ(MOJO_RESULT_SHOULD_WAIT,
- mp->ReadMessage(0, UserPointer<void>(buffer),
- MakeUserPointer(&buffer_size), 0, nullptr,
+ mp->ReadMessage(0,
+ UserPointer<void>(buffer),
+ MakeUserPointer(&buffer_size),
+ 0,
+ nullptr,
MOJO_READ_MESSAGE_FLAG_MAY_DISCARD));
// Write from port 1 (to port 0).
buffer[0] = 123456789;
buffer[1] = 0;
EXPECT_EQ(MOJO_RESULT_OK,
- mp->WriteMessage(1, UserPointer<const void>(buffer),
- static_cast<uint32_t>(sizeof(buffer[0])), nullptr,
+ mp->WriteMessage(1,
+ UserPointer<const void>(buffer),
+ static_cast<uint32_t>(sizeof(buffer[0])),
+ nullptr,
MOJO_WRITE_MESSAGE_FLAG_NONE));
// Discard from port 0.
buffer_size = 1;
EXPECT_EQ(MOJO_RESULT_RESOURCE_EXHAUSTED,
- mp->ReadMessage(0, NullUserPointer(), NullUserPointer(), 0, nullptr,
+ mp->ReadMessage(0,
+ NullUserPointer(),
+ NullUserPointer(),
+ 0,
+ nullptr,
MOJO_READ_MESSAGE_FLAG_MAY_DISCARD));
// Read again from port 0 -- it should be empty.
buffer_size = kBufferSize;
EXPECT_EQ(MOJO_RESULT_SHOULD_WAIT,
- mp->ReadMessage(0, UserPointer<void>(buffer),
- MakeUserPointer(&buffer_size), 0, nullptr,
+ mp->ReadMessage(0,
+ UserPointer<void>(buffer),
+ MakeUserPointer(&buffer_size),
+ 0,
+ nullptr,
MOJO_READ_MESSAGE_FLAG_MAY_DISCARD));
mp->Close(0);
@@ -339,10 +424,13 @@
hss.satisfiable_signals);
waiter.Init();
hss = HandleSignalsState();
- EXPECT_EQ(MOJO_RESULT_ALREADY_EXISTS,
- mp->AddWaiter(0, &waiter, MOJO_HANDLE_SIGNAL_READABLE |
- MOJO_HANDLE_SIGNAL_WRITABLE,
- 0, &hss));
+ EXPECT_EQ(
+ MOJO_RESULT_ALREADY_EXISTS,
+ mp->AddWaiter(0,
+ &waiter,
+ MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_WRITABLE,
+ 0,
+ &hss));
EXPECT_EQ(MOJO_HANDLE_SIGNAL_WRITABLE, hss.satisfied_signals);
EXPECT_EQ(MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_WRITABLE,
hss.satisfiable_signals);
@@ -361,8 +449,11 @@
// Write from port 0 (to port 1), to make port 1 readable.
buffer[0] = 123456789;
EXPECT_EQ(MOJO_RESULT_OK,
- mp->WriteMessage(0, UserPointer<const void>(buffer), kBufferSize,
- nullptr, MOJO_WRITE_MESSAGE_FLAG_NONE));
+ mp->WriteMessage(0,
+ UserPointer<const void>(buffer),
+ kBufferSize,
+ nullptr,
+ MOJO_WRITE_MESSAGE_FLAG_NONE));
// Port 1 should already be readable now.
waiter.Init();
@@ -375,10 +466,13 @@
hss.satisfiable_signals);
waiter.Init();
hss = HandleSignalsState();
- EXPECT_EQ(MOJO_RESULT_ALREADY_EXISTS,
- mp->AddWaiter(1, &waiter, MOJO_HANDLE_SIGNAL_READABLE |
- MOJO_HANDLE_SIGNAL_WRITABLE,
- 0, &hss));
+ EXPECT_EQ(
+ MOJO_RESULT_ALREADY_EXISTS,
+ mp->AddWaiter(1,
+ &waiter,
+ MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_WRITABLE,
+ 0,
+ &hss));
EXPECT_EQ(MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_WRITABLE,
hss.satisfied_signals);
EXPECT_EQ(MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_WRITABLE,
@@ -416,8 +510,11 @@
buffer[0] = 0;
buffer_size = kBufferSize;
EXPECT_EQ(MOJO_RESULT_OK,
- mp->ReadMessage(1, UserPointer<void>(buffer),
- MakeUserPointer(&buffer_size), 0, nullptr,
+ mp->ReadMessage(1,
+ UserPointer<void>(buffer),
+ MakeUserPointer(&buffer_size),
+ 0,
+ nullptr,
MOJO_READ_MESSAGE_FLAG_NONE));
EXPECT_EQ(123456789, buffer[0]);
@@ -446,15 +543,18 @@
thread.waiter()->Init();
ASSERT_EQ(MOJO_RESULT_OK,
- mp->AddWaiter(1, thread.waiter(), MOJO_HANDLE_SIGNAL_READABLE, 1,
- nullptr));
+ mp->AddWaiter(
+ 1, thread.waiter(), MOJO_HANDLE_SIGNAL_READABLE, 1, nullptr));
thread.Start();
buffer[0] = 123456789;
// Write from port 0 (to port 1), which should wake up the waiter.
EXPECT_EQ(MOJO_RESULT_OK,
- mp->WriteMessage(0, UserPointer<const void>(buffer), kBufferSize,
- nullptr, MOJO_WRITE_MESSAGE_FLAG_NONE));
+ mp->WriteMessage(0,
+ UserPointer<const void>(buffer),
+ kBufferSize,
+ nullptr,
+ MOJO_WRITE_MESSAGE_FLAG_NONE));
HandleSignalsState hss;
mp->RemoveWaiter(1, thread.waiter(), &hss);
@@ -477,8 +577,8 @@
thread.waiter()->Init();
ASSERT_EQ(MOJO_RESULT_OK,
- mp->AddWaiter(1, thread.waiter(), MOJO_HANDLE_SIGNAL_READABLE, 2,
- nullptr));
+ mp->AddWaiter(
+ 1, thread.waiter(), MOJO_HANDLE_SIGNAL_READABLE, 2, nullptr));
thread.Start();
// Close port 1 first -- this should result in the waiter being cancelled.
@@ -500,8 +600,8 @@
thread.waiter()->Init();
ASSERT_EQ(MOJO_RESULT_OK,
- mp->AddWaiter(1, thread.waiter(), MOJO_HANDLE_SIGNAL_READABLE, 3,
- nullptr));
+ mp->AddWaiter(
+ 1, thread.waiter(), MOJO_HANDLE_SIGNAL_READABLE, 3, nullptr));
thread.Start();
// Close port 0 first -- this should wake the waiter up, since port 1 will
« no previous file with comments | « mojo/edk/system/message_pipe_test_utils.cc ('k') | mojo/edk/system/multiprocess_message_pipe_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698