OLD | NEW |
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= | 5 // VMOptions= |
6 // VMOptions=--short_socket_read | 6 // VMOptions=--short_socket_read |
7 // VMOptions=--short_socket_write | 7 // VMOptions=--short_socket_write |
8 // VMOptions=--short_socket_read --short_socket_write | 8 // VMOptions=--short_socket_read --short_socket_write |
9 | 9 |
10 import 'dart:io'; | 10 import 'dart:io'; |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 message.port); | 233 message.port); |
234 clientPorts[i].send(command, clientStatusPorts[i].toSendPort()); | 234 clientPorts[i].send(command, clientStatusPorts[i].toSendPort()); |
235 } | 235 } |
236 } else if (message.isError) { | 236 } else if (message.isError) { |
237 print("Could not start server - probably error \"Address already in
use\" from bind."); | 237 print("Could not start server - probably error \"Address already in
use\" from bind."); |
238 serverStatusPort.close(); | 238 serverStatusPort.close(); |
239 } | 239 } |
240 }); | 240 }); |
241 | 241 |
242 // Prepare the requested number of clients. | 242 // Prepare the requested number of clients. |
243 clientPorts = new List<SendPort>.fixedLength(clientCount); | 243 clientPorts = new List<SendPort>(clientCount); |
244 int liveClientsCount = 0; | 244 int liveClientsCount = 0; |
245 clientStatusPorts = new List<ReceivePort>.fixedLength(clientCount); | 245 clientStatusPorts = new List<ReceivePort>(clientCount); |
246 for (int i = 0; i < clientCount; i++) { | 246 for (int i = 0; i < clientCount; i++) { |
247 ReceivePort statusPort = new ReceivePort(); | 247 ReceivePort statusPort = new ReceivePort(); |
248 statusPort.receive((var message, SendPort replyTo) { | 248 statusPort.receive((var message, SendPort replyTo) { |
249 // First and only message from the client indicates that | 249 // First and only message from the client indicates that |
250 // the test is done. | 250 // the test is done. |
251 Expect.equals("Test succeeded", message); | 251 Expect.equals("Test succeeded", message); |
252 statusPort.close(); | 252 statusPort.close(); |
253 finishedClients++; | 253 finishedClients++; |
254 | 254 |
255 // If all clients are finished shutdown the server. | 255 // If all clients are finished shutdown the server. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 TestMain testMain = new TestMain.run(10, 2); | 310 TestMain testMain = new TestMain.run(10, 2); |
311 } | 311 } |
312 | 312 |
313 | 313 |
314 void main() { | 314 void main() { |
315 testOneClient(); | 315 testOneClient(); |
316 testTwoClients(); | 316 testTwoClients(); |
317 testTwoClientsMoreMessages(); | 317 testTwoClientsMoreMessages(); |
318 testTenClients(); | 318 testTenClients(); |
319 } | 319 } |
OLD | NEW |