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 // |
| 7 // VMOptions= |
| 8 // VMOptions=--short_socket_read |
| 9 // VMOptions=--short_socket_write |
| 10 // VMOptions=--short_socket_read --short_socket_write |
6 | 11 |
7 class ProcessStderrTest { | 12 class ProcessStderrTest { |
8 | 13 |
9 static void testExit() { | 14 static void testExit() { |
10 Process process = new Process("out/Debug_ia32/process_test", | 15 Process process = new Process("out/Debug_ia32/process_test", |
11 const ["1", "1", "99", "0"]); | 16 const ["1", "1", "99", "0"]); |
12 final int BUFFERSIZE = 10; | 17 final int BUFFERSIZE = 10; |
13 final int STARTCHAR = 65; | 18 final int STARTCHAR = 65; |
14 List<int> buffer = new List<int>(BUFFERSIZE); | 19 List<int> buffer = new List<int>(BUFFERSIZE); |
15 for (int i = 0; (i < BUFFERSIZE - 1); i++) { | 20 for (int i = 0; (i < BUFFERSIZE - 1); i++) { |
16 buffer[i] = STARTCHAR + i; | 21 buffer[i] = STARTCHAR + i; |
17 } | 22 } |
18 buffer[BUFFERSIZE - 1] = 10; | 23 buffer[BUFFERSIZE - 1] = 10; |
19 | 24 |
20 SocketInputStream input = process.stderrStream; | 25 SocketInputStream input = process.stderrStream; |
21 SocketOutputStream output = process.stdinStream; | 26 SocketOutputStream output = process.stdinStream; |
22 | 27 |
23 process.start(); | 28 process.start(); |
24 | 29 |
25 List<int> readBuffer = new List<int>(BUFFERSIZE); | 30 List<int> readBuffer = new List<int>(BUFFERSIZE); |
26 | 31 |
27 void dataWritten() { | 32 void dataWritten() { |
28 void readData() { | 33 void readData() { |
29 for (int i = 0; i < BUFFERSIZE; i++) { | 34 for (int i = 0; i < BUFFERSIZE; i++) { |
30 Expect.equals(buffer[i], readBuffer[i]); | 35 Expect.equals(buffer[i], readBuffer[i]); |
31 } | 36 } |
32 process.close(); | 37 process.close(); |
33 } | 38 } |
34 | 39 |
35 bool read = input.read(readBuffer, 0, BUFFERSIZE, readData); | 40 bool read = input.read(readBuffer, 0, BUFFERSIZE, readData); |
36 if (read) { | 41 if (read) { |
37 readData(); | 42 readData(); |
38 } | 43 } |
39 } | 44 } |
40 bool written = output.write(buffer, 0, BUFFERSIZE, dataWritten); | 45 bool written = output.write(buffer, 0, BUFFERSIZE, dataWritten); |
41 if (written) { | 46 if (written) { |
42 dataWritten(); | 47 dataWritten(); |
43 } | 48 } |
44 } | 49 } |
45 | 50 |
46 static void testMain() { | 51 static void testMain() { |
47 testExit(); | 52 testExit(); |
48 } | 53 } |
49 } | 54 } |
50 | 55 |
51 main() { | 56 main() { |
52 ProcessStderrTest.testMain(); | 57 ProcessStderrTest.testMain(); |
53 } | 58 } |
OLD | NEW |