Index: runtime/vm/thread_test.cc |
=================================================================== |
--- runtime/vm/thread_test.cc (revision 14653) |
+++ runtime/vm/thread_test.cc (working copy) |
@@ -39,18 +39,33 @@ |
monitor->Enter(); |
monitor->Exit(); |
- { |
+ const int kNumAttempts = 5; |
+ int attempts = 0; |
+ while (attempts < kNumAttempts) { |
MonitorLocker ml(monitor); |
int64_t start = OS::GetCurrentTimeMillis(); |
int64_t wait_time = 2017; |
Monitor::WaitResult wait_result = ml.Wait(wait_time); |
int64_t stop = OS::GetCurrentTimeMillis(); |
+ |
+ // We expect to be timing out here. |
EXPECT_EQ(Monitor::kTimedOut, wait_result); |
+ |
+ // Check whether this attempt falls within the exptected time limits. |
+ int64_t wakeup_time = stop - start; |
+ OS::Print("wakeup_time: %"Pd64"\n", wakeup_time); |
const int kAcceptableTimeJitter = 20; // Measured in milliseconds. |
- EXPECT_LE(wait_time - kAcceptableTimeJitter, stop - start); |
const int kAcceptableWakeupDelay = 150; // Measured in milliseconds. |
- EXPECT_GE(wait_time + kAcceptableWakeupDelay, stop - start); |
+ if (((wait_time - kAcceptableTimeJitter) <= wakeup_time) && |
+ (wakeup_time <= (wait_time + kAcceptableWakeupDelay))) { |
+ break; |
+ } |
+ |
+ // Record the attempt. |
+ attempts++; |
} |
+ EXPECT_LT(attempts, kNumAttempts); |
+ |
// The isolate shutdown and the destruction of the mutex are out-of-order on |
// purpose. |
isolate->Shutdown(); |