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

Unified Diff: runtime/vm/message_test.cc

Issue 10052011: Fix flaky message queue test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix comment. Created 8 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 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/message_test.cc
diff --git a/runtime/vm/message_test.cc b/runtime/vm/message_test.cc
index dfbe1b93c42bd0c19ba8309133428e4d4dbd6809..6f9cbe157dad5614a57a686d1bd4c4c5808c335b 100644
--- a/runtime/vm/message_test.cc
+++ b/runtime/vm/message_test.cc
@@ -130,21 +130,30 @@ void MessageReceiver_start(uword unused) {
ml.Wait(5);
}
- for (int i = 0; i < 3; i++) {
+ int i = 0;
+ while (i < 3) {
Message* msg = queue->Dequeue(0);
- EXPECT(msg != NULL);
- EXPECT_EQ(i + 10, msg->dest_port());
- EXPECT_EQ(i + 100, msg->reply_port());
- EXPECT_EQ(i + 1000, *(reinterpret_cast<int*>(msg->data())));
- delete msg;
+ // Dequeue(0) can return NULL due to spurious wakeup.
+ if (msg != NULL) {
+ EXPECT_EQ(i + 10, msg->dest_port());
+ EXPECT_EQ(i + 100, msg->reply_port());
+ EXPECT_EQ(i + 1000, *(reinterpret_cast<int*>(msg->data())));
+ delete msg;
+ i++;
+ }
}
- for (int i = 0; i < 3; i++) {
+
+ i = 0;
+ while (i < 3) {
Message* msg = queue->Dequeue(0);
- EXPECT(msg != NULL);
- EXPECT_EQ(i + 20, msg->dest_port());
- EXPECT_EQ(i + 200, msg->reply_port());
- EXPECT_EQ(i + 2000, *(reinterpret_cast<int*>(msg->data())));
- delete msg;
+ // Dequeue(0) can return NULL due to spurious wakeup.
+ if (msg != NULL) {
+ EXPECT_EQ(i + 20, msg->dest_port());
+ EXPECT_EQ(i + 200, msg->reply_port());
+ EXPECT_EQ(i + 2000, *(reinterpret_cast<int*>(msg->data())));
+ delete msg;
+ i++;
+ }
}
shared_queue = NULL;
delete queue;
« 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