| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Process test program to test process communication. | 5 // Process test program to test process communication. |
| 6 // | 6 // |
| 7 // VMOptions= | 7 // VMOptions= |
| 8 // VMOptions=--short_socket_read | 8 // VMOptions=--short_socket_read |
| 9 // VMOptions=--short_socket_write | 9 // VMOptions=--short_socket_write |
| 10 // VMOptions=--short_socket_read --short_socket_write | 10 // VMOptions=--short_socket_read --short_socket_write |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 } | 22 } |
| 23 data[BUFFERSIZE - 1] = 10; | 23 data[BUFFERSIZE - 1] = 10; |
| 24 | 24 |
| 25 InputStream input = process.stdout; | 25 InputStream input = process.stdout; |
| 26 OutputStream output = process.stdin; | 26 OutputStream output = process.stdin; |
| 27 | 27 |
| 28 process.start(); | 28 process.start(); |
| 29 | 29 |
| 30 int received = 0; | 30 int received = 0; |
| 31 | 31 |
| 32 void dataWritten() { | 32 void readData() { |
| 33 void readData() { | 33 List<int> buffer = input.read(); |
| 34 List<int> buffer = input.read(); | 34 for (int i = 0; i < buffer.length; i++) { |
| 35 for (int i = 0; i < buffer.length; i++) { | 35 Expect.equals(data[received + i], buffer[i]); |
| 36 Expect.equals(data[received + i], buffer[i]); | |
| 37 } | |
| 38 received += buffer.length; | |
| 39 if (received == BUFFERSIZE) { | |
| 40 process.close(); | |
| 41 } | |
| 42 } | 36 } |
| 43 | 37 received += buffer.length; |
| 44 void streamClosed() { | 38 if (received == BUFFERSIZE) { |
| 45 Expect.equals(BUFFERSIZE, received); | 39 process.close(); |
| 46 } | 40 } |
| 47 | |
| 48 input.dataHandler = readData; | |
| 49 input.closeHandler = streamClosed; | |
| 50 } | 41 } |
| 51 | 42 |
| 52 bool written = output.write(data, 0, BUFFERSIZE, dataWritten); | 43 void streamClosed() { |
| 53 if (written) { | 44 Expect.equals(BUFFERSIZE, received); |
| 54 dataWritten(); | |
| 55 } | 45 } |
| 46 |
| 47 output.write(data); |
| 48 output.end(); |
| 49 input.dataHandler = readData; |
| 50 input.closeHandler = streamClosed; |
| 56 } | 51 } |
| 57 | 52 |
| 58 static void testMain() { | 53 static void testMain() { |
| 59 testStdout(); | 54 testStdout(); |
| 60 } | 55 } |
| 61 } | 56 } |
| 62 | 57 |
| 63 main() { | 58 main() { |
| 64 ProcessStdoutTest.testMain(); | 59 ProcessStdoutTest.testMain(); |
| 65 } | 60 } |
| OLD | NEW |