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

Unified Diff: tests/standalone/src/SocketCloseTest.dart

Issue 9361034: Fix potential flakiness of SocketStreamCloseTest. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments Created 8 years, 10 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 | « runtime/bin/socket_impl.dart ('k') | tests/standalone/src/SocketStreamCloseTest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/src/SocketCloseTest.dart
diff --git a/tests/standalone/src/SocketCloseTest.dart b/tests/standalone/src/SocketCloseTest.dart
index ea7daf3646136c88f8d8e217a3df20038ca6b9a7..2f2f18220d6e8067e96e0b0bdc74d960f4bd31bb 100644
--- a/tests/standalone/src/SocketCloseTest.dart
+++ b/tests/standalone/src/SocketCloseTest.dart
@@ -2,6 +2,11 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
//
+// VMOptions=
+// VMOptions=--short_socket_read
+// VMOptions=--short_socket_write
+// VMOptions=--short_socket_read --short_socket_write
+//
// Test socket close events.
#import("dart:io");
@@ -96,6 +101,15 @@ class SocketClose {
_socket.closeHandler = closeHandler;
_socket.errorHandler = errorHandler;
+ void writeHello() {
+ int bytesWritten = 0;
+ while (bytesWritten != 5) {
+ bytesWritten += _socket.writeList("Hello".charCodes(),
+ bytesWritten,
+ 5 - bytesWritten);
+ }
+ }
+
_iterations++;
switch (_mode) {
case 0:
@@ -103,28 +117,23 @@ class SocketClose {
proceed();
break;
case 1:
- int bytesWritten = _socket.writeList("Hello".charCodes(), 0, 5);
- Expect.equals(5, bytesWritten);
+ writeHello();
_socket.close();
proceed();
break;
case 2:
case 3:
- int bytesWritten = _socket.writeList("Hello".charCodes(), 0, 5);
- Expect.equals(5, bytesWritten);
+ writeHello();
break;
case 4:
- int bytesWritten = _socket.writeList("Hello".charCodes(), 0, 5);
- Expect.equals(5, bytesWritten);
+ writeHello();
_socket.close(true);
break;
case 5:
- int bytesWritten = _socket.writeList("Hello".charCodes(), 0, 5);
- Expect.equals(5, bytesWritten);
+ writeHello();
break;
case 6:
- int bytesWritten = _socket.writeList("Hello".charCodes(), 0, 5);
- Expect.equals(5, bytesWritten);
+ writeHello();
_socket.close(true);
break;
default:
@@ -203,35 +212,47 @@ class SocketCloseServer extends Isolate {
}
}
+ void writeHello() {
+ int bytesWritten = 0;
+ while (bytesWritten != 5) {
+ bytesWritten += connection.writeList("Hello".charCodes(),
+ bytesWritten,
+ 5 - bytesWritten);
+ }
+ }
+
void dataHandler() {
- _dataEvents++;
switch (_mode) {
case 0:
Expect.fail("No data expected");
break;
case 1:
- readBytes(() { });
+ readBytes(() { _dataEvents++; });
break;
case 2:
readBytes(() {
+ _dataEvents++;
connection.close();
});
break;
case 3:
readBytes(() {
- connection.writeList("Hello".charCodes(), 0, 5);
+ _dataEvents++;
+ writeHello();
connection.close();
});
break;
case 4:
readBytes(() {
- connection.writeList("Hello".charCodes(), 0, 5);
+ _dataEvents++;
+ writeHello();
});
break;
case 5:
case 6:
readBytes(() {
- connection.writeList("Hello".charCodes(), 0, 5);
+ _dataEvents++;
+ writeHello();
connection.close(true);
});
break;
« no previous file with comments | « runtime/bin/socket_impl.dart ('k') | tests/standalone/src/SocketStreamCloseTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698