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 #include <stdio.h> | 5 #include <stdio.h> |
6 #include <stdlib.h> | 6 #include <stdlib.h> |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 /* | 9 /* |
10 * Run ./process_test <outstream> <echocount> <exitcode> <crash> | 10 * Run ./process_test <outstream> <echocount> <exitcode> <crash> |
(...skipping 20 matching lines...) Expand all Loading... |
31 int exit_code = atoi(argv[3]); | 31 int exit_code = atoi(argv[3]); |
32 int crash = atoi(argv[4]); | 32 int crash = atoi(argv[4]); |
33 | 33 |
34 const int kLineSize = 128; | 34 const int kLineSize = 128; |
35 char line[kLineSize]; | 35 char line[kLineSize]; |
36 | 36 |
37 while ((echo_count != echo_counter) && | 37 while ((echo_count != echo_counter) && |
38 (fgets(line, kLineSize, stdin) != NULL)) { | 38 (fgets(line, kLineSize, stdin) != NULL)) { |
39 if (outstream == 0) { | 39 if (outstream == 0) { |
40 fprintf(stdout, "%s", line); | 40 fprintf(stdout, "%s", line); |
| 41 fflush(stdout); |
41 } else if (outstream == 1) { | 42 } else if (outstream == 1) { |
42 fprintf(stderr, "%s", line); | 43 fprintf(stderr, "%s", line); |
| 44 fflush(stderr); |
43 } else if (outstream == 2) { | 45 } else if (outstream == 2) { |
44 fprintf(stdout, "%s", line); | 46 fprintf(stdout, "%s", line); |
45 fprintf(stderr, "%s", line); | 47 fprintf(stderr, "%s", line); |
| 48 fflush(stdout); |
| 49 fflush(stderr); |
46 } | 50 } |
47 echo_counter++; | 51 echo_counter++; |
48 } | 52 } |
49 | 53 |
50 if (crash == 1) { | 54 if (crash == 1) { |
51 int* segfault = NULL; | 55 int* segfault = NULL; |
52 *segfault = 1; | 56 *segfault = 1; |
53 } | 57 } |
54 | 58 |
55 | |
56 return exit_code; | 59 return exit_code; |
57 } | 60 } |
OLD | NEW |