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

Side by Side Diff: tests/standalone/src/SocketCloseTest.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/socket_impl.dart ('k') | tests/standalone/src/SocketStreamCloseTest.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 // 4 //
5 // VMOptions=
6 // VMOptions=--short_socket_read
7 // VMOptions=--short_socket_write
8 // VMOptions=--short_socket_read --short_socket_write
9 //
10 // Test socket close events. 5 // Test socket close events.
11 6
12 #import("dart:io"); 7 #import("dart:io");
13 8
14 final SERVERSHUTDOWN = -1; 9 final SERVERSHUTDOWN = -1;
15 final ITERATIONS = 10; 10 final ITERATIONS = 10;
16 11
17 12
18 class SocketClose { 13 class SocketClose {
19 14
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 void errorHandler() { 89 void errorHandler() {
95 _errorEvents++; 90 _errorEvents++;
96 _socket.close(); 91 _socket.close();
97 } 92 }
98 93
99 void connectHandler() { 94 void connectHandler() {
100 _socket.dataHandler = dataHandler; 95 _socket.dataHandler = dataHandler;
101 _socket.closeHandler = closeHandler; 96 _socket.closeHandler = closeHandler;
102 _socket.errorHandler = errorHandler; 97 _socket.errorHandler = errorHandler;
103 98
104 void writeHello() {
105 int bytesWritten = 0;
106 while (bytesWritten != 5) {
107 bytesWritten += _socket.writeList("Hello".charCodes(),
108 bytesWritten,
109 5 - bytesWritten);
110 }
111 }
112
113 _iterations++; 99 _iterations++;
114 switch (_mode) { 100 switch (_mode) {
115 case 0: 101 case 0:
116 _socket.close(); 102 _socket.close();
117 proceed(); 103 proceed();
118 break; 104 break;
119 case 1: 105 case 1:
120 writeHello(); 106 int bytesWritten = _socket.writeList("Hello".charCodes(), 0, 5);
107 Expect.equals(5, bytesWritten);
121 _socket.close(); 108 _socket.close();
122 proceed(); 109 proceed();
123 break; 110 break;
124 case 2: 111 case 2:
125 case 3: 112 case 3:
126 writeHello(); 113 int bytesWritten = _socket.writeList("Hello".charCodes(), 0, 5);
114 Expect.equals(5, bytesWritten);
127 break; 115 break;
128 case 4: 116 case 4:
129 writeHello(); 117 int bytesWritten = _socket.writeList("Hello".charCodes(), 0, 5);
118 Expect.equals(5, bytesWritten);
130 _socket.close(true); 119 _socket.close(true);
131 break; 120 break;
132 case 5: 121 case 5:
133 writeHello(); 122 int bytesWritten = _socket.writeList("Hello".charCodes(), 0, 5);
123 Expect.equals(5, bytesWritten);
134 break; 124 break;
135 case 6: 125 case 6:
136 writeHello(); 126 int bytesWritten = _socket.writeList("Hello".charCodes(), 0, 5);
127 Expect.equals(5, bytesWritten);
137 _socket.close(true); 128 _socket.close(true);
138 break; 129 break;
139 default: 130 default:
140 Expect.fail("Unknown test mode"); 131 Expect.fail("Unknown test mode");
141 } 132 }
142 } 133 }
143 134
144 _socket = new Socket(SocketCloseServer.HOST, _port); 135 _socket = new Socket(SocketCloseServer.HOST, _port);
145 Expect.equals(true, _socket !== null); 136 Expect.equals(true, _socket !== null);
146 _socket.connectHandler = connectHandler; 137 _socket.connectHandler = connectHandler;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 void connectionHandler(Socket connection) { 196 void connectionHandler(Socket connection) {
206 197
207 void readBytes(whenFiveBytes) { 198 void readBytes(whenFiveBytes) {
208 List<int> b = new List<int>(100); 199 List<int> b = new List<int>(100);
209 _readBytes += connection.readList(b, 0, 100); 200 _readBytes += connection.readList(b, 0, 100);
210 if ((_readBytes % 5) == 0) { 201 if ((_readBytes % 5) == 0) {
211 whenFiveBytes(); 202 whenFiveBytes();
212 } 203 }
213 } 204 }
214 205
215 void writeHello() {
216 int bytesWritten = 0;
217 while (bytesWritten != 5) {
218 bytesWritten += connection.writeList("Hello".charCodes(),
219 bytesWritten,
220 5 - bytesWritten);
221 }
222 }
223
224 void dataHandler() { 206 void dataHandler() {
207 _dataEvents++;
225 switch (_mode) { 208 switch (_mode) {
226 case 0: 209 case 0:
227 Expect.fail("No data expected"); 210 Expect.fail("No data expected");
228 break; 211 break;
229 case 1: 212 case 1:
230 readBytes(() { _dataEvents++; }); 213 readBytes(() { });
231 break; 214 break;
232 case 2: 215 case 2:
233 readBytes(() { 216 readBytes(() {
234 _dataEvents++;
235 connection.close(); 217 connection.close();
236 }); 218 });
237 break; 219 break;
238 case 3: 220 case 3:
239 readBytes(() { 221 readBytes(() {
240 _dataEvents++; 222 connection.writeList("Hello".charCodes(), 0, 5);
241 writeHello();
242 connection.close(); 223 connection.close();
243 }); 224 });
244 break; 225 break;
245 case 4: 226 case 4:
246 readBytes(() { 227 readBytes(() {
247 _dataEvents++; 228 connection.writeList("Hello".charCodes(), 0, 5);
248 writeHello();
249 }); 229 });
250 break; 230 break;
251 case 5: 231 case 5:
252 case 6: 232 case 6:
253 readBytes(() { 233 readBytes(() {
254 _dataEvents++; 234 connection.writeList("Hello".charCodes(), 0, 5);
255 writeHello();
256 connection.close(true); 235 connection.close(true);
257 }); 236 });
258 break; 237 break;
259 default: 238 default:
260 Expect.fail("Unknown test mode"); 239 Expect.fail("Unknown test mode");
261 } 240 }
262 } 241 }
263 242
264 void closeHandler() { 243 void closeHandler() {
265 _closeEvents++; 244 _closeEvents++;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 // 5: Client sends. Server responds and half closes. 337 // 5: Client sends. Server responds and half closes.
359 // 6: Client sends and half-closes. Server responds and half closes. 338 // 6: Client sends and half-closes. Server responds and half closes.
360 new SocketClose.start(0); 339 new SocketClose.start(0);
361 new SocketClose.start(1); 340 new SocketClose.start(1);
362 new SocketClose.start(2); 341 new SocketClose.start(2);
363 new SocketClose.start(3); 342 new SocketClose.start(3);
364 new SocketClose.start(4); 343 new SocketClose.start(4);
365 new SocketClose.start(5); 344 new SocketClose.start(5);
366 new SocketClose.start(6); 345 new SocketClose.start(6);
367 } 346 }
OLDNEW
« 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