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

Side by Side Diff: tests/standalone/src/ProcessStderrTest.dart

Issue 8437090: Change the handling of closing sockets (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments by ager@ Created 9 years, 1 month 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 | « tests/standalone/src/EchoServerTest.dart ('k') | tests/standalone/src/ProcessStdoutTest.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) 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
11 11
12 class ProcessStderrTest { 12 class ProcessStderrTest {
13 13 static void testStderr() {
14 static void testExit() {
15 Process process = new Process("out/Debug_ia32/process_test", 14 Process process = new Process("out/Debug_ia32/process_test",
16 const ["1", "1", "99", "0"]); 15 const ["1", "1", "99", "0"]);
17 final int BUFFERSIZE = 10; 16 final int BUFFERSIZE = 10;
18 final int STARTCHAR = 65; 17 final int STARTCHAR = 65;
19 List<int> data = new List<int>(BUFFERSIZE); 18 List<int> data = new List<int>(BUFFERSIZE);
20 for (int i = 0; (i < BUFFERSIZE - 1); i++) { 19 for (int i = 0; (i < BUFFERSIZE - 1); i++) {
21 data[i] = STARTCHAR + i; 20 data[i] = STARTCHAR + i;
22 } 21 }
23 data[BUFFERSIZE - 1] = 10; 22 data[BUFFERSIZE - 1] = 10;
24 23
25 InputStream input = process.stderr; 24 InputStream input = process.stderr;
26 OutputStream output = process.stdin; 25 OutputStream output = process.stdin;
27 26
28 process.start(); 27 process.start();
29 28
30 int received = 0; 29 int received = 0;
30
31 void readData() { 31 void readData() {
32 List<int> buffer = input.read(); 32 List<int> buffer = input.read();
33 for (int i = 0; i < buffer.length; i++) { 33 for (int i = 0; i < buffer.length; i++) {
34 Expect.equals(data[received + i], buffer[i]); 34 Expect.equals(data[received + i], buffer[i]);
35 } 35 }
36 received += buffer.length; 36 received += buffer.length;
37 if (received == BUFFERSIZE) { 37 }
38 process.close(); 38
39 } 39 void streamClosed() {
40 Expect.equals(BUFFERSIZE, received);
41 process.close();
40 } 42 }
41 43
42 output.write(data); 44 output.write(data);
43 output.end(); 45 output.close();
44 input.dataHandler = readData; 46 input.dataHandler = readData;
47 input.closeHandler = streamClosed;
45 } 48 }
46 49
47 static void testMain() { 50 static void testMain() {
48 testExit(); 51 testStderr();
49 } 52 }
50 } 53 }
51 54
52 main() { 55 main() {
53 ProcessStderrTest.testMain(); 56 ProcessStderrTest.testStderr();
54 } 57 }
OLDNEW
« no previous file with comments | « tests/standalone/src/EchoServerTest.dart ('k') | tests/standalone/src/ProcessStdoutTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698