| Index: mojo/edk/system/core_unittest.cc
|
| diff --git a/mojo/edk/system/core_unittest.cc b/mojo/edk/system/core_unittest.cc
|
| index 7eeabc03e2fc0b26ea6a522427064b6facb22068..b180b5574ee396582b5d763484c9b04d3af2d2f6 100644
|
| --- a/mojo/edk/system/core_unittest.cc
|
| +++ b/mojo/edk/system/core_unittest.cc
|
| @@ -327,6 +327,18 @@ TEST_F(CoreTest, InvalidArguments) {
|
| MOJO_WRITE_MESSAGE_FLAG_NONE));
|
| ASSERT_EQ(0u, info.GetWriteMessageCallCount());
|
|
|
| + // Null |bytes| with non-zero message size.
|
| + ASSERT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
|
| + core()->WriteMessage(h, nullptr, 1, nullptr, 0,
|
| + MOJO_WRITE_MESSAGE_FLAG_NONE));
|
| + ASSERT_EQ(0u, info.GetWriteMessageCallCount());
|
| +
|
| + // Null |handles| with non-zero handle count.
|
| + ASSERT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
|
| + core()->WriteMessage(h, nullptr, 0, nullptr, 1,
|
| + MOJO_WRITE_MESSAGE_FLAG_NONE));
|
| + ASSERT_EQ(0u, info.GetWriteMessageCallCount());
|
| +
|
| // Huge handle count (plausibly big).
|
| ASSERT_EQ(MOJO_RESULT_RESOURCE_EXHAUSTED,
|
| core()->WriteMessage(
|
| @@ -349,19 +361,21 @@ TEST_F(CoreTest, InvalidArguments) {
|
| MOJO_WRITE_MESSAGE_FLAG_NONE));
|
| ASSERT_EQ(0u, info.GetWriteMessageCallCount());
|
|
|
| - // Can't send a handle over itself.
|
| + // Can't send a handle over itself. Note that this will also cause |h| to be
|
| + // closed.
|
| handles[0] = h;
|
| ASSERT_EQ(
|
| - MOJO_RESULT_BUSY,
|
| + MOJO_RESULT_INVALID_ARGUMENT,
|
| core()->WriteMessage(h, nullptr, 0, handles, 1,
|
| MOJO_WRITE_MESSAGE_FLAG_NONE));
|
| ASSERT_EQ(0u, info.GetWriteMessageCallCount());
|
|
|
| + h = CreateMockHandle(&info);
|
| +
|
| MockHandleInfo info2;
|
| - MojoHandle h2 = CreateMockHandle(&info2);
|
|
|
| // This is "okay", but |MockDispatcher| doesn't implement it.
|
| - handles[0] = h2;
|
| + handles[0] = CreateMockHandle(&info2);
|
| ASSERT_EQ(
|
| MOJO_RESULT_UNIMPLEMENTED,
|
| core()->WriteMessage(h, nullptr, 0, handles, 1,
|
| @@ -369,32 +383,33 @@ TEST_F(CoreTest, InvalidArguments) {
|
| ASSERT_EQ(1u, info.GetWriteMessageCallCount());
|
|
|
| // One of the |handles| is still invalid.
|
| + handles[0] = CreateMockHandle(&info2);
|
| ASSERT_EQ(
|
| MOJO_RESULT_INVALID_ARGUMENT,
|
| core()->WriteMessage(h, nullptr, 0, handles, 2,
|
| MOJO_WRITE_MESSAGE_FLAG_NONE));
|
| ASSERT_EQ(1u, info.GetWriteMessageCallCount());
|
|
|
| - // One of the |handles| is the same as |handle|.
|
| + // One of the |handles| is the same as |h|. Both handles are closed.
|
| + handles[0] = CreateMockHandle(&info2);
|
| handles[1] = h;
|
| ASSERT_EQ(
|
| - MOJO_RESULT_BUSY,
|
| + MOJO_RESULT_INVALID_ARGUMENT,
|
| core()->WriteMessage(h, nullptr, 0, handles, 2,
|
| MOJO_WRITE_MESSAGE_FLAG_NONE));
|
| ASSERT_EQ(1u, info.GetWriteMessageCallCount());
|
|
|
| + h = CreateMockHandle(&info);
|
| +
|
| // Can't send a handle twice in the same message.
|
| - handles[1] = h2;
|
| + handles[0] = CreateMockHandle(&info2);
|
| + handles[1] = handles[0];
|
| ASSERT_EQ(
|
| MOJO_RESULT_BUSY,
|
| core()->WriteMessage(h, nullptr, 0, handles, 2,
|
| MOJO_WRITE_MESSAGE_FLAG_NONE));
|
| ASSERT_EQ(1u, info.GetWriteMessageCallCount());
|
|
|
| - // Note: Since we never successfully sent anything with it, |h2| should
|
| - // still be valid.
|
| - ASSERT_EQ(MOJO_RESULT_OK, core()->Close(h2));
|
| -
|
| ASSERT_EQ(MOJO_RESULT_OK, core()->Close(h));
|
| }
|
|
|
| @@ -462,22 +477,6 @@ TEST_F(CoreTest, InvalidArgumentsDeath) {
|
| kMemoryCheckFailedRegex);
|
| }
|
|
|
| - // |WriteMessage()|:
|
| - // Only check arguments checked by |Core|, namely |handle|, |handles|, and
|
| - // |num_handles|.
|
| - {
|
| - MockHandleInfo info;
|
| - MojoHandle h = CreateMockHandle(&info);
|
| -
|
| - // Null |handles| with nonzero |num_handles|.
|
| - ASSERT_DEATH_IF_SUPPORTED(
|
| - core()->WriteMessage(h, nullptr, 0, nullptr, 1,
|
| - MOJO_WRITE_MESSAGE_FLAG_NONE),
|
| - kMemoryCheckFailedRegex);
|
| -
|
| - ASSERT_EQ(MOJO_RESULT_OK, core()->Close(h));
|
| - }
|
| -
|
| // |ReadMessage()|:
|
| // Only check arguments checked by |Core|, namely |handle|, |handles|, and
|
| // |num_handles|.
|
| @@ -711,14 +710,19 @@ TEST_F(CoreTest, MessagePipeBasicLocalHandlePassing1) {
|
|
|
| // Make sure that you can't pass either of the message pipe's handles over
|
| // itself.
|
| - ASSERT_EQ(MOJO_RESULT_BUSY,
|
| + ASSERT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
|
| core()->WriteMessage(h_passing[0], kHello, kHelloSize,
|
| &h_passing[0], 1,
|
| MOJO_WRITE_MESSAGE_FLAG_NONE));
|
| + ASSERT_EQ(MOJO_RESULT_OK,
|
| + core()->CreateMessagePipe(nullptr, &h_passing[0], &h_passing[1]));
|
| +
|
| ASSERT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
|
| core()->WriteMessage(h_passing[0], kHello, kHelloSize,
|
| &h_passing[1], 1,
|
| MOJO_WRITE_MESSAGE_FLAG_NONE));
|
| + ASSERT_EQ(MOJO_RESULT_OK,
|
| + core()->CreateMessagePipe(nullptr, &h_passing[0], &h_passing[1]));
|
|
|
| MojoHandle h_passed[2];
|
| MojoCreateMessagePipeOptions options;
|
|
|