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

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

Issue 2056763003: EDK: Change Awakable::Awake()'s context, etc., to be a uint64_t. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: doh 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 // This file tests both |RemoteProducerDataPipeImpl| and 5 // This file tests both |RemoteProducerDataPipeImpl| and
6 // |RemoteConsumerDataPipeImpl|. 6 // |RemoteConsumerDataPipeImpl|.
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // Make sure that the test fixture works properly (i.e., that the message pipe 128 // Make sure that the test fixture works properly (i.e., that the message pipe
129 // works properly, and that things are shut down correctly). 129 // works properly, and that things are shut down correctly).
130 // TODO(vtl): Make lighter-weight tests. Ideally, we'd have tests for remote 130 // TODO(vtl): Make lighter-weight tests. Ideally, we'd have tests for remote
131 // data pipes which don't involve message pipes (or even data pipe dispatchers). 131 // data pipes which don't involve message pipes (or even data pipe dispatchers).
132 TEST_F(RemoteDataPipeImplTest, Sanity) { 132 TEST_F(RemoteDataPipeImplTest, Sanity) {
133 static const char kHello[] = "hello"; 133 static const char kHello[] = "hello";
134 char read_buffer[100] = {}; 134 char read_buffer[100] = {};
135 uint32_t read_buffer_size = static_cast<uint32_t>(sizeof(read_buffer)); 135 uint32_t read_buffer_size = static_cast<uint32_t>(sizeof(read_buffer));
136 Waiter waiter; 136 Waiter waiter;
137 HandleSignalsState hss; 137 HandleSignalsState hss;
138 uint32_t context = 0; 138 uint64_t context = 0;
139 139
140 // Write on MP 0 (port 0). Wait and receive on MP 1 (port 0). (Add the waiter 140 // Write on MP 0 (port 0). Wait and receive on MP 1 (port 0). (Add the waiter
141 // first, to avoid any handling the case where it's already readable.) 141 // first, to avoid any handling the case where it's already readable.)
142 waiter.Init(); 142 waiter.Init();
143 ASSERT_EQ(MOJO_RESULT_OK, 143 ASSERT_EQ(MOJO_RESULT_OK,
144 message_pipe(1)->AddAwakable( 144 message_pipe(1)->AddAwakable(
145 0, &waiter, MOJO_HANDLE_SIGNAL_READABLE, 123, nullptr)); 145 0, &waiter, MOJO_HANDLE_SIGNAL_READABLE, 123, nullptr));
146 EXPECT_EQ(MOJO_RESULT_OK, 146 EXPECT_EQ(MOJO_RESULT_OK,
147 message_pipe(0)->WriteMessage(0, UserPointer<const void>(kHello), 147 message_pipe(0)->WriteMessage(0, UserPointer<const void>(kHello),
148 sizeof(kHello), nullptr, 148 sizeof(kHello), nullptr,
(...skipping 15 matching lines...) Expand all
164 EXPECT_STREQ(kHello, read_buffer); 164 EXPECT_STREQ(kHello, read_buffer);
165 } 165 }
166 166
167 TEST_F(RemoteDataPipeImplTest, SendConsumerWithClosedProducer) { 167 TEST_F(RemoteDataPipeImplTest, SendConsumerWithClosedProducer) {
168 char read_buffer[100] = {}; 168 char read_buffer[100] = {};
169 uint32_t read_buffer_size = static_cast<uint32_t>(sizeof(read_buffer)); 169 uint32_t read_buffer_size = static_cast<uint32_t>(sizeof(read_buffer));
170 HandleVector read_handles; 170 HandleVector read_handles;
171 uint32_t read_num_handles = 10; // Maximum to get. 171 uint32_t read_num_handles = 10; // Maximum to get.
172 Waiter waiter; 172 Waiter waiter;
173 HandleSignalsState hss; 173 HandleSignalsState hss;
174 uint32_t context = 0; 174 uint64_t context = 0;
175 175
176 RefPtr<DataPipe> dp(CreateLocal(sizeof(int32_t), 1000)); 176 RefPtr<DataPipe> dp(CreateLocal(sizeof(int32_t), 1000));
177 // This is the consumer dispatcher we'll send. 177 // This is the consumer dispatcher we'll send.
178 auto consumer = DataPipeConsumerDispatcher::Create(); 178 auto consumer = DataPipeConsumerDispatcher::Create();
179 consumer->Init(dp.Clone()); 179 consumer->Init(dp.Clone());
180 Handle consumer_handle(std::move(consumer), 180 Handle consumer_handle(std::move(consumer),
181 DataPipeConsumerDispatcher::kDefaultHandleRights); 181 DataPipeConsumerDispatcher::kDefaultHandleRights);
182 182
183 // Write to the producer and close it, before sending the consumer. 183 // Write to the producer and close it, before sending the consumer.
184 int32_t elements[10] = {123}; 184 int32_t elements[10] = {123};
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 consumer->Close(); 289 consumer->Close();
290 } 290 }
291 291
292 TEST_F(RemoteDataPipeImplTest, SendConsumerDuringTwoPhaseWrite) { 292 TEST_F(RemoteDataPipeImplTest, SendConsumerDuringTwoPhaseWrite) {
293 char read_buffer[100] = {}; 293 char read_buffer[100] = {};
294 uint32_t read_buffer_size = static_cast<uint32_t>(sizeof(read_buffer)); 294 uint32_t read_buffer_size = static_cast<uint32_t>(sizeof(read_buffer));
295 HandleVector read_handles; 295 HandleVector read_handles;
296 uint32_t read_num_handles = 10; // Maximum to get. 296 uint32_t read_num_handles = 10; // Maximum to get.
297 Waiter waiter; 297 Waiter waiter;
298 HandleSignalsState hss; 298 HandleSignalsState hss;
299 uint32_t context = 0; 299 uint64_t context = 0;
300 300
301 RefPtr<DataPipe> dp(CreateLocal(sizeof(int32_t), 1000)); 301 RefPtr<DataPipe> dp(CreateLocal(sizeof(int32_t), 1000));
302 // This is the consumer dispatcher we'll send. 302 // This is the consumer dispatcher we'll send.
303 auto consumer = DataPipeConsumerDispatcher::Create(); 303 auto consumer = DataPipeConsumerDispatcher::Create();
304 consumer->Init(dp.Clone()); 304 consumer->Init(dp.Clone());
305 Handle consumer_handle(std::move(consumer), 305 Handle consumer_handle(std::move(consumer),
306 DataPipeConsumerDispatcher::kDefaultHandleRights); 306 DataPipeConsumerDispatcher::kDefaultHandleRights);
307 307
308 void* write_ptr = nullptr; 308 void* write_ptr = nullptr;
309 uint32_t num_bytes = 0u; 309 uint32_t num_bytes = 0u;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 // Like |SendConsumerDuringTwoPhaseWrite|, but transfers the consumer during the 406 // Like |SendConsumerDuringTwoPhaseWrite|, but transfers the consumer during the
407 // second two-phase write (to try to test that the offset in circular buffer is 407 // second two-phase write (to try to test that the offset in circular buffer is
408 // properly preserved). 408 // properly preserved).
409 TEST_F(RemoteDataPipeImplTest, SendConsumerDuringSecondTwoPhaseWrite) { 409 TEST_F(RemoteDataPipeImplTest, SendConsumerDuringSecondTwoPhaseWrite) {
410 char read_buffer[100] = {}; 410 char read_buffer[100] = {};
411 uint32_t read_buffer_size = static_cast<uint32_t>(sizeof(read_buffer)); 411 uint32_t read_buffer_size = static_cast<uint32_t>(sizeof(read_buffer));
412 HandleVector read_handles; 412 HandleVector read_handles;
413 uint32_t read_num_handles = 10; // Maximum to get. 413 uint32_t read_num_handles = 10; // Maximum to get.
414 Waiter waiter; 414 Waiter waiter;
415 HandleSignalsState hss; 415 HandleSignalsState hss;
416 uint32_t context = 0; 416 uint64_t context = 0;
417 417
418 RefPtr<DataPipe> dp(CreateLocal(sizeof(int32_t), 1000)); 418 RefPtr<DataPipe> dp(CreateLocal(sizeof(int32_t), 1000));
419 // This is the consumer dispatcher we'll send. 419 // This is the consumer dispatcher we'll send.
420 auto consumer = DataPipeConsumerDispatcher::Create(); 420 auto consumer = DataPipeConsumerDispatcher::Create();
421 consumer->Init(dp.Clone()); 421 consumer->Init(dp.Clone());
422 Handle consumer_handle(std::move(consumer), 422 Handle consumer_handle(std::move(consumer),
423 DataPipeConsumerDispatcher::kDefaultHandleRights); 423 DataPipeConsumerDispatcher::kDefaultHandleRights);
424 424
425 void* write_ptr = nullptr; 425 void* write_ptr = nullptr;
426 uint32_t num_bytes = 0u; 426 uint32_t num_bytes = 0u;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 EXPECT_EQ(123456, elements[0]); 528 EXPECT_EQ(123456, elements[0]);
529 EXPECT_EQ(789012, elements[1]); 529 EXPECT_EQ(789012, elements[1]);
530 EXPECT_EQ(0, elements[2]); 530 EXPECT_EQ(0, elements[2]);
531 531
532 consumer->Close(); 532 consumer->Close();
533 } 533 }
534 534
535 } // namespace 535 } // namespace
536 } // namespace system 536 } // namespace system
537 } // namespace mojo 537 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/message_pipe_unittest.cc ('k') | mojo/edk/system/remote_message_pipe_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698