OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // OtherResources=verbose_gc_to_bmu_script.dart |
| 6 |
5 // This test forks a second vm process that runs the BMU tool and verifies that | 7 // This test forks a second vm process that runs the BMU tool and verifies that |
6 // it produces some output. This test is mainly here to ensure that the BMU | 8 // it produces some output. This test is mainly here to ensure that the BMU |
7 // tool compiles and runs. | 9 // tool compiles and runs. |
8 | 10 |
9 import "dart:async"; | 11 import "dart:async"; |
10 import "dart:convert"; | 12 import "dart:convert"; |
11 import "dart:io"; | 13 import "dart:io"; |
12 | 14 |
13 import "package:path/path.dart"; | 15 import "package:path/path.dart"; |
14 | 16 |
15 // Tool script relative to the path of this test. | 17 // Tool script relative to the path of this test. |
16 var toolScript = "../../runtime/tools/verbose_gc_to_bmu.dart"; | 18 var toolScript = Uri.parse(Platform.executable) |
| 19 .resolve("../../runtime/tools/verbose_gc_to_bmu.dart").toFilePath(); |
17 | 20 |
18 // Target script relative to this test. | 21 // Target script relative to this test. |
19 var targetScript = "../language/gc_test.dart"; | 22 var targetScript = Platform.script |
| 23 .resolve("verbose_gc_to_bmu_script.dart").toFilePath(); |
20 const minOutputLines = 20; | 24 const minOutputLines = 20; |
21 | 25 |
22 void checkExitCode(exitCode) { | 26 void checkExitCode(targetResult) { |
23 if (exitCode != 0) { | 27 if (exitCode != 0) { |
24 print("Process terminated with exit code ${exitCode}."); | 28 print("Process terminated with exit code ${exitCode}."); |
25 exit(-1); | 29 exit(-1); |
26 } | 30 } |
27 } | 31 } |
28 | 32 |
29 void main() { | 33 void main() { |
30 // Compute paths for tool and target relative to the path of this script. | 34 // Compute paths for tool and target relative to the path of this script. |
31 var scriptDir = dirname(Platform.script.toFilePath()); | |
32 var targPath = normalize(join(scriptDir, targetScript)); | |
33 var targetResult = | 35 var targetResult = |
34 Process.runSync(Platform.executable, ["--verbose_gc", targPath]); | 36 Process.runSync(Platform.executable, ["--verbose_gc", targetScript]); |
35 checkExitCode(targetResult.exitCode); | 37 checkExitCode(targetResult); |
36 var gcLog = targetResult.stderr; | 38 var gcLog = targetResult.stderr; |
37 var toolPath = normalize(join(scriptDir, toolScript)); | 39 Process.start(Platform.executable, [toolScript]).then((Process process) { |
38 Process.start(Platform.executable, [toolPath]).then((Process process) { | |
39 // Feed the GC log of the target to the BMU tool. | 40 // Feed the GC log of the target to the BMU tool. |
40 process.stdin.write(gcLog); | 41 process.stdin.write(gcLog); |
41 process.stdin.close(); | 42 process.stdin.close(); |
42 var stdoutStringStream = process.stdout | 43 var stdoutStringStream = process.stdout |
43 .transform(UTF8.decoder) | 44 .transform(UTF8.decoder) |
44 .transform(new LineSplitter()); | 45 .transform(new LineSplitter()); |
45 var stderrStringStream = process.stderr | 46 var stderrStringStream = process.stderr |
46 .transform(UTF8.decoder) | 47 .transform(UTF8.decoder) |
47 .transform(new LineSplitter()); | 48 .transform(new LineSplitter()); |
48 // Wait for 3 future events: stdout and stderr streams closed, and | 49 // Wait for 3 future events: stdout and stderr streams closed, and |
(...skipping 13 matching lines...) Expand all Loading... |
62 exit(-1); | 63 exit(-1); |
63 } | 64 } |
64 if (stdoutLines.length < minOutputLines) { | 65 if (stdoutLines.length < minOutputLines) { |
65 print("Less than expected output on stdout:"); | 66 print("Less than expected output on stdout:"); |
66 print(stdoutLines.join('\n')); | 67 print(stdoutLines.join('\n')); |
67 exit(-1); | 68 exit(-1); |
68 } | 69 } |
69 }); | 70 }); |
70 }); | 71 }); |
71 } | 72 } |
OLD | NEW |