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

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 9016007: Update the isolate interrupt test (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl_test.cc
diff --git a/runtime/vm/dart_api_impl_test.cc b/runtime/vm/dart_api_impl_test.cc
index fc4daf616fcb19e42bdb3ca691085963de05c013..8ec52403e3107eb883df393c3bf09ff7f489918c 100644
--- a/runtime/vm/dart_api_impl_test.cc
+++ b/runtime/vm/dart_api_impl_test.cc
@@ -3046,6 +3046,7 @@ void BusyLoop_start(uword unused) {
// This callback handles isolate interrupts for the IsolateInterrupt
// test. It ignores the first two interrupts and throws an exception
// on the third interrupt.
+const int kInterruptCount = 10;
static int interrupt_count = 0;
static bool IsolateInterruptTestCallback() {
OS::Print(" ========== Interrupt callback called #%d\n", interrupt_count + 1);
@@ -3054,7 +3055,7 @@ static bool IsolateInterruptTestCallback() {
interrupt_count++;
ml.Notify();
}
- if (interrupt_count >= 3) {
+ if (interrupt_count == kInterruptCount) {
Dart_EnterScope();
Dart_Handle lib = Dart_LookupLibrary(Dart_NewString(TestCase::url()));
EXPECT_VALID(lib);
@@ -3065,6 +3066,7 @@ static bool IsolateInterruptTestCallback() {
UNREACHABLE(); // Dart_ThrowException only returns if it gets an error.
return false;
}
+ ASSERT(interrupt_count < kInterruptCount);
return true;
}
@@ -3085,10 +3087,10 @@ TEST_CASE(IsolateInterrupt) {
}
}
- // Send three interrupts to the other isolate. The first two allow
- // execution to continue. The third causes an exception in the
- // isolate.
- for (int i = 0; i < 3; i++) {
+ // Send a number of interrupts to the other isolate. All but the
+ // last allow execution to continue. The last causes an exception in
+ // the isolate.
+ for (int i = 0; i < kInterruptCount; i++) {
Dart_InterruptIsolate(shared_isolate);
{
MonitorLocker ml(sync);
@@ -3098,6 +3100,8 @@ TEST_CASE(IsolateInterrupt) {
}
OS::Print(" ========== Interrupt processed #%d\n", interrupt_count);
}
+ // Space out the interrupts a bit.
+ OS::Sleep(i + 1);
Ivan Posva 2011/12/21 17:27:14 If you move OS::Sleep(i) before the call to Dart_I
Søren Gjesse 2011/12/22 08:21:26 Done.
}
{
@@ -3108,8 +3112,8 @@ TEST_CASE(IsolateInterrupt) {
}
}
- // We should have received 3 interrupts.
- EXPECT_EQ(3, interrupt_count);
+ // We should have received the expected number of interrupts.
+ EXPECT_EQ(kInterruptCount, interrupt_count);
// Give the spawned thread enough time to properly exit.
Isolate::SetInterruptCallback(saved);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698