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