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 14 matching lines...) Expand all Loading... |
25 fprintf(stderr, "unknown outstream"); | 25 fprintf(stderr, "unknown outstream"); |
26 exit(1); | 26 exit(1); |
27 } | 27 } |
28 | 28 |
29 int echo_counter = 0; | 29 int echo_counter = 0; |
30 int echo_count = atoi(argv[2]); | 30 int echo_count = atoi(argv[2]); |
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 if (crash == 1) { | 34 if (crash == 1) { |
35 abort(); | 35 int* segfault = NULL; |
| 36 *segfault = 1; |
36 } | 37 } |
37 | 38 |
38 const int kLineSize = 128; | 39 const int kLineSize = 128; |
39 char line[kLineSize]; | 40 char line[kLineSize]; |
40 | 41 |
41 while ((echo_count != echo_counter) && | 42 while ((echo_count != echo_counter) && |
42 (fgets(line, kLineSize, stdin) != NULL)) { | 43 (fgets(line, kLineSize, stdin) != NULL)) { |
43 if (outstream == 0) { | 44 if (outstream == 0) { |
44 fprintf(stdout, "%s", line); | 45 fprintf(stdout, "%s", line); |
45 fflush(stdout); | 46 fflush(stdout); |
46 } else if (outstream == 1) { | 47 } else if (outstream == 1) { |
47 fprintf(stderr, "%s", line); | 48 fprintf(stderr, "%s", line); |
48 fflush(stderr); | 49 fflush(stderr); |
49 } else if (outstream == 2) { | 50 } else if (outstream == 2) { |
50 fprintf(stdout, "%s", line); | 51 fprintf(stdout, "%s", line); |
51 fprintf(stderr, "%s", line); | 52 fprintf(stderr, "%s", line); |
52 fflush(stdout); | 53 fflush(stdout); |
53 fflush(stderr); | 54 fflush(stderr); |
54 } | 55 } |
55 echo_counter++; | 56 echo_counter++; |
56 } | 57 } |
57 | 58 |
58 return exit_code; | 59 return exit_code; |
59 } | 60 } |
OLD | NEW |