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

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

Issue 2068483002: Add an unconditional version of DispatcherAddAwakable(): AddAwakableUnconditional(). (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: oops 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 uint64_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, false, 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,
149 MOJO_WRITE_MESSAGE_FLAG_NONE)); 149 MOJO_WRITE_MESSAGE_FLAG_NONE));
150 EXPECT_EQ(MOJO_RESULT_OK, waiter.Wait(test::ActionTimeout(), &context)); 150 EXPECT_EQ(MOJO_RESULT_OK, waiter.Wait(test::ActionTimeout(), &context));
151 EXPECT_EQ(123u, context); 151 EXPECT_EQ(123u, context);
152 hss = HandleSignalsState(); 152 hss = HandleSignalsState();
153 message_pipe(1)->RemoveAwakable(0, &waiter, &hss); 153 message_pipe(1)->RemoveAwakable(0, &waiter, &hss);
154 EXPECT_EQ(MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_WRITABLE, 154 EXPECT_EQ(MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_WRITABLE,
155 hss.satisfied_signals); 155 hss.satisfied_signals);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 MakeUserPointer(&num_bytes), false)); 188 MakeUserPointer(&num_bytes), false));
189 EXPECT_EQ(1u * sizeof(elements[0]), num_bytes); 189 EXPECT_EQ(1u * sizeof(elements[0]), num_bytes);
190 dp->ProducerClose(); 190 dp->ProducerClose();
191 191
192 // Write the consumer to MP 0 (port 0). Wait and receive on MP 1 (port 0). 192 // Write the consumer to MP 0 (port 0). Wait and receive on MP 1 (port 0).
193 // (Add the waiter first, to avoid any handling the case where it's already 193 // (Add the waiter first, to avoid any handling the case where it's already
194 // readable.) 194 // readable.)
195 waiter.Init(); 195 waiter.Init();
196 ASSERT_EQ(MOJO_RESULT_OK, 196 ASSERT_EQ(MOJO_RESULT_OK,
197 message_pipe(1)->AddAwakable( 197 message_pipe(1)->AddAwakable(
198 0, &waiter, MOJO_HANDLE_SIGNAL_READABLE, 123, nullptr)); 198 0, &waiter, MOJO_HANDLE_SIGNAL_READABLE, false, 123, nullptr));
199 { 199 {
200 HandleTransport transport(test::HandleTryStartTransport(consumer_handle)); 200 HandleTransport transport(test::HandleTryStartTransport(consumer_handle));
201 EXPECT_TRUE(transport.is_valid()); 201 EXPECT_TRUE(transport.is_valid());
202 202
203 std::vector<HandleTransport> transports; 203 std::vector<HandleTransport> transports;
204 transports.push_back(transport); 204 transports.push_back(transport);
205 EXPECT_EQ(MOJO_RESULT_OK, message_pipe(0)->WriteMessage( 205 EXPECT_EQ(MOJO_RESULT_OK, message_pipe(0)->WriteMessage(
206 0, NullUserPointer(), 0, &transports, 206 0, NullUserPointer(), 0, &transports,
207 MOJO_WRITE_MESSAGE_FLAG_NONE)); 207 MOJO_WRITE_MESSAGE_FLAG_NONE));
208 transport.End(); 208 transport.End();
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 dp->ProducerBeginWriteData(MakeUserPointer(&write_ptr), 311 dp->ProducerBeginWriteData(MakeUserPointer(&write_ptr),
312 MakeUserPointer(&num_bytes))); 312 MakeUserPointer(&num_bytes)));
313 ASSERT_GE(num_bytes, 1u * sizeof(int32_t)); 313 ASSERT_GE(num_bytes, 1u * sizeof(int32_t));
314 314
315 // Write the consumer to MP 0 (port 0). Wait and receive on MP 1 (port 0). 315 // Write the consumer to MP 0 (port 0). Wait and receive on MP 1 (port 0).
316 // (Add the waiter first, to avoid any handling the case where it's already 316 // (Add the waiter first, to avoid any handling the case where it's already
317 // readable.) 317 // readable.)
318 waiter.Init(); 318 waiter.Init();
319 ASSERT_EQ(MOJO_RESULT_OK, 319 ASSERT_EQ(MOJO_RESULT_OK,
320 message_pipe(1)->AddAwakable( 320 message_pipe(1)->AddAwakable(
321 0, &waiter, MOJO_HANDLE_SIGNAL_READABLE, 123, nullptr)); 321 0, &waiter, MOJO_HANDLE_SIGNAL_READABLE, false, 123, nullptr));
322 { 322 {
323 HandleTransport transport(test::HandleTryStartTransport(consumer_handle)); 323 HandleTransport transport(test::HandleTryStartTransport(consumer_handle));
324 EXPECT_TRUE(transport.is_valid()); 324 EXPECT_TRUE(transport.is_valid());
325 325
326 std::vector<HandleTransport> transports; 326 std::vector<HandleTransport> transports;
327 transports.push_back(transport); 327 transports.push_back(transport);
328 EXPECT_EQ(MOJO_RESULT_OK, message_pipe(0)->WriteMessage( 328 EXPECT_EQ(MOJO_RESULT_OK, message_pipe(0)->WriteMessage(
329 0, NullUserPointer(), 0, &transports, 329 0, NullUserPointer(), 0, &transports,
330 MOJO_WRITE_MESSAGE_FLAG_NONE)); 330 MOJO_WRITE_MESSAGE_FLAG_NONE));
331 transport.End(); 331 transport.End();
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 dp->ProducerBeginWriteData(MakeUserPointer(&write_ptr), 438 dp->ProducerBeginWriteData(MakeUserPointer(&write_ptr),
439 MakeUserPointer(&num_bytes))); 439 MakeUserPointer(&num_bytes)));
440 ASSERT_GE(num_bytes, 1u * sizeof(int32_t)); 440 ASSERT_GE(num_bytes, 1u * sizeof(int32_t));
441 441
442 // Write the consumer to MP 0 (port 0). Wait and receive on MP 1 (port 0). 442 // Write the consumer to MP 0 (port 0). Wait and receive on MP 1 (port 0).
443 // (Add the waiter first, to avoid any handling the case where it's already 443 // (Add the waiter first, to avoid any handling the case where it's already
444 // readable.) 444 // readable.)
445 waiter.Init(); 445 waiter.Init();
446 ASSERT_EQ(MOJO_RESULT_OK, 446 ASSERT_EQ(MOJO_RESULT_OK,
447 message_pipe(1)->AddAwakable( 447 message_pipe(1)->AddAwakable(
448 0, &waiter, MOJO_HANDLE_SIGNAL_READABLE, 123, nullptr)); 448 0, &waiter, MOJO_HANDLE_SIGNAL_READABLE, false, 123, nullptr));
449 { 449 {
450 HandleTransport transport(test::HandleTryStartTransport(consumer_handle)); 450 HandleTransport transport(test::HandleTryStartTransport(consumer_handle));
451 EXPECT_TRUE(transport.is_valid()); 451 EXPECT_TRUE(transport.is_valid());
452 452
453 std::vector<HandleTransport> transports; 453 std::vector<HandleTransport> transports;
454 transports.push_back(transport); 454 transports.push_back(transport);
455 EXPECT_EQ(MOJO_RESULT_OK, message_pipe(0)->WriteMessage( 455 EXPECT_EQ(MOJO_RESULT_OK, message_pipe(0)->WriteMessage(
456 0, NullUserPointer(), 0, &transports, 456 0, NullUserPointer(), 0, &transports,
457 MOJO_WRITE_MESSAGE_FLAG_NONE)); 457 MOJO_WRITE_MESSAGE_FLAG_NONE));
458 transport.End(); 458 transport.End();
(...skipping 69 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