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

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

Issue 9368058: Revert "Fix potential flakiness of SocketStreamCloseTest." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 | « tests/standalone/src/SocketCloseTest.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/src/SocketStreamCloseTest.dart
diff --git a/tests/standalone/src/SocketStreamCloseTest.dart b/tests/standalone/src/SocketStreamCloseTest.dart
index ee8f594f3a0d047eae4e1accaacad1350276da64..ed788c5e420b1edaac576809043ddd621320dfd7 100644
--- a/tests/standalone/src/SocketStreamCloseTest.dart
+++ b/tests/standalone/src/SocketStreamCloseTest.dart
@@ -2,11 +2,6 @@
// 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");
@@ -20,7 +15,6 @@ class SocketClose {
SocketClose.start(mode)
: _receivePort = new ReceivePort(),
_sendPort = null,
- _readBytes = 0,
_dataEvents = 0,
_closeEvents = 0,
_errorEvents = 0,
@@ -53,13 +47,9 @@ class SocketClose {
case 4:
case 5:
case 6:
- case 7:
- case 8:
- var read = _socket.inputStream.read();
- _readBytes += read.length;
- if ((_readBytes % 5) == 0) {
- _dataEvents++;
- }
+ List<int> b = new List<int>(100);
+ _socket.readList(b, 0, 100);
+ _dataEvents++;
break;
default:
Expect.fail("Unknown test mode");
@@ -74,19 +64,17 @@ class SocketClose {
break;
case 2:
case 3:
- case 4:
_socket.outputStream.close();
proceed();
break;
- case 5:
+ case 4:
proceed();
break;
- case 6:
+ case 5:
_socket.outputStream.close();
proceed();
break;
- case 7:
- case 8:
+ case 6:
proceed();
break;
default:
@@ -112,31 +100,23 @@ class SocketClose {
break;
case 1:
_socket.outputStream.write("Hello".charCodes());
- _socket.outputStream.noPendingWriteHandler = () {
- _socket.inputStream.close();
- proceed();
- };
+ _socket.inputStream.close();
+ proceed();
break;
case 2:
case 3:
+ _socket.outputStream.write("Hello".charCodes());
+ break;
case 4:
_socket.outputStream.write("Hello".charCodes());
+ _socket.outputStream.close();
break;
case 5:
_socket.outputStream.write("Hello".charCodes());
- _socket.outputStream.noPendingWriteHandler = () {
- _socket.outputStream.close();
- };
break;
case 6:
_socket.outputStream.write("Hello".charCodes());
- break;
- case 7:
- case 8:
- _socket.outputStream.write("Hello".charCodes());
- _socket.outputStream.noPendingWriteHandler = () {
- _socket.outputStream.close();
- };
+ _socket.outputStream.close();
break;
default:
Expect.fail("Unknown test mode");
@@ -164,23 +144,16 @@ class SocketClose {
case 0:
case 1:
Expect.equals(0, _dataEvents);
- Expect.equals(ITERATIONS, _closeEvents);
+ Expect.equals(10, _closeEvents);
break;
case 2:
Expect.equals(0, _dataEvents);
Expect.equals(ITERATIONS, _closeEvents);
break;
case 3:
- Expect.equals(ITERATIONS, _dataEvents);
- Expect.equals(ITERATIONS, _closeEvents);
- break;
case 4:
- Expect.equals(ITERATIONS, _closeEvents);
- break;
case 5:
case 6:
- case 7:
- case 8:
Expect.equals(ITERATIONS, _dataEvents);
Expect.equals(ITERATIONS, _closeEvents);
break;
@@ -195,7 +168,6 @@ class SocketClose {
SendPort _sendPort;
Socket _socket;
List<int> _buffer;
- int _readBytes;
int _dataEvents;
int _closeEvents;
int _errorEvents;
@@ -213,66 +185,34 @@ class SocketCloseServer extends Isolate {
void connectionHandler(Socket connection) {
- void readBytes(whenFiveBytes) {
- var read = connection.inputStream.read();
- _readBytes += read.length;
- if ((_readBytes % 5) == 0) {
- whenFiveBytes();
- }
- }
-
void dataHandler() {
+ _dataEvents++;
switch (_mode) {
case 0:
Expect.fail("No data expected");
break;
case 1:
- readBytes(() => _dataEvents++);
+ connection.inputStream.read();
break;
case 2:
- readBytes(() {
- _dataEvents++;
- connection.inputStream.close();
- });
+ connection.inputStream.read();
+ connection.inputStream.close();
break;
case 3:
- readBytes(() {
- _dataEvents++;
- connection.outputStream.write("Hello".charCodes());
- connection.outputStream.noPendingWriteHandler = () {
- connection.inputStream.close();
- };
- });
+ connection.inputStream.read();
+ connection.outputStream.write("Hello".charCodes());
+ connection.inputStream.close();
+ //connection.outputStream.close();
break;
case 4:
- readBytes(() {
- _dataEvents++;
- connection.outputStream.write("Hello".charCodes());
- connection.inputStream.close();
- });
+ connection.inputStream.read();
+ connection.outputStream.write("Hello".charCodes());
break;
case 5:
- readBytes(() {
- _dataEvents++;
- connection.outputStream.write("Hello".charCodes());
- });
- break;
case 6:
- case 7:
- readBytes(() {
- _dataEvents++;
- connection.outputStream.write("Hello".charCodes());
- connection.outputStream.noPendingWriteHandler = () {
- connection.outputStream.close();
- };
- });
- break;
- case 8:
- readBytes(() {
- _dataEvents++;
- connection.outputStream.write("Hello".charCodes());
- connection.outputStream.close();
- });
+ connection.inputStream.read();
+ connection.outputStream.write("Hello".charCodes());
+ connection.outputStream.close();
break;
default:
Expect.fail("Unknown test mode");
@@ -281,7 +221,7 @@ class SocketCloseServer extends Isolate {
void closeHandler() {
_closeEvents++;
- connection.outputStream.close();
+ connection.close();
}
void errorHandler() {
@@ -317,14 +257,12 @@ class SocketCloseServer extends Isolate {
break;
case 2:
case 3:
- case 4:
Expect.equals(ITERATIONS, _dataEvents);
Expect.equals(ITERATIONS, _closeEvents);
break;
+ case 4:
case 5:
case 6:
- case 7:
- case 8:
Expect.equals(ITERATIONS, _dataEvents);
Expect.equals(ITERATIONS, _closeEvents);
break;
@@ -341,7 +279,6 @@ class SocketCloseServer extends Isolate {
this.port.receive((message, SendPort replyTo) {
if (message != SERVERSHUTDOWN) {
- _readBytes = 0;
_errorEvents = 0;
_dataEvents = 0;
_closeEvents = 0;
@@ -359,7 +296,6 @@ class SocketCloseServer extends Isolate {
}
ServerSocket _server;
- int _readBytes;
int _errorEvents;
int _dataEvents;
int _closeEvents;
@@ -374,13 +310,9 @@ main() {
// 1: Client sends and closes.
// 2: Client sends. Server closes.
// 3: Client sends. Server responds and closes.
- // 4: Client sends. Server responds and closes without waiting for everything
- // being sent.
- // 5: Client sends and half-closes. Server responds and closes.
- // 6: Client sends. Server responds and half closes.
- // 7: Client sends and half-closes. Server responds and half closes.
- // 8: Client sends and half-closes. Server responds and half closes without
- // explicitly waiting for everything being sent.
+ // 4: Client sends and half-closes. Server responds and closes.
+ // 5: Client sends. Server responds and half closes.
+ // 6: Client sends and half-closes. Server responds and half closes.
new SocketClose.start(0);
new SocketClose.start(1);
new SocketClose.start(2);
@@ -388,6 +320,4 @@ main() {
new SocketClose.start(4);
new SocketClose.start(5);
new SocketClose.start(6);
- new SocketClose.start(7);
- new SocketClose.start(8);
}
« no previous file with comments | « tests/standalone/src/SocketCloseTest.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698