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

Unified Diff: runtime/vm/thread_test.cc

Issue 11361157: Fix bug 6586: (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/platform/thread_macos.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/thread_test.cc
===================================================================
--- runtime/vm/thread_test.cc (revision 14653)
+++ runtime/vm/thread_test.cc (working copy)
@@ -39,17 +39,35 @@
monitor->Enter();
monitor->Exit();
- {
+ const int kNumAttempts = 5;
+ int attempts = 0;
+ while (true) {
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);
siva 2012/11/07 23:41:02 Is this print statement needed?
Ivan Posva 2012/11/08 18:01:08 It is needed to be able to figure out the wakeup t
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.
+ if (attempts++ == kNumAttempts) {
+ // Ran out of attempts. Record the failure and break out of the loop.
+ OS::Print("Failed %d consecutive attempts.\n", kNumAttempts);
siva 2012/11/07 23:41:02 OS::Print("Monitor.wait test failed %d.....
Ivan Posva 2012/11/08 18:01:08 The test harness around it identifies the test. I
+ EXPECT(false);
+ break;
+ }
}
// The isolate shutdown and the destruction of the mutex are out-of-order on
// purpose.
« no previous file with comments | « runtime/platform/thread_macos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698