| 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 // NOTE(vtl): Some of these tests are inherently flaky (e.g., if run on a | 5 // NOTE(vtl): Some of these tests are inherently flaky (e.g., if run on a |
| 6 // heavily-loaded system). Sorry. |kEpsilonMicros| may be increased to increase | 6 // heavily-loaded system). Sorry. |kEpsilonMicros| may be increased to increase |
| 7 // tolerance and reduce observed flakiness. | 7 // tolerance and reduce observed flakiness. |
| 8 | 8 |
| 9 #include "mojo/system/message_pipe_dispatcher.h" | 9 #include "mojo/system/message_pipe_dispatcher.h" |
| 10 | 10 |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 EXPECT_EQ(MOJO_RESULT_OK, | 204 EXPECT_EQ(MOJO_RESULT_OK, |
| 205 d_1->WriteMessage(buffer, kBufferSize, | 205 d_1->WriteMessage(buffer, kBufferSize, |
| 206 NULL, 0, | 206 NULL, 0, |
| 207 MOJO_WRITE_MESSAGE_FLAG_NONE)); | 207 MOJO_WRITE_MESSAGE_FLAG_NONE)); |
| 208 | 208 |
| 209 // Try waiting for readable on |d_0|; should fail (already satisfied). | 209 // Try waiting for readable on |d_0|; should fail (already satisfied). |
| 210 w.Init(); | 210 w.Init(); |
| 211 EXPECT_EQ(MOJO_RESULT_ALREADY_EXISTS, | 211 EXPECT_EQ(MOJO_RESULT_ALREADY_EXISTS, |
| 212 d_0->AddWaiter(&w, MOJO_WAIT_FLAG_READABLE, 0)); | 212 d_0->AddWaiter(&w, MOJO_WAIT_FLAG_READABLE, 0)); |
| 213 | 213 |
| 214 // Try reading from |d_1|; should fail (nothing to read). |
| 215 buffer[0] = 0; |
| 216 buffer_size = kBufferSize; |
| 217 EXPECT_EQ(MOJO_RESULT_NOT_FOUND, |
| 218 d_1->ReadMessage(buffer, &buffer_size, |
| 219 NULL, NULL, |
| 220 MOJO_READ_MESSAGE_FLAG_NONE)); |
| 221 |
| 214 // Close |d_1|. | 222 // Close |d_1|. |
| 215 EXPECT_EQ(MOJO_RESULT_OK, d_1->Close()); | 223 EXPECT_EQ(MOJO_RESULT_OK, d_1->Close()); |
| 216 | 224 |
| 217 // Try waiting for readable on |d_0|; should fail (already satisfied). | 225 // Try waiting for readable on |d_0|; should fail (already satisfied). |
| 218 w.Init(); | 226 w.Init(); |
| 219 EXPECT_EQ(MOJO_RESULT_ALREADY_EXISTS, | 227 EXPECT_EQ(MOJO_RESULT_ALREADY_EXISTS, |
| 220 d_0->AddWaiter(&w, MOJO_WAIT_FLAG_READABLE, 1)); | 228 d_0->AddWaiter(&w, MOJO_WAIT_FLAG_READABLE, 1)); |
| 221 | 229 |
| 222 // Read from |d_0|. | 230 // Read from |d_0|. |
| 223 buffer[0] = 0; | 231 buffer[0] = 0; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 247 // Try waiting for readable on |d_0|; should fail (unsatisfiable). | 255 // Try waiting for readable on |d_0|; should fail (unsatisfiable). |
| 248 w.Init(); | 256 w.Init(); |
| 249 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, | 257 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, |
| 250 d_0->AddWaiter(&w, MOJO_WAIT_FLAG_READABLE, 3)); | 258 d_0->AddWaiter(&w, MOJO_WAIT_FLAG_READABLE, 3)); |
| 251 | 259 |
| 252 // Try waiting for writable on |d_0|; should fail (unsatisfiable). | 260 // Try waiting for writable on |d_0|; should fail (unsatisfiable). |
| 253 w.Init(); | 261 w.Init(); |
| 254 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, | 262 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, |
| 255 d_0->AddWaiter(&w, MOJO_WAIT_FLAG_WRITABLE, 4)); | 263 d_0->AddWaiter(&w, MOJO_WAIT_FLAG_WRITABLE, 4)); |
| 256 | 264 |
| 257 // Try reading from |d_0|; should fail (nothing to read). | 265 // Try reading from |d_0|; should fail (nothing to read and other end |
| 266 // closed). |
| 258 buffer[0] = 0; | 267 buffer[0] = 0; |
| 259 buffer_size = kBufferSize; | 268 buffer_size = kBufferSize; |
| 260 EXPECT_EQ(MOJO_RESULT_NOT_FOUND, | 269 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, |
| 261 d_0->ReadMessage(buffer, &buffer_size, | 270 d_0->ReadMessage(buffer, &buffer_size, |
| 262 NULL, NULL, | 271 NULL, NULL, |
| 263 MOJO_READ_MESSAGE_FLAG_NONE)); | 272 MOJO_READ_MESSAGE_FLAG_NONE)); |
| 264 | 273 |
| 265 // Try writing to |d_0|; should fail (other end closed). | 274 // Try writing to |d_0|; should fail (other end closed). |
| 266 buffer[0] = 345678901; | 275 buffer[0] = 345678901; |
| 267 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, | 276 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, |
| 268 d_0->WriteMessage(buffer, kBufferSize, | 277 d_0->WriteMessage(buffer, kBufferSize, |
| 269 NULL, 0, | 278 NULL, 0, |
| 270 MOJO_WRITE_MESSAGE_FLAG_NONE)); | 279 MOJO_WRITE_MESSAGE_FLAG_NONE)); |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 EXPECT_EQ(total_messages_written, total_messages_read); | 605 EXPECT_EQ(total_messages_written, total_messages_read); |
| 597 EXPECT_EQ(total_bytes_written, total_bytes_read); | 606 EXPECT_EQ(total_bytes_written, total_bytes_read); |
| 598 | 607 |
| 599 EXPECT_EQ(MOJO_RESULT_OK, d_write->Close()); | 608 EXPECT_EQ(MOJO_RESULT_OK, d_write->Close()); |
| 600 EXPECT_EQ(MOJO_RESULT_OK, d_read->Close()); | 609 EXPECT_EQ(MOJO_RESULT_OK, d_read->Close()); |
| 601 } | 610 } |
| 602 | 611 |
| 603 } // namespace | 612 } // namespace |
| 604 } // namespace system | 613 } // namespace system |
| 605 } // namespace mojo | 614 } // namespace mojo |
| OLD | NEW |