Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 // 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 | |
| 7 // tool compiles and runs. | |
| 8 | |
| 9 import "dart:async"; | |
| 10 import "dart:convert"; | |
| 11 import "dart:io"; | |
| 12 | |
| 13 import "package:path/path.dart"; | |
| 14 | |
| 15 // Tool script relative to the path of this test. | |
| 16 var toolScript = "../../runtime/tools/verbose_gc_to_bmu.dart"; | |
| 17 | |
| 18 // Target script relative to this test. | |
| 19 var targetScript = "../language/gc_test.dart"; | |
| 20 | |
| 21 void checkExitCode(exitCode) { | |
| 22 if (exitCode != 0) { | |
| 23 print("Process terminated with exit code ${exitCode}."); | |
| 24 exit(-1); | |
| 25 } | |
| 26 } | |
| 27 | |
| 28 void main() { | |
| 29 // Compute paths for tool and target relative to the path of this script. | |
| 30 var scriptDir = dirname(Platform.script.toFilePath()); | |
| 31 var targPath = normalize(join(scriptDir, targetScript)); | |
| 32 var targetResult = | |
| 33 Process.runSync(Platform.executable, ["--verbose_gc", targPath]); | |
| 34 checkExitCode(targetResult.exitCode); | |
| 35 var gcLog = targetResult.stderr; | |
| 36 var toolPath = normalize(join(scriptDir, toolScript)); | |
| 37 Process.start(Platform.executable, [toolPath]).then((Process process) { | |
| 38 // Feed the GC log of the target to the BMU tool. | |
| 39 process.stdin.write(gcLog); | |
| 40 process.stdin.close(); | |
| 41 var stdoutStringStream = process.stdout | |
| 42 .transform(UTF8.decoder) | |
| 43 .transform(new LineSplitter()); | |
| 44 var stderrStringStream = process.stderr | |
| 45 .transform(UTF8.decoder) | |
| 46 .transform(new LineSplitter()); | |
| 47 // Wait for 3 future events: stdout and stderr streams closed, and | |
| 48 // process terminated. | |
| 49 var futures = []; | |
| 50 var stdoutLines = []; | |
| 51 var stderrLines = []; | |
| 52 var subscription = stdoutStringStream.listen(stdoutLines.add); | |
| 53 futures.add(subscription.asFuture(true)); | |
| 54 subscription = stderrStringStream.listen(stderrLines.add); | |
| 55 futures.add(subscription.asFuture(true)); | |
| 56 futures.add(process.exitCode.then(checkExitCode)); | |
| 57 Future.wait(futures).then((results) { | |
| 58 if (stderrLines.isNotEmpty) { | |
| 59 print("Unexpected output on stderr:"); | |
| 60 print(stderrLines.join('\n')); | |
| 61 exit(-1); | |
| 62 } | |
| 63 if (stdoutLines.length < 200) { | |
|
Ivan Posva
2015/05/14 05:06:35
Please comment why you expect more than 200 lines
| |
| 64 print("Less than expected output on stdout:"); | |
| 65 print(stdoutLines.join('\n')); | |
| 66 exit(-1); | |
| 67 } | |
| 68 }); | |
| 69 }); | |
| 70 } | |
| OLD | NEW |