| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 // 4. Pipes the socket output stream to the temp file. | 62 // 4. Pipes the socket output stream to the temp file. |
| 63 // 5. Expects the original file and the temp file to be equal. | 63 // 5. Expects the original file and the temp file to be equal. |
| 64 class PipeServerGame { | 64 class PipeServerGame { |
| 65 int count = 0; | 65 int count = 0; |
| 66 | 66 |
| 67 PipeServerGame.start() | 67 PipeServerGame.start() |
| 68 : _receivePort = new ReceivePort(), | 68 : _receivePort = new ReceivePort(), |
| 69 _sendPort = null, | 69 _sendPort = null, |
| 70 _messages = 0 { | 70 _messages = 0 { |
| 71 _sendPort = spawnFunction(startPipeServer); | 71 _sendPort = spawnFunction(startPipeServer); |
| 72 start(); | 72 initialize(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void runTest() { | 75 void runTest() { |
| 76 | 76 |
| 77 void connectHandler() { | 77 void connectHandler() { |
| 78 String srcFileName = | 78 String srcFileName = |
| 79 getDataFilename("tests/standalone/io/readline_test1.dat"); | 79 getDataFilename("tests/standalone/io/readline_test1.dat"); |
| 80 | 80 |
| 81 SocketOutputStream socketOutput = _socket.outputStream; | 81 SocketOutputStream socketOutput = _socket.outputStream; |
| 82 InputStream fileInput = new File(srcFileName).openInputStream(); | 82 InputStream fileInput = new File(srcFileName).openInputStream(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 | 117 |
| 118 // Connect to the server. | 118 // Connect to the server. |
| 119 _socket = new Socket(TestingServer.HOST, _port); | 119 _socket = new Socket(TestingServer.HOST, _port); |
| 120 if (_socket !== null) { | 120 if (_socket !== null) { |
| 121 _socket.onConnect = connectHandler; | 121 _socket.onConnect = connectHandler; |
| 122 } else { | 122 } else { |
| 123 Expect.fail("socket creation failed"); | 123 Expect.fail("socket creation failed"); |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 | 126 |
| 127 void start() { | 127 void initialize() { |
| 128 _receivePort.receive((var message, SendPort replyTo) { | 128 _receivePort.receive((var message, SendPort replyTo) { |
| 129 _port = message; | 129 _port = message; |
| 130 runTest(); | 130 runTest(); |
| 131 }); | 131 }); |
| 132 _sendPort.send(TestingServer.INIT, _receivePort.toSendPort()); | 132 _sendPort.send(TestingServer.INIT, _receivePort.toSendPort()); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void shutdown() { | 135 void shutdown() { |
| 136 _sendPort.send(TestingServer.SHUTDOWN, _receivePort.toSendPort()); | 136 _sendPort.send(TestingServer.SHUTDOWN, _receivePort.toSendPort()); |
| 137 _receivePort.close(); | 137 _receivePort.close(); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 srcStream.pipe(dstStream, close: false); | 285 srcStream.pipe(dstStream, close: false); |
| 286 } | 286 } |
| 287 | 287 |
| 288 | 288 |
| 289 main() { | 289 main() { |
| 290 testFileToFilePipe1(); | 290 testFileToFilePipe1(); |
| 291 testFileToFilePipe2(); | 291 testFileToFilePipe2(); |
| 292 testFileToFilePipe3(); | 292 testFileToFilePipe3(); |
| 293 PipeServerGame echoServerGame = new PipeServerGame.start(); | 293 PipeServerGame echoServerGame = new PipeServerGame.start(); |
| 294 } | 294 } |
| OLD | NEW |