| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 // NOTE(vtl): Some of these tests are inherently flaky (e.g., if run on a | 5 // NOTE(vtl): Some of these tests are inherently flaky (e.g., if run on a |
| 6 // heavily-loaded system). Sorry. |test::EpsilonTimeout()| may be increased to | 6 // heavily-loaded system). Sorry. |test::EpsilonTimeout()| may be increased to |
| 7 // increase tolerance and reduce observed flakiness (though doing so reduces the | 7 // increase tolerance and reduce observed flakiness (though doing so reduces the |
| 8 // meaningfulness of the test). | 8 // meaningfulness of the test). |
| 9 | 9 |
| 10 #include "mojo/edk/system/wait_set_dispatcher.h" | 10 #include "mojo/edk/system/wait_set_dispatcher.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 87 |
| 88 auto d = WaitSetDispatcher::Create(WaitSetDispatcher::kDefaultCreateOptions); | 88 auto d = WaitSetDispatcher::Create(WaitSetDispatcher::kDefaultCreateOptions); |
| 89 | 89 |
| 90 // These will be members of our wait set. | 90 // These will be members of our wait set. |
| 91 auto d_member0 = MakeRefCounted<test::MockSimpleDispatcher>(kW, kR | kW); | 91 auto d_member0 = MakeRefCounted<test::MockSimpleDispatcher>(kW, kR | kW); |
| 92 auto d_member1 = MakeRefCounted<test::MockSimpleDispatcher>(kR, kR); | 92 auto d_member1 = MakeRefCounted<test::MockSimpleDispatcher>(kR, kR); |
| 93 | 93 |
| 94 // Add |d_member0|, for something not satisfied, but satisfiable. | 94 // Add |d_member0|, for something not satisfied, but satisfiable. |
| 95 static constexpr uint64_t kCookie0 = 0x123456789abcdef0ULL; | 95 static constexpr uint64_t kCookie0 = 0x123456789abcdef0ULL; |
| 96 static constexpr auto kSignals0 = kR; | 96 static constexpr auto kSignals0 = kR; |
| 97 EXPECT_EQ(MOJO_RESULT_OK, d->WaitSetAdd(NullUserPointer(), d_member0.Clone(), | 97 EXPECT_EQ(MOJO_RESULT_OK, d->WaitSetAdd(d_member0.Clone(), kSignals0, |
| 98 kSignals0, kCookie0)); | 98 kCookie0, NullUserPointer())); |
| 99 | 99 |
| 100 // Add |d_member1|, for something satisfied. | 100 // Add |d_member1|, for something satisfied. |
| 101 static constexpr uint64_t kCookie1 = 0x23456789abcdef01ULL; | 101 static constexpr uint64_t kCookie1 = 0x23456789abcdef01ULL; |
| 102 static constexpr auto kSignals1 = kR; | 102 static constexpr auto kSignals1 = kR; |
| 103 EXPECT_EQ(MOJO_RESULT_OK, d->WaitSetAdd(NullUserPointer(), d_member1.Clone(), | 103 EXPECT_EQ(MOJO_RESULT_OK, d->WaitSetAdd(d_member1.Clone(), kSignals1, |
| 104 kSignals1, kCookie1)); | 104 kCookie1, NullUserPointer())); |
| 105 | 105 |
| 106 // Can add |d_member0| again (satisfied), with a different cookie. | 106 // Can add |d_member0| again (satisfied), with a different cookie. |
| 107 static constexpr uint64_t kCookie2 = 0x3456789abcdef012ULL; | 107 static constexpr uint64_t kCookie2 = 0x3456789abcdef012ULL; |
| 108 static constexpr auto kSignals2 = kW; | 108 static constexpr auto kSignals2 = kW; |
| 109 EXPECT_EQ(MOJO_RESULT_OK, d->WaitSetAdd(NullUserPointer(), d_member0.Clone(), | 109 EXPECT_EQ(MOJO_RESULT_OK, d->WaitSetAdd(d_member0.Clone(), kSignals2, |
| 110 kSignals2, kCookie2)); | 110 kCookie2, NullUserPointer())); |
| 111 | 111 |
| 112 // Adding something with the same cookie yields "already exists". | 112 // Adding something with the same cookie yields "already exists". |
| 113 EXPECT_EQ(MOJO_RESULT_ALREADY_EXISTS, | 113 EXPECT_EQ(MOJO_RESULT_ALREADY_EXISTS, |
| 114 d->WaitSetAdd(NullUserPointer(), d_member1.Clone(), kR, kCookie2)); | 114 d->WaitSetAdd(d_member1.Clone(), kR, kCookie2, NullUserPointer())); |
| 115 | 115 |
| 116 // Can remove something based on a cookie. | 116 // Can remove something based on a cookie. |
| 117 EXPECT_EQ(MOJO_RESULT_OK, d->WaitSetRemove(kCookie0)); | 117 EXPECT_EQ(MOJO_RESULT_OK, d->WaitSetRemove(kCookie0)); |
| 118 | 118 |
| 119 // Trying to remove the same cookie again should fail. | 119 // Trying to remove the same cookie again should fail. |
| 120 EXPECT_EQ(MOJO_RESULT_NOT_FOUND, d->WaitSetRemove(kCookie0)); | 120 EXPECT_EQ(MOJO_RESULT_NOT_FOUND, d->WaitSetRemove(kCookie0)); |
| 121 | 121 |
| 122 // Can re-add it (still not satisfied, but satisfiable). | 122 // Can re-add it (still not satisfied, but satisfiable). |
| 123 EXPECT_EQ(MOJO_RESULT_OK, | 123 EXPECT_EQ(MOJO_RESULT_OK, |
| 124 d->WaitSetAdd(NullUserPointer(), d_member0.Clone(), kR, kCookie0)); | 124 d->WaitSetAdd(d_member0.Clone(), kR, kCookie0, NullUserPointer())); |
| 125 | 125 |
| 126 // Wait. Recall: | 126 // Wait. Recall: |
| 127 // - |kCookie0| is for |d_member0| and is not satisfied (but satisfiable). | 127 // - |kCookie0| is for |d_member0| and is not satisfied (but satisfiable). |
| 128 // - |kCookie1| is for |d_member1| and is satisfied. | 128 // - |kCookie1| is for |d_member1| and is satisfied. |
| 129 // - |kCookie2| is for |d_member0| and is satisfied. | 129 // - |kCookie2| is for |d_member0| and is satisfied. |
| 130 { | 130 { |
| 131 uint32_t num_results = 10u; | 131 uint32_t num_results = 10u; |
| 132 MojoWaitSetResult results[10] = {}; | 132 MojoWaitSetResult results[10] = {}; |
| 133 uint32_t max_results = static_cast<uint32_t>(-1); | 133 uint32_t max_results = static_cast<uint32_t>(-1); |
| 134 EXPECT_EQ(MOJO_RESULT_OK, | 134 EXPECT_EQ(MOJO_RESULT_OK, |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 EXPECT_GT(elapsed, test::EpsilonTimeout()); | 285 EXPECT_GT(elapsed, test::EpsilonTimeout()); |
| 286 EXPECT_LT(elapsed, 3 * test::EpsilonTimeout()); | 286 EXPECT_LT(elapsed, 3 * test::EpsilonTimeout()); |
| 287 // The inputs should be untouched. | 287 // The inputs should be untouched. |
| 288 EXPECT_EQ(1u, num_results); | 288 EXPECT_EQ(1u, num_results); |
| 289 EXPECT_EQ(456u, results[0].cookie); | 289 EXPECT_EQ(456u, results[0].cookie); |
| 290 EXPECT_EQ(789u, max_results); | 290 EXPECT_EQ(789u, max_results); |
| 291 } | 291 } |
| 292 | 292 |
| 293 auto d_member = MakeRefCounted<test::MockSimpleDispatcher>( | 293 auto d_member = MakeRefCounted<test::MockSimpleDispatcher>( |
| 294 MOJO_HANDLE_SIGNAL_NONE, MOJO_HANDLE_SIGNAL_READABLE); | 294 MOJO_HANDLE_SIGNAL_NONE, MOJO_HANDLE_SIGNAL_READABLE); |
| 295 EXPECT_EQ(MOJO_RESULT_OK, d->WaitSetAdd(NullUserPointer(), d_member.Clone(), | 295 EXPECT_EQ(MOJO_RESULT_OK, |
| 296 MOJO_HANDLE_SIGNAL_READABLE, 123u)); | 296 d->WaitSetAdd(d_member.Clone(), MOJO_HANDLE_SIGNAL_READABLE, 123u, |
| 297 NullUserPointer())); |
| 297 | 298 |
| 298 // Wait with timeout with an unsatisfied (but satisfiable) entry. | 299 // Wait with timeout with an unsatisfied (but satisfiable) entry. |
| 299 { | 300 { |
| 300 uint32_t num_results = 1u; | 301 uint32_t num_results = 1u; |
| 301 MojoWaitSetResult results[1] = {{456u}}; | 302 MojoWaitSetResult results[1] = {{456u}}; |
| 302 uint32_t max_results = 789u; | 303 uint32_t max_results = 789u; |
| 303 stopwatch.Start(); | 304 stopwatch.Start(); |
| 304 EXPECT_EQ(MOJO_RESULT_DEADLINE_EXCEEDED, | 305 EXPECT_EQ(MOJO_RESULT_DEADLINE_EXCEEDED, |
| 305 d->WaitSetWait( | 306 d->WaitSetWait( |
| 306 2 * test::EpsilonTimeout(), MakeUserPointer(&num_results), | 307 2 * test::EpsilonTimeout(), MakeUserPointer(&num_results), |
| (...skipping 20 matching lines...) Expand all Loading... |
| 327 | 328 |
| 328 auto d = WaitSetDispatcher::Create(WaitSetDispatcher::kDefaultCreateOptions); | 329 auto d = WaitSetDispatcher::Create(WaitSetDispatcher::kDefaultCreateOptions); |
| 329 | 330 |
| 330 // These will be members of our wait set. | 331 // These will be members of our wait set. |
| 331 auto d_member0 = MakeRefCounted<test::MockSimpleDispatcher>(kNone, kR | kW); | 332 auto d_member0 = MakeRefCounted<test::MockSimpleDispatcher>(kNone, kR | kW); |
| 332 auto d_member1 = MakeRefCounted<test::MockSimpleDispatcher>(kNone, kR); | 333 auto d_member1 = MakeRefCounted<test::MockSimpleDispatcher>(kNone, kR); |
| 333 | 334 |
| 334 // Add |d_member0|. | 335 // Add |d_member0|. |
| 335 static constexpr uint64_t kCookie0 = 123u; | 336 static constexpr uint64_t kCookie0 = 123u; |
| 336 static constexpr auto kSignals0 = kR; | 337 static constexpr auto kSignals0 = kR; |
| 337 EXPECT_EQ(MOJO_RESULT_OK, d->WaitSetAdd(NullUserPointer(), d_member0.Clone(), | 338 EXPECT_EQ(MOJO_RESULT_OK, d->WaitSetAdd(d_member0.Clone(), kSignals0, |
| 338 kSignals0, kCookie0)); | 339 kCookie0, NullUserPointer())); |
| 339 | 340 |
| 340 // Add |d_member1|. | 341 // Add |d_member1|. |
| 341 static constexpr uint64_t kCookie1 = 456u; | 342 static constexpr uint64_t kCookie1 = 456u; |
| 342 static constexpr auto kSignals1 = kR; | 343 static constexpr auto kSignals1 = kR; |
| 343 EXPECT_EQ(MOJO_RESULT_OK, d->WaitSetAdd(NullUserPointer(), d_member1.Clone(), | 344 EXPECT_EQ(MOJO_RESULT_OK, d->WaitSetAdd(d_member1.Clone(), kSignals1, |
| 344 kSignals1, kCookie1)); | 345 kCookie1, NullUserPointer())); |
| 345 | 346 |
| 346 // Can add |d_member0| again with a different cookie. | 347 // Can add |d_member0| again with a different cookie. |
| 347 static constexpr uint64_t kCookie2 = 789u; | 348 static constexpr uint64_t kCookie2 = 789u; |
| 348 static constexpr auto kSignals2 = kW; | 349 static constexpr auto kSignals2 = kW; |
| 349 EXPECT_EQ(MOJO_RESULT_OK, d->WaitSetAdd(NullUserPointer(), d_member0.Clone(), | 350 EXPECT_EQ(MOJO_RESULT_OK, d->WaitSetAdd(d_member0.Clone(), kSignals2, |
| 350 kSignals2, kCookie2)); | 351 kCookie2, NullUserPointer())); |
| 351 | 352 |
| 352 // We'll wait on the main thread, and do stuff on another thread. | 353 // We'll wait on the main thread, and do stuff on another thread. |
| 353 | 354 |
| 354 { | 355 { |
| 355 // Trigger |kCookie0|. | 356 // Trigger |kCookie0|. |
| 356 std::thread t([epsilon, d_member0]() { | 357 std::thread t([epsilon, d_member0]() { |
| 357 // Sleep to try to ensure that waiting has started. | 358 // Sleep to try to ensure that waiting has started. |
| 358 ThreadSleep(epsilon); | 359 ThreadSleep(epsilon); |
| 359 d_member0->SetSatisfiedSignals(kR); | 360 d_member0->SetSatisfiedSignals(kR); |
| 360 }); | 361 }); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 static constexpr uint64_t kCookie2 = 789u; | 480 static constexpr uint64_t kCookie2 = 789u; |
| 480 static constexpr auto kSignals2 = kR | kW; | 481 static constexpr auto kSignals2 = kR | kW; |
| 481 | 482 |
| 482 // We'll wait on the main thread, and do stuff on another thread. | 483 // We'll wait on the main thread, and do stuff on another thread. |
| 483 | 484 |
| 484 { | 485 { |
| 485 // Add |kCookie0|. | 486 // Add |kCookie0|. |
| 486 std::thread t0([epsilon, d, d_member]() { | 487 std::thread t0([epsilon, d, d_member]() { |
| 487 // Sleep to try to ensure that waiting has started. | 488 // Sleep to try to ensure that waiting has started. |
| 488 ThreadSleep(epsilon); | 489 ThreadSleep(epsilon); |
| 489 EXPECT_EQ(MOJO_RESULT_OK, | 490 EXPECT_EQ(MOJO_RESULT_OK, d->WaitSetAdd(d_member.Clone(), kSignals0, |
| 490 d->WaitSetAdd(NullUserPointer(), d_member.Clone(), kSignals0, | 491 kCookie0, NullUserPointer())); |
| 491 kCookie0)); | |
| 492 }); | 492 }); |
| 493 // Trigger |kCookie0| after |2 * epsilon| on another thread. | 493 // Trigger |kCookie0| after |2 * epsilon| on another thread. |
| 494 stopwatch.Start(); | 494 stopwatch.Start(); |
| 495 std::thread t1([epsilon, d_member]() { | 495 std::thread t1([epsilon, d_member]() { |
| 496 ThreadSleep(2 * epsilon); | 496 ThreadSleep(2 * epsilon); |
| 497 d_member->SetSatisfiedSignals(kR); | 497 d_member->SetSatisfiedSignals(kR); |
| 498 }); | 498 }); |
| 499 | 499 |
| 500 uint32_t num_results = 10u; | 500 uint32_t num_results = 10u; |
| 501 MojoWaitSetResult results[10] = {}; | 501 MojoWaitSetResult results[10] = {}; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 524 // Remove |kCookie0|. | 524 // Remove |kCookie0|. |
| 525 std::thread t0([epsilon, d]() { | 525 std::thread t0([epsilon, d]() { |
| 526 // Sleep to try to ensure that waiting has started. | 526 // Sleep to try to ensure that waiting has started. |
| 527 ThreadSleep(epsilon); | 527 ThreadSleep(epsilon); |
| 528 EXPECT_EQ(MOJO_RESULT_OK, d->WaitSetRemove(kCookie0)); | 528 EXPECT_EQ(MOJO_RESULT_OK, d->WaitSetRemove(kCookie0)); |
| 529 }); | 529 }); |
| 530 // Add |kCookie1|. | 530 // Add |kCookie1|. |
| 531 std::thread t1([epsilon, d, d_member]() { | 531 std::thread t1([epsilon, d, d_member]() { |
| 532 // Sleep to try to ensure that waiting has started. | 532 // Sleep to try to ensure that waiting has started. |
| 533 ThreadSleep(epsilon); | 533 ThreadSleep(epsilon); |
| 534 EXPECT_EQ(MOJO_RESULT_OK, | 534 EXPECT_EQ(MOJO_RESULT_OK, d->WaitSetAdd(d_member.Clone(), kSignals1, |
| 535 d->WaitSetAdd(NullUserPointer(), d_member.Clone(), kSignals1, | 535 kCookie1, NullUserPointer())); |
| 536 kCookie1)); | |
| 537 }); | 536 }); |
| 538 // Add |kCookie2|. | 537 // Add |kCookie2|. |
| 539 std::thread t2([epsilon, d, d_member]() { | 538 std::thread t2([epsilon, d, d_member]() { |
| 540 // Sleep to try to ensure that waiting has started. | 539 // Sleep to try to ensure that waiting has started. |
| 541 ThreadSleep(epsilon); | 540 ThreadSleep(epsilon); |
| 542 EXPECT_EQ(MOJO_RESULT_OK, | 541 EXPECT_EQ(MOJO_RESULT_OK, d->WaitSetAdd(d_member.Clone(), kSignals2, |
| 543 d->WaitSetAdd(NullUserPointer(), d_member.Clone(), kSignals2, | 542 kCookie2, NullUserPointer())); |
| 544 kCookie2)); | |
| 545 }); | 543 }); |
| 546 // Trigger |kCookie1| and |kCookie2| after |2 * epsilon| on another thread. | 544 // Trigger |kCookie1| and |kCookie2| after |2 * epsilon| on another thread. |
| 547 stopwatch.Start(); | 545 stopwatch.Start(); |
| 548 std::thread t3([epsilon, d_member]() { | 546 std::thread t3([epsilon, d_member]() { |
| 549 ThreadSleep(2 * epsilon); | 547 ThreadSleep(2 * epsilon); |
| 550 d_member->SetSatisfiedSignals(kW); | 548 d_member->SetSatisfiedSignals(kW); |
| 551 }); | 549 }); |
| 552 | 550 |
| 553 uint32_t num_results = 10u; | 551 uint32_t num_results = 10u; |
| 554 MojoWaitSetResult results[10] = {}; | 552 MojoWaitSetResult results[10] = {}; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 const auto epsilon = test::EpsilonTimeout(); | 606 const auto epsilon = test::EpsilonTimeout(); |
| 609 | 607 |
| 610 Stopwatch stopwatch; | 608 Stopwatch stopwatch; |
| 611 | 609 |
| 612 auto d = WaitSetDispatcher::Create(WaitSetDispatcher::kDefaultCreateOptions); | 610 auto d = WaitSetDispatcher::Create(WaitSetDispatcher::kDefaultCreateOptions); |
| 613 auto d_member = MakeRefCounted<test::MockSimpleDispatcher>(kNone, kR); | 611 auto d_member = MakeRefCounted<test::MockSimpleDispatcher>(kNone, kR); |
| 614 | 612 |
| 615 { | 613 { |
| 616 // Add an entry. | 614 // Add an entry. |
| 617 EXPECT_EQ(MOJO_RESULT_OK, | 615 EXPECT_EQ(MOJO_RESULT_OK, |
| 618 d->WaitSetAdd(NullUserPointer(), d_member.Clone(), kR, 123u)); | 616 d->WaitSetAdd(d_member.Clone(), kR, 123u, NullUserPointer())); |
| 619 | 617 |
| 620 // Wait on a bunch of threads. We'll trigger on the main thread. | 618 // Wait on a bunch of threads. We'll trigger on the main thread. |
| 621 std::vector<std::thread> threads; | 619 std::vector<std::thread> threads; |
| 622 for (size_t i = 0; i < 4; i++) { | 620 for (size_t i = 0; i < 4; i++) { |
| 623 threads.push_back(std::thread([epsilon, d, d_member]() { | 621 threads.push_back(std::thread([epsilon, d, d_member]() { |
| 624 uint32_t num_results = 10u; | 622 uint32_t num_results = 10u; |
| 625 MojoWaitSetResult results[10] = {}; | 623 MojoWaitSetResult results[10] = {}; |
| 626 EXPECT_EQ(MOJO_RESULT_OK, | 624 EXPECT_EQ(MOJO_RESULT_OK, |
| 627 d->WaitSetWait(5 * epsilon, MakeUserPointer(&num_results), | 625 d->WaitSetWait(5 * epsilon, MakeUserPointer(&num_results), |
| 628 MakeUserPointer(results), NullUserPointer())); | 626 MakeUserPointer(results), NullUserPointer())); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 uint64_t next_cookie = kQuitCookie + 1; | 679 uint64_t next_cookie = kQuitCookie + 1; |
| 682 // Cookie -> dispatcher map. Guarded by |mu|. | 680 // Cookie -> dispatcher map. Guarded by |mu|. |
| 683 std::map<uint64_t, RefPtr<test::MockSimpleDispatcher>> | 681 std::map<uint64_t, RefPtr<test::MockSimpleDispatcher>> |
| 684 cookie_to_dispatcher_map; | 682 cookie_to_dispatcher_map; |
| 685 | 683 |
| 686 auto wait_set = | 684 auto wait_set = |
| 687 WaitSetDispatcher::Create(WaitSetDispatcher::kDefaultCreateOptions); | 685 WaitSetDispatcher::Create(WaitSetDispatcher::kDefaultCreateOptions); |
| 688 // The quit dispatcher and entry. | 686 // The quit dispatcher and entry. |
| 689 auto quit = MakeRefCounted<test::MockSimpleDispatcher>(kNone, kSignal); | 687 auto quit = MakeRefCounted<test::MockSimpleDispatcher>(kNone, kSignal); |
| 690 EXPECT_EQ(MOJO_RESULT_OK, | 688 EXPECT_EQ(MOJO_RESULT_OK, |
| 691 wait_set->WaitSetAdd(NullUserPointer(), quit.Clone(), kSignal, | 689 wait_set->WaitSetAdd(quit.Clone(), kSignal, kQuitCookie, |
| 692 kQuitCookie)); | 690 NullUserPointer())); |
| 693 | 691 |
| 694 std::vector<std::thread> threads; | 692 std::vector<std::thread> threads; |
| 695 | 693 |
| 696 // Add waiter threads. | 694 // Add waiter threads. |
| 697 for (size_t i = 0; i < kNumWaiters; i++) { | 695 for (size_t i = 0; i < kNumWaiters; i++) { |
| 698 threads.push_back(std::thread([&mu, &cookie_to_dispatcher_map, &wait_set, | 696 threads.push_back(std::thread([&mu, &cookie_to_dispatcher_map, &wait_set, |
| 699 i]() { | 697 i]() { |
| 700 uint64_t total_wakeups = 0; | 698 uint64_t total_wakeups = 0; |
| 701 | 699 |
| 702 for (;;) { | 700 for (;;) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 MakeRefCounted<test::MockSimpleDispatcher>(kNone, kSignal); | 758 MakeRefCounted<test::MockSimpleDispatcher>(kNone, kSignal); |
| 761 uint64_t new_cookie; | 759 uint64_t new_cookie; |
| 762 { | 760 { |
| 763 MutexLocker locker(&mu); | 761 MutexLocker locker(&mu); |
| 764 new_cookie = next_cookie++; | 762 new_cookie = next_cookie++; |
| 765 cookie_to_dispatcher_map[new_cookie] = new_dispatcher; | 763 cookie_to_dispatcher_map[new_cookie] = new_dispatcher; |
| 766 dispatchers.push_back(new_dispatcher); | 764 dispatchers.push_back(new_dispatcher); |
| 767 cookies.push_back(new_cookie); | 765 cookies.push_back(new_cookie); |
| 768 } | 766 } |
| 769 EXPECT_NE(new_cookie, kQuitCookie); | 767 EXPECT_NE(new_cookie, kQuitCookie); |
| 770 EXPECT_EQ( | 768 EXPECT_EQ(MOJO_RESULT_OK, |
| 771 MOJO_RESULT_OK, | 769 wait_set->WaitSetAdd(std::move(new_dispatcher), kSignal, |
| 772 wait_set->WaitSetAdd(NullUserPointer(), std::move(new_dispatcher), | 770 new_cookie, NullUserPointer())); |
| 773 kSignal, new_cookie)); | |
| 774 } | 771 } |
| 775 | 772 |
| 776 // Should we trigger an entry? Make the probability be (current number) | 773 // Should we trigger an entry? Make the probability be (current number) |
| 777 // / (maximum number). | 774 // / (maximum number). |
| 778 int j = test::RandomInt(0, static_cast<int>(kMaxEntriesPerWorker - 1)); | 775 int j = test::RandomInt(0, static_cast<int>(kMaxEntriesPerWorker - 1)); |
| 779 if (j < static_cast<int>(dispatchers.size())) { | 776 if (j < static_cast<int>(dispatchers.size())) { |
| 780 total_triggers++; | 777 total_triggers++; |
| 781 | 778 |
| 782 // Just use |j| as an index into |dispatchers|/|cookies|. | 779 // Just use |j| as an index into |dispatchers|/|cookies|. |
| 783 dispatchers[j]->SetSatisfiedSignals(kSignal); | 780 dispatchers[j]->SetSatisfiedSignals(kSignal); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 EXPECT_EQ(MOJO_RESULT_OK, quit->Close()); | 822 EXPECT_EQ(MOJO_RESULT_OK, quit->Close()); |
| 826 EXPECT_EQ(MOJO_RESULT_OK, wait_set->Close()); | 823 EXPECT_EQ(MOJO_RESULT_OK, wait_set->Close()); |
| 827 } | 824 } |
| 828 | 825 |
| 829 // TODO(vtl): Test options validation for "create" and "add" (not that there's | 826 // TODO(vtl): Test options validation for "create" and "add" (not that there's |
| 830 // much to test). | 827 // much to test). |
| 831 | 828 |
| 832 } // namespace | 829 } // namespace |
| 833 } // namespace system | 830 } // namespace system |
| 834 } // namespace mojo | 831 } // namespace mojo |
| OLD | NEW |