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

Side by Side Diff: mojo/edk/system/ipc_support_unittest.cc

Issue 2075353002: Plumb the handle signals state out of Waiter::Wait(). (Closed) Base URL: https://github.com/domokit/mojo.git@work795_wait_set_4.3-x-work794_wait_set_4.2
Patch Set: Created 4 years, 6 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "mojo/edk/system/ipc_support.h" 5 #include "mojo/edk/system/ipc_support.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 ASSERT_EQ( 55 ASSERT_EQ(
56 MOJO_RESULT_OK, 56 MOJO_RESULT_OK,
57 read_mp->AddAwakable(&waiter, MOJO_HANDLE_SIGNAL_READABLE, 0, nullptr)); 57 read_mp->AddAwakable(&waiter, MOJO_HANDLE_SIGNAL_READABLE, 0, nullptr));
58 58
59 // Write a message with just 'x' through the write end. 59 // Write a message with just 'x' through the write end.
60 EXPECT_EQ(MOJO_RESULT_OK, 60 EXPECT_EQ(MOJO_RESULT_OK,
61 write_mp->WriteMessage(UserPointer<const void>("x"), 1, nullptr, 61 write_mp->WriteMessage(UserPointer<const void>("x"), 1, nullptr,
62 MOJO_WRITE_MESSAGE_FLAG_NONE)); 62 MOJO_WRITE_MESSAGE_FLAG_NONE));
63 63
64 // Wait for it to arrive. 64 // Wait for it to arrive.
65 EXPECT_EQ(MOJO_RESULT_OK, waiter.Wait(test::ActionTimeout(), nullptr)); 65 EXPECT_EQ(MOJO_RESULT_OK,
66 waiter.Wait(test::ActionTimeout(), nullptr, nullptr));
66 read_mp->RemoveAwakable(&waiter, nullptr); 67 read_mp->RemoveAwakable(&waiter, nullptr);
67 68
68 // Read the message from the read end. 69 // Read the message from the read end.
69 char buffer[10] = {}; 70 char buffer[10] = {};
70 uint32_t buffer_size = static_cast<uint32_t>(sizeof(buffer)); 71 uint32_t buffer_size = static_cast<uint32_t>(sizeof(buffer));
71 EXPECT_EQ(MOJO_RESULT_OK, 72 EXPECT_EQ(MOJO_RESULT_OK,
72 read_mp->ReadMessage(UserPointer<void>(buffer), 73 read_mp->ReadMessage(UserPointer<void>(buffer),
73 MakeUserPointer(&buffer_size), 0, nullptr, 74 MakeUserPointer(&buffer_size), 0, nullptr,
74 MOJO_READ_MESSAGE_FLAG_NONE)); 75 MOJO_READ_MESSAGE_FLAG_NONE));
75 EXPECT_EQ(1u, buffer_size); 76 EXPECT_EQ(1u, buffer_size);
(...skipping 26 matching lines...) Expand all
102 CHECK(transport.is_valid()); 103 CHECK(transport.is_valid());
103 std::vector<HandleTransport> transports; 104 std::vector<HandleTransport> transports;
104 transports.push_back(transport); 105 transports.push_back(transport);
105 CHECK_EQ(write_mp->WriteMessage(NullUserPointer(), 0, &transports, 106 CHECK_EQ(write_mp->WriteMessage(NullUserPointer(), 0, &transports,
106 MOJO_WRITE_MESSAGE_FLAG_NONE), 107 MOJO_WRITE_MESSAGE_FLAG_NONE),
107 MOJO_RESULT_OK); 108 MOJO_RESULT_OK);
108 transport.End(); 109 transport.End();
109 mp_handle_to_send.reset(); 110 mp_handle_to_send.reset();
110 111
111 // Wait for it to arrive. 112 // Wait for it to arrive.
112 CHECK_EQ(waiter.Wait(test::ActionTimeout(), nullptr), MOJO_RESULT_OK); 113 CHECK_EQ(waiter.Wait(test::ActionTimeout(), nullptr, nullptr),
114 MOJO_RESULT_OK);
113 read_mp->RemoveAwakable(&waiter, nullptr); 115 read_mp->RemoveAwakable(&waiter, nullptr);
114 116
115 // Read the message from the read end. 117 // Read the message from the read end.
116 HandleVector handles; 118 HandleVector handles;
117 uint32_t num_handles = 10; 119 uint32_t num_handles = 10;
118 CHECK_EQ(read_mp->ReadMessage(NullUserPointer(), NullUserPointer(), &handles, 120 CHECK_EQ(read_mp->ReadMessage(NullUserPointer(), NullUserPointer(), &handles,
119 &num_handles, MOJO_READ_MESSAGE_FLAG_NONE), 121 &num_handles, MOJO_READ_MESSAGE_FLAG_NONE),
120 MOJO_RESULT_OK); 122 MOJO_RESULT_OK);
121 CHECK_EQ(handles.size(), 1u); 123 CHECK_EQ(handles.size(), 1u);
122 CHECK_EQ(num_handles, 1u); 124 CHECK_EQ(num_handles, 1u);
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 718
717 test_io_thread.PostTaskAndWait( 719 test_io_thread.PostTaskAndWait(
718 [&ipc_support]() { ipc_support.ShutdownOnIOThread(); }); 720 [&ipc_support]() { ipc_support.ShutdownOnIOThread(); });
719 } 721 }
720 722
721 // TODO(vtl): Also test the case of the master "dying" before the slave. (The 723 // TODO(vtl): Also test the case of the master "dying" before the slave. (The
722 // slave should get OnMasterDisconnect(), which we currently don't test.) 724 // slave should get OnMasterDisconnect(), which we currently don't test.)
723 725
724 } // namespace system 726 } // namespace system
725 } // namespace mojo 727 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698