| 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 #include <stdint.h> | 5 #include <stdint.h> |
| 6 #include <stdio.h> | 6 #include <stdio.h> |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 } else { | 68 } else { |
| 69 CHECK((hss.satisfied_signals & MOJO_HANDLE_SIGNAL_READABLE)); | 69 CHECK((hss.satisfied_signals & MOJO_HANDLE_SIGNAL_READABLE)); |
| 70 CHECK((hss.satisfiable_signals & MOJO_HANDLE_SIGNAL_READABLE)); | 70 CHECK((hss.satisfiable_signals & MOJO_HANDLE_SIGNAL_READABLE)); |
| 71 } | 71 } |
| 72 | 72 |
| 73 std::string read_buffer(1000, '\0'); | 73 std::string read_buffer(1000, '\0'); |
| 74 uint32_t read_buffer_size = static_cast<uint32_t>(read_buffer.size()); | 74 uint32_t read_buffer_size = static_cast<uint32_t>(read_buffer.size()); |
| 75 CHECK_EQ(mp->ReadMessage(0, | 75 CHECK_EQ(mp->ReadMessage(0, |
| 76 UserPointer<void>(&read_buffer[0]), | 76 UserPointer<void>(&read_buffer[0]), |
| 77 MakeUserPointer(&read_buffer_size), | 77 MakeUserPointer(&read_buffer_size), |
| 78 NULL, | 78 nullptr, |
| 79 NULL, | 79 nullptr, |
| 80 MOJO_READ_MESSAGE_FLAG_NONE), | 80 MOJO_READ_MESSAGE_FLAG_NONE), |
| 81 MOJO_RESULT_OK); | 81 MOJO_RESULT_OK); |
| 82 read_buffer.resize(read_buffer_size); | 82 read_buffer.resize(read_buffer_size); |
| 83 VLOG(2) << "Child got: " << read_buffer; | 83 VLOG(2) << "Child got: " << read_buffer; |
| 84 | 84 |
| 85 if (read_buffer == quitquitquit) { | 85 if (read_buffer == quitquitquit) { |
| 86 VLOG(2) << "Child quitting."; | 86 VLOG(2) << "Child quitting."; |
| 87 break; | 87 break; |
| 88 } | 88 } |
| 89 | 89 |
| 90 std::string write_buffer = read_buffer + read_buffer; | 90 std::string write_buffer = read_buffer + read_buffer; |
| 91 CHECK_EQ(mp->WriteMessage(0, | 91 CHECK_EQ(mp->WriteMessage(0, |
| 92 UserPointer<const void>(write_buffer.data()), | 92 UserPointer<const void>(write_buffer.data()), |
| 93 static_cast<uint32_t>(write_buffer.size()), | 93 static_cast<uint32_t>(write_buffer.size()), |
| 94 NULL, | 94 nullptr, |
| 95 MOJO_WRITE_MESSAGE_FLAG_NONE), | 95 MOJO_WRITE_MESSAGE_FLAG_NONE), |
| 96 MOJO_RESULT_OK); | 96 MOJO_RESULT_OK); |
| 97 } | 97 } |
| 98 | 98 |
| 99 mp->Close(0); | 99 mp->Close(0); |
| 100 return rv; | 100 return rv; |
| 101 } | 101 } |
| 102 | 102 |
| 103 // Sends "hello" to child, and expects "hellohello" back. | 103 // Sends "hello" to child, and expects "hellohello" back. |
| 104 TEST_F(MultiprocessMessagePipeTest, Basic) { | 104 TEST_F(MultiprocessMessagePipeTest, Basic) { |
| 105 helper()->StartChild("EchoEcho"); | 105 helper()->StartChild("EchoEcho"); |
| 106 | 106 |
| 107 scoped_refptr<ChannelEndpoint> ep; | 107 scoped_refptr<ChannelEndpoint> ep; |
| 108 scoped_refptr<MessagePipe> mp(MessagePipe::CreateLocalProxy(&ep)); | 108 scoped_refptr<MessagePipe> mp(MessagePipe::CreateLocalProxy(&ep)); |
| 109 Init(ep); | 109 Init(ep); |
| 110 | 110 |
| 111 std::string hello("hello"); | 111 std::string hello("hello"); |
| 112 EXPECT_EQ(MOJO_RESULT_OK, | 112 EXPECT_EQ(MOJO_RESULT_OK, |
| 113 mp->WriteMessage(0, | 113 mp->WriteMessage(0, |
| 114 UserPointer<const void>(hello.data()), | 114 UserPointer<const void>(hello.data()), |
| 115 static_cast<uint32_t>(hello.size()), | 115 static_cast<uint32_t>(hello.size()), |
| 116 NULL, | 116 nullptr, |
| 117 MOJO_WRITE_MESSAGE_FLAG_NONE)); | 117 MOJO_WRITE_MESSAGE_FLAG_NONE)); |
| 118 | 118 |
| 119 HandleSignalsState hss; | 119 HandleSignalsState hss; |
| 120 EXPECT_EQ(MOJO_RESULT_OK, | 120 EXPECT_EQ(MOJO_RESULT_OK, |
| 121 test::WaitIfNecessary(mp, MOJO_HANDLE_SIGNAL_READABLE, &hss)); | 121 test::WaitIfNecessary(mp, MOJO_HANDLE_SIGNAL_READABLE, &hss)); |
| 122 // The child may or may not have closed its end of the message pipe and died | 122 // The child may or may not have closed its end of the message pipe and died |
| 123 // (and we may or may not know it yet), so our end may or may not appear as | 123 // (and we may or may not know it yet), so our end may or may not appear as |
| 124 // writable. | 124 // writable. |
| 125 EXPECT_TRUE((hss.satisfied_signals & MOJO_HANDLE_SIGNAL_READABLE)); | 125 EXPECT_TRUE((hss.satisfied_signals & MOJO_HANDLE_SIGNAL_READABLE)); |
| 126 EXPECT_TRUE((hss.satisfiable_signals & MOJO_HANDLE_SIGNAL_READABLE)); | 126 EXPECT_TRUE((hss.satisfiable_signals & MOJO_HANDLE_SIGNAL_READABLE)); |
| 127 | 127 |
| 128 std::string read_buffer(1000, '\0'); | 128 std::string read_buffer(1000, '\0'); |
| 129 uint32_t read_buffer_size = static_cast<uint32_t>(read_buffer.size()); | 129 uint32_t read_buffer_size = static_cast<uint32_t>(read_buffer.size()); |
| 130 CHECK_EQ(mp->ReadMessage(0, | 130 CHECK_EQ(mp->ReadMessage(0, |
| 131 UserPointer<void>(&read_buffer[0]), | 131 UserPointer<void>(&read_buffer[0]), |
| 132 MakeUserPointer(&read_buffer_size), | 132 MakeUserPointer(&read_buffer_size), |
| 133 NULL, | 133 nullptr, |
| 134 NULL, | 134 nullptr, |
| 135 MOJO_READ_MESSAGE_FLAG_NONE), | 135 MOJO_READ_MESSAGE_FLAG_NONE), |
| 136 MOJO_RESULT_OK); | 136 MOJO_RESULT_OK); |
| 137 read_buffer.resize(read_buffer_size); | 137 read_buffer.resize(read_buffer_size); |
| 138 VLOG(2) << "Parent got: " << read_buffer; | 138 VLOG(2) << "Parent got: " << read_buffer; |
| 139 EXPECT_EQ(hello + hello, read_buffer); | 139 EXPECT_EQ(hello + hello, read_buffer); |
| 140 | 140 |
| 141 mp->Close(0); | 141 mp->Close(0); |
| 142 | 142 |
| 143 // We sent one message. | 143 // We sent one message. |
| 144 EXPECT_EQ(1 % 100, helper()->WaitForChildShutdown()); | 144 EXPECT_EQ(1 % 100, helper()->WaitForChildShutdown()); |
| 145 } | 145 } |
| 146 | 146 |
| 147 // Sends a bunch of messages to the child. Expects them "repeated" back. Waits | 147 // Sends a bunch of messages to the child. Expects them "repeated" back. Waits |
| 148 // for the child to close its end before quitting. | 148 // for the child to close its end before quitting. |
| 149 TEST_F(MultiprocessMessagePipeTest, QueueMessages) { | 149 TEST_F(MultiprocessMessagePipeTest, QueueMessages) { |
| 150 helper()->StartChild("EchoEcho"); | 150 helper()->StartChild("EchoEcho"); |
| 151 | 151 |
| 152 scoped_refptr<ChannelEndpoint> ep; | 152 scoped_refptr<ChannelEndpoint> ep; |
| 153 scoped_refptr<MessagePipe> mp(MessagePipe::CreateLocalProxy(&ep)); | 153 scoped_refptr<MessagePipe> mp(MessagePipe::CreateLocalProxy(&ep)); |
| 154 Init(ep); | 154 Init(ep); |
| 155 | 155 |
| 156 static const size_t kNumMessages = 1001; | 156 static const size_t kNumMessages = 1001; |
| 157 for (size_t i = 0; i < kNumMessages; i++) { | 157 for (size_t i = 0; i < kNumMessages; i++) { |
| 158 std::string write_buffer(i, 'A' + (i % 26)); | 158 std::string write_buffer(i, 'A' + (i % 26)); |
| 159 EXPECT_EQ(MOJO_RESULT_OK, | 159 EXPECT_EQ(MOJO_RESULT_OK, |
| 160 mp->WriteMessage(0, | 160 mp->WriteMessage(0, |
| 161 UserPointer<const void>(write_buffer.data()), | 161 UserPointer<const void>(write_buffer.data()), |
| 162 static_cast<uint32_t>(write_buffer.size()), | 162 static_cast<uint32_t>(write_buffer.size()), |
| 163 NULL, | 163 nullptr, |
| 164 MOJO_WRITE_MESSAGE_FLAG_NONE)); | 164 MOJO_WRITE_MESSAGE_FLAG_NONE)); |
| 165 } | 165 } |
| 166 | 166 |
| 167 const std::string quitquitquit("quitquitquit"); | 167 const std::string quitquitquit("quitquitquit"); |
| 168 EXPECT_EQ(MOJO_RESULT_OK, | 168 EXPECT_EQ(MOJO_RESULT_OK, |
| 169 mp->WriteMessage(0, | 169 mp->WriteMessage(0, |
| 170 UserPointer<const void>(quitquitquit.data()), | 170 UserPointer<const void>(quitquitquit.data()), |
| 171 static_cast<uint32_t>(quitquitquit.size()), | 171 static_cast<uint32_t>(quitquitquit.size()), |
| 172 NULL, | 172 nullptr, |
| 173 MOJO_WRITE_MESSAGE_FLAG_NONE)); | 173 MOJO_WRITE_MESSAGE_FLAG_NONE)); |
| 174 | 174 |
| 175 for (size_t i = 0; i < kNumMessages; i++) { | 175 for (size_t i = 0; i < kNumMessages; i++) { |
| 176 HandleSignalsState hss; | 176 HandleSignalsState hss; |
| 177 EXPECT_EQ(MOJO_RESULT_OK, | 177 EXPECT_EQ(MOJO_RESULT_OK, |
| 178 test::WaitIfNecessary(mp, MOJO_HANDLE_SIGNAL_READABLE, &hss)); | 178 test::WaitIfNecessary(mp, MOJO_HANDLE_SIGNAL_READABLE, &hss)); |
| 179 // The child may or may not have closed its end of the message pipe and died | 179 // The child may or may not have closed its end of the message pipe and died |
| 180 // (and we may or may not know it yet), so our end may or may not appear as | 180 // (and we may or may not know it yet), so our end may or may not appear as |
| 181 // writable. | 181 // writable. |
| 182 EXPECT_TRUE((hss.satisfied_signals & MOJO_HANDLE_SIGNAL_READABLE)); | 182 EXPECT_TRUE((hss.satisfied_signals & MOJO_HANDLE_SIGNAL_READABLE)); |
| 183 EXPECT_TRUE((hss.satisfiable_signals & MOJO_HANDLE_SIGNAL_READABLE)); | 183 EXPECT_TRUE((hss.satisfiable_signals & MOJO_HANDLE_SIGNAL_READABLE)); |
| 184 | 184 |
| 185 std::string read_buffer(kNumMessages * 2, '\0'); | 185 std::string read_buffer(kNumMessages * 2, '\0'); |
| 186 uint32_t read_buffer_size = static_cast<uint32_t>(read_buffer.size()); | 186 uint32_t read_buffer_size = static_cast<uint32_t>(read_buffer.size()); |
| 187 CHECK_EQ(mp->ReadMessage(0, | 187 CHECK_EQ(mp->ReadMessage(0, |
| 188 UserPointer<void>(&read_buffer[0]), | 188 UserPointer<void>(&read_buffer[0]), |
| 189 MakeUserPointer(&read_buffer_size), | 189 MakeUserPointer(&read_buffer_size), |
| 190 NULL, | 190 nullptr, |
| 191 NULL, | 191 nullptr, |
| 192 MOJO_READ_MESSAGE_FLAG_NONE), | 192 MOJO_READ_MESSAGE_FLAG_NONE), |
| 193 MOJO_RESULT_OK); | 193 MOJO_RESULT_OK); |
| 194 read_buffer.resize(read_buffer_size); | 194 read_buffer.resize(read_buffer_size); |
| 195 | 195 |
| 196 EXPECT_EQ(std::string(i * 2, 'A' + (i % 26)), read_buffer); | 196 EXPECT_EQ(std::string(i * 2, 'A' + (i % 26)), read_buffer); |
| 197 } | 197 } |
| 198 | 198 |
| 199 // Wait for it to become readable, which should fail (since we sent | 199 // Wait for it to become readable, which should fail (since we sent |
| 200 // "quitquitquit"). | 200 // "quitquitquit"). |
| 201 HandleSignalsState hss; | 201 HandleSignalsState hss; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 memcpy(mapping->GetBase(), kHello, sizeof(kHello)); | 265 memcpy(mapping->GetBase(), kHello, sizeof(kHello)); |
| 266 | 266 |
| 267 // We should be able to close the dispatcher now. | 267 // We should be able to close the dispatcher now. |
| 268 dispatcher->Close(); | 268 dispatcher->Close(); |
| 269 | 269 |
| 270 // And send a message to signal that we've written stuff. | 270 // And send a message to signal that we've written stuff. |
| 271 const std::string go2("go 2"); | 271 const std::string go2("go 2"); |
| 272 CHECK_EQ(mp->WriteMessage(0, | 272 CHECK_EQ(mp->WriteMessage(0, |
| 273 UserPointer<const void>(&go2[0]), | 273 UserPointer<const void>(&go2[0]), |
| 274 static_cast<uint32_t>(go2.size()), | 274 static_cast<uint32_t>(go2.size()), |
| 275 NULL, | 275 nullptr, |
| 276 MOJO_WRITE_MESSAGE_FLAG_NONE), | 276 MOJO_WRITE_MESSAGE_FLAG_NONE), |
| 277 MOJO_RESULT_OK); | 277 MOJO_RESULT_OK); |
| 278 | 278 |
| 279 // Now wait for our parent to send us a message. | 279 // Now wait for our parent to send us a message. |
| 280 hss = HandleSignalsState(); | 280 hss = HandleSignalsState(); |
| 281 CHECK_EQ(test::WaitIfNecessary(mp, MOJO_HANDLE_SIGNAL_READABLE, &hss), | 281 CHECK_EQ(test::WaitIfNecessary(mp, MOJO_HANDLE_SIGNAL_READABLE, &hss), |
| 282 MOJO_RESULT_OK); | 282 MOJO_RESULT_OK); |
| 283 CHECK_EQ(hss.satisfied_signals, | 283 CHECK_EQ(hss.satisfied_signals, |
| 284 MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_WRITABLE); | 284 MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_WRITABLE); |
| 285 CHECK_EQ(hss.satisfiable_signals, | 285 CHECK_EQ(hss.satisfiable_signals, |
| 286 MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_WRITABLE); | 286 MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_WRITABLE); |
| 287 | 287 |
| 288 read_buffer = std::string(100, '\0'); | 288 read_buffer = std::string(100, '\0'); |
| 289 num_bytes = static_cast<uint32_t>(read_buffer.size()); | 289 num_bytes = static_cast<uint32_t>(read_buffer.size()); |
| 290 CHECK_EQ(mp->ReadMessage(0, | 290 CHECK_EQ(mp->ReadMessage(0, |
| 291 UserPointer<void>(&read_buffer[0]), | 291 UserPointer<void>(&read_buffer[0]), |
| 292 MakeUserPointer(&num_bytes), | 292 MakeUserPointer(&num_bytes), |
| 293 NULL, | 293 nullptr, |
| 294 NULL, | 294 nullptr, |
| 295 MOJO_READ_MESSAGE_FLAG_NONE), | 295 MOJO_READ_MESSAGE_FLAG_NONE), |
| 296 MOJO_RESULT_OK); | 296 MOJO_RESULT_OK); |
| 297 read_buffer.resize(num_bytes); | 297 read_buffer.resize(num_bytes); |
| 298 CHECK_EQ(read_buffer, std::string("go 3")); | 298 CHECK_EQ(read_buffer, std::string("go 3")); |
| 299 | 299 |
| 300 // It should have written something to the shared buffer. | 300 // It should have written something to the shared buffer. |
| 301 static const char kWorld[] = "world!!!"; | 301 static const char kWorld[] = "world!!!"; |
| 302 CHECK_EQ(memcmp(mapping->GetBase(), kWorld, sizeof(kWorld)), 0); | 302 CHECK_EQ(memcmp(mapping->GetBase(), kWorld, sizeof(kWorld)), 0); |
| 303 | 303 |
| 304 // And we're done. | 304 // And we're done. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 transports.push_back(transport); | 348 transports.push_back(transport); |
| 349 EXPECT_EQ(MOJO_RESULT_OK, | 349 EXPECT_EQ(MOJO_RESULT_OK, |
| 350 mp->WriteMessage(0, | 350 mp->WriteMessage(0, |
| 351 UserPointer<const void>(&go1[0]), | 351 UserPointer<const void>(&go1[0]), |
| 352 static_cast<uint32_t>(go1.size()), | 352 static_cast<uint32_t>(go1.size()), |
| 353 &transports, | 353 &transports, |
| 354 MOJO_WRITE_MESSAGE_FLAG_NONE)); | 354 MOJO_WRITE_MESSAGE_FLAG_NONE)); |
| 355 transport.End(); | 355 transport.End(); |
| 356 | 356 |
| 357 EXPECT_TRUE(dispatcher->HasOneRef()); | 357 EXPECT_TRUE(dispatcher->HasOneRef()); |
| 358 dispatcher = NULL; | 358 dispatcher = nullptr; |
| 359 | 359 |
| 360 // Wait for a message from the child. | 360 // Wait for a message from the child. |
| 361 HandleSignalsState hss; | 361 HandleSignalsState hss; |
| 362 EXPECT_EQ(MOJO_RESULT_OK, | 362 EXPECT_EQ(MOJO_RESULT_OK, |
| 363 test::WaitIfNecessary(mp, MOJO_HANDLE_SIGNAL_READABLE, &hss)); | 363 test::WaitIfNecessary(mp, MOJO_HANDLE_SIGNAL_READABLE, &hss)); |
| 364 EXPECT_TRUE((hss.satisfied_signals & MOJO_HANDLE_SIGNAL_READABLE)); | 364 EXPECT_TRUE((hss.satisfied_signals & MOJO_HANDLE_SIGNAL_READABLE)); |
| 365 EXPECT_TRUE((hss.satisfiable_signals & MOJO_HANDLE_SIGNAL_READABLE)); | 365 EXPECT_TRUE((hss.satisfiable_signals & MOJO_HANDLE_SIGNAL_READABLE)); |
| 366 | 366 |
| 367 std::string read_buffer(100, '\0'); | 367 std::string read_buffer(100, '\0'); |
| 368 uint32_t num_bytes = static_cast<uint32_t>(read_buffer.size()); | 368 uint32_t num_bytes = static_cast<uint32_t>(read_buffer.size()); |
| 369 EXPECT_EQ(MOJO_RESULT_OK, | 369 EXPECT_EQ(MOJO_RESULT_OK, |
| 370 mp->ReadMessage(0, | 370 mp->ReadMessage(0, |
| 371 UserPointer<void>(&read_buffer[0]), | 371 UserPointer<void>(&read_buffer[0]), |
| 372 MakeUserPointer(&num_bytes), | 372 MakeUserPointer(&num_bytes), |
| 373 NULL, | 373 nullptr, |
| 374 NULL, | 374 nullptr, |
| 375 MOJO_READ_MESSAGE_FLAG_NONE)); | 375 MOJO_READ_MESSAGE_FLAG_NONE)); |
| 376 read_buffer.resize(num_bytes); | 376 read_buffer.resize(num_bytes); |
| 377 EXPECT_EQ(std::string("go 2"), read_buffer); | 377 EXPECT_EQ(std::string("go 2"), read_buffer); |
| 378 | 378 |
| 379 // After we get it, the child should have written something to the shared | 379 // After we get it, the child should have written something to the shared |
| 380 // buffer. | 380 // buffer. |
| 381 static const char kHello[] = "hello"; | 381 static const char kHello[] = "hello"; |
| 382 EXPECT_EQ(0, memcmp(mapping->GetBase(), kHello, sizeof(kHello))); | 382 EXPECT_EQ(0, memcmp(mapping->GetBase(), kHello, sizeof(kHello))); |
| 383 | 383 |
| 384 // Now we'll write some stuff to the shared buffer. | 384 // Now we'll write some stuff to the shared buffer. |
| 385 static const char kWorld[] = "world!!!"; | 385 static const char kWorld[] = "world!!!"; |
| 386 memcpy(mapping->GetBase(), kWorld, sizeof(kWorld)); | 386 memcpy(mapping->GetBase(), kWorld, sizeof(kWorld)); |
| 387 | 387 |
| 388 // And send a message to signal that we've written stuff. | 388 // And send a message to signal that we've written stuff. |
| 389 const std::string go3("go 3"); | 389 const std::string go3("go 3"); |
| 390 EXPECT_EQ(MOJO_RESULT_OK, | 390 EXPECT_EQ(MOJO_RESULT_OK, |
| 391 mp->WriteMessage(0, | 391 mp->WriteMessage(0, |
| 392 UserPointer<const void>(&go3[0]), | 392 UserPointer<const void>(&go3[0]), |
| 393 static_cast<uint32_t>(go3.size()), | 393 static_cast<uint32_t>(go3.size()), |
| 394 NULL, | 394 nullptr, |
| 395 MOJO_WRITE_MESSAGE_FLAG_NONE)); | 395 MOJO_WRITE_MESSAGE_FLAG_NONE)); |
| 396 | 396 |
| 397 // Wait for |mp| to become readable, which should fail. | 397 // Wait for |mp| to become readable, which should fail. |
| 398 hss = HandleSignalsState(); | 398 hss = HandleSignalsState(); |
| 399 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, | 399 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, |
| 400 test::WaitIfNecessary(mp, MOJO_HANDLE_SIGNAL_READABLE, &hss)); | 400 test::WaitIfNecessary(mp, MOJO_HANDLE_SIGNAL_READABLE, &hss)); |
| 401 EXPECT_EQ(0u, hss.satisfied_signals); | 401 EXPECT_EQ(0u, hss.satisfied_signals); |
| 402 EXPECT_EQ(0u, hss.satisfiable_signals); | 402 EXPECT_EQ(0u, hss.satisfiable_signals); |
| 403 | 403 |
| 404 mp->Close(0); | 404 mp->Close(0); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 transports.push_back(transport); | 497 transports.push_back(transport); |
| 498 EXPECT_EQ(MOJO_RESULT_OK, | 498 EXPECT_EQ(MOJO_RESULT_OK, |
| 499 mp->WriteMessage(0, | 499 mp->WriteMessage(0, |
| 500 UserPointer<const void>(&hello[0]), | 500 UserPointer<const void>(&hello[0]), |
| 501 static_cast<uint32_t>(hello.size()), | 501 static_cast<uint32_t>(hello.size()), |
| 502 &transports, | 502 &transports, |
| 503 MOJO_WRITE_MESSAGE_FLAG_NONE)); | 503 MOJO_WRITE_MESSAGE_FLAG_NONE)); |
| 504 transport.End(); | 504 transport.End(); |
| 505 | 505 |
| 506 EXPECT_TRUE(dispatcher->HasOneRef()); | 506 EXPECT_TRUE(dispatcher->HasOneRef()); |
| 507 dispatcher = NULL; | 507 dispatcher = nullptr; |
| 508 | 508 |
| 509 // Wait for it to become readable, which should fail. | 509 // Wait for it to become readable, which should fail. |
| 510 HandleSignalsState hss; | 510 HandleSignalsState hss; |
| 511 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, | 511 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, |
| 512 test::WaitIfNecessary(mp, MOJO_HANDLE_SIGNAL_READABLE, &hss)); | 512 test::WaitIfNecessary(mp, MOJO_HANDLE_SIGNAL_READABLE, &hss)); |
| 513 EXPECT_EQ(0u, hss.satisfied_signals); | 513 EXPECT_EQ(0u, hss.satisfied_signals); |
| 514 EXPECT_EQ(0u, hss.satisfiable_signals); | 514 EXPECT_EQ(0u, hss.satisfiable_signals); |
| 515 | 515 |
| 516 mp->Close(0); | 516 mp->Close(0); |
| 517 | 517 |
| 518 EXPECT_EQ(0, helper()->WaitForChildShutdown()); | 518 EXPECT_EQ(0, helper()->WaitForChildShutdown()); |
| 519 } | 519 } |
| 520 | 520 |
| 521 } // namespace | 521 } // namespace |
| 522 } // namespace system | 522 } // namespace system |
| 523 } // namespace mojo | 523 } // namespace mojo |
| OLD | NEW |