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

Side by Side Diff: mojo/public/c/system/tests/core_unittest.cc

Issue 1885663002: EDK: Add implementation of data pipe producer write threshold stuff. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 8 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 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 // This file tests the C API. 5 // This file tests the C API.
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "mojo/public/c/system/buffer.h" 9 #include "mojo/public/c/system/buffer.h"
10 #include "mojo/public/c/system/data_pipe.h" 10 #include "mojo/public/c/system/data_pipe.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 EXPECT_EQ(MOJO_RESULT_DEADLINE_EXCEEDED, 223 EXPECT_EQ(MOJO_RESULT_DEADLINE_EXCEEDED,
224 MojoWait(hc, MOJO_HANDLE_SIGNAL_READABLE, 0, &state)); 224 MojoWait(hc, MOJO_HANDLE_SIGNAL_READABLE, 0, &state));
225 EXPECT_EQ(MOJO_HANDLE_SIGNAL_NONE, state.satisfied_signals); 225 EXPECT_EQ(MOJO_HANDLE_SIGNAL_NONE, state.satisfied_signals);
226 EXPECT_EQ(MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_PEER_CLOSED | 226 EXPECT_EQ(MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_PEER_CLOSED |
227 MOJO_HANDLE_SIGNAL_READ_THRESHOLD, 227 MOJO_HANDLE_SIGNAL_READ_THRESHOLD,
228 state.satisfiable_signals); 228 state.satisfiable_signals);
229 229
230 // The producer |hp| should be writable. 230 // The producer |hp| should be writable.
231 EXPECT_EQ(MOJO_RESULT_OK, 231 EXPECT_EQ(MOJO_RESULT_OK,
232 MojoWait(hp, MOJO_HANDLE_SIGNAL_WRITABLE, 0, &state)); 232 MojoWait(hp, MOJO_HANDLE_SIGNAL_WRITABLE, 0, &state));
233 EXPECT_EQ(MOJO_HANDLE_SIGNAL_WRITABLE, state.satisfied_signals); 233 EXPECT_EQ(MOJO_HANDLE_SIGNAL_WRITABLE | MOJO_HANDLE_SIGNAL_WRITE_THRESHOLD,
234 EXPECT_EQ(MOJO_HANDLE_SIGNAL_WRITABLE | MOJO_HANDLE_SIGNAL_PEER_CLOSED, 234 state.satisfied_signals);
235 EXPECT_EQ(MOJO_HANDLE_SIGNAL_WRITABLE | MOJO_HANDLE_SIGNAL_PEER_CLOSED |
236 MOJO_HANDLE_SIGNAL_WRITE_THRESHOLD,
235 state.satisfiable_signals); 237 state.satisfiable_signals);
236 238
237 // Try to read from |hc|. 239 // Try to read from |hc|.
238 buffer_size = static_cast<uint32_t>(sizeof(buffer)); 240 buffer_size = static_cast<uint32_t>(sizeof(buffer));
239 EXPECT_EQ(MOJO_RESULT_SHOULD_WAIT, 241 EXPECT_EQ(MOJO_RESULT_SHOULD_WAIT,
240 MojoReadData(hc, buffer, &buffer_size, MOJO_READ_DATA_FLAG_NONE)); 242 MojoReadData(hc, buffer, &buffer_size, MOJO_READ_DATA_FLAG_NONE));
241 243
242 // Try to begin a two-phase read from |hc|. 244 // Try to begin a two-phase read from |hc|.
243 read_pointer = nullptr; 245 read_pointer = nullptr;
244 EXPECT_EQ(MOJO_RESULT_SHOULD_WAIT, 246 EXPECT_EQ(MOJO_RESULT_SHOULD_WAIT,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 MojoWait(hc, MOJO_HANDLE_SIGNAL_READABLE, 1000, &state)); 310 MojoWait(hc, MOJO_HANDLE_SIGNAL_READABLE, 1000, &state));
309 EXPECT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, state.satisfied_signals); 311 EXPECT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, state.satisfied_signals);
310 EXPECT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, state.satisfiable_signals); 312 EXPECT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, state.satisfiable_signals);
311 313
312 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(hc)); 314 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(hc));
313 315
314 // TODO(vtl): Test the other way around -- closing the consumer should make 316 // TODO(vtl): Test the other way around -- closing the consumer should make
315 // the producer never-writable? 317 // the producer never-writable?
316 } 318 }
317 319
320 // TODO(vtl): Once thunks are in: TEST(CoreTest, DataPipeWriteThreshold) { ... }
321
318 TEST(CoreTest, DataPipeReadThreshold) { 322 TEST(CoreTest, DataPipeReadThreshold) {
319 MojoHandle hp = MOJO_HANDLE_INVALID; 323 MojoHandle hp = MOJO_HANDLE_INVALID;
320 MojoHandle hc = MOJO_HANDLE_INVALID; 324 MojoHandle hc = MOJO_HANDLE_INVALID;
321 EXPECT_EQ(MOJO_RESULT_OK, MojoCreateDataPipe(nullptr, &hp, &hc)); 325 EXPECT_EQ(MOJO_RESULT_OK, MojoCreateDataPipe(nullptr, &hp, &hc));
322 EXPECT_NE(hp, MOJO_HANDLE_INVALID); 326 EXPECT_NE(hp, MOJO_HANDLE_INVALID);
323 EXPECT_NE(hc, MOJO_HANDLE_INVALID); 327 EXPECT_NE(hc, MOJO_HANDLE_INVALID);
328 EXPECT_NE(hc, hp);
324 329
325 MojoDataPipeConsumerOptions copts; 330 MojoDataPipeConsumerOptions copts;
326 static const uint32_t kCoptsSize = static_cast<uint32_t>(sizeof(copts)); 331 static const uint32_t kCoptsSize = static_cast<uint32_t>(sizeof(copts));
327 332
328 // Check the current read threshold; should be the default. 333 // Check the current read threshold; should be the default.
329 memset(&copts, 255, kCoptsSize); 334 memset(&copts, 255, kCoptsSize);
330 EXPECT_EQ(MOJO_RESULT_OK, 335 EXPECT_EQ(MOJO_RESULT_OK,
331 MojoGetDataPipeConsumerOptions(hc, &copts, kCoptsSize)); 336 MojoGetDataPipeConsumerOptions(hc, &copts, kCoptsSize));
332 EXPECT_EQ(kCoptsSize, copts.struct_size); 337 EXPECT_EQ(kCoptsSize, copts.struct_size);
333 EXPECT_EQ(0u, copts.read_threshold_num_bytes); 338 EXPECT_EQ(0u, copts.read_threshold_num_bytes);
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 508
504 TEST(CoreTest, MinimalCppTest) { 509 TEST(CoreTest, MinimalCppTest) {
505 const char* failure = MinimalCppTest(); 510 const char* failure = MinimalCppTest();
506 EXPECT_FALSE(failure) << failure; 511 EXPECT_FALSE(failure) << failure;
507 } 512 }
508 513
509 // TODO(vtl): Add multi-threaded tests. 514 // TODO(vtl): Add multi-threaded tests.
510 515
511 } // namespace 516 } // namespace
512 } // namespace mojo 517 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/remote_consumer_data_pipe_impl.cc ('k') | mojo/public/platform/native/system_impl_private_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698