OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** | 5 /** |
6 * Classes and methods for executing tests. | 6 * Classes and methods for executing tests. |
7 * | 7 * |
8 * This module includes: | 8 * This module includes: |
9 * - Managing parallel execution of tests, including timeout checks. | 9 * - Managing parallel execution of tests, including timeout checks. |
10 * - Evaluating the output of each test as pass/fail/crash/timeout. | 10 * - Evaluating the output of each test as pass/fail/crash/timeout. |
(...skipping 2486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2497 return _getBatchRunner("dart2js") | 2497 return _getBatchRunner("dart2js") |
2498 .runCommand("dart2js", command, timeout, command.arguments); | 2498 .runCommand("dart2js", command, timeout, command.arguments); |
2499 } else if (command is AnalysisCommand && batchMode) { | 2499 } else if (command is AnalysisCommand && batchMode) { |
2500 return _getBatchRunner(command.flavor) | 2500 return _getBatchRunner(command.flavor) |
2501 .runCommand(command.flavor, command, timeout, command.arguments); | 2501 .runCommand(command.flavor, command, timeout, command.arguments); |
2502 } else if (command is ScriptCommand) { | 2502 } else if (command is ScriptCommand) { |
2503 return command.run(); | 2503 return command.run(); |
2504 } else if (command is AdbPrecompilationCommand) { | 2504 } else if (command is AdbPrecompilationCommand) { |
2505 assert(adbDevicePool != null); | 2505 assert(adbDevicePool != null); |
2506 return adbDevicePool.acquireDevice().then((AdbDevice device) { | 2506 return adbDevicePool.acquireDevice().then((AdbDevice device) { |
2507 return _runAdbPrecompilationCommand(device, command).whenComplete(() { | 2507 return _runAdbPrecompilationCommand( |
| 2508 device, command, timeout).whenComplete(() { |
2508 adbDevicePool.releaseDevice(device); | 2509 adbDevicePool.releaseDevice(device); |
2509 }); | 2510 }); |
2510 }); | 2511 }); |
2511 } else { | 2512 } else { |
2512 return new RunningProcess(command, timeout).run(); | 2513 return new RunningProcess(command, timeout).run(); |
2513 } | 2514 } |
2514 } | 2515 } |
2515 | 2516 |
2516 Future<CommandOutput> _runAdbPrecompilationCommand( | 2517 Future<CommandOutput> _runAdbPrecompilationCommand( |
2517 AdbDevice device, AdbPrecompilationCommand command) async { | 2518 AdbDevice device, AdbPrecompilationCommand command, int timeout) async { |
2518 var runner = command.precompiledRunnerFilename; | 2519 var runner = command.precompiledRunnerFilename; |
2519 var testdir = command.precompiledTestDirectory; | 2520 var testdir = command.precompiledTestDirectory; |
2520 var devicedir = '/data/local/tmp/precompilation-testing'; | 2521 var devicedir = '/data/local/tmp/precompilation-testing'; |
2521 var deviceTestDir = '/data/local/tmp/precompilation-testing/test'; | 2522 var deviceTestDir = '/data/local/tmp/precompilation-testing/test'; |
2522 | 2523 |
2523 // We copy all the files which the vm precompiler puts into the test | 2524 // We copy all the files which the vm precompiler puts into the test |
2524 // directory. | 2525 // directory. |
2525 List<String> files = new io.Directory(testdir) | 2526 List<String> files = new io.Directory(testdir) |
2526 .listSync() | 2527 .listSync() |
2527 .where((fse) => fse is io.File) | 2528 .where((fse) => fse is io.File) |
2528 .map((file) => file.path) | 2529 .map((file) => file.path) |
2529 .map((path) => path.substring(path.lastIndexOf('/') + 1)) | 2530 .map((path) => path.substring(path.lastIndexOf('/') + 1)) |
2530 .toList(); | 2531 .toList(); |
2531 | 2532 |
| 2533 var timeoutDuration = new Duration(seconds: timeout); |
| 2534 |
2532 // All closures are of type "Future<AdbCommandResult> run()" | 2535 // All closures are of type "Future<AdbCommandResult> run()" |
2533 List<Function> steps = []; | 2536 List<Function> steps = []; |
2534 | 2537 |
2535 steps.add(() => device.runAdbShellCommand( | 2538 steps.add(() => device.runAdbShellCommand( |
2536 ['rm', '-Rf', deviceTestDir])); | 2539 ['rm', '-Rf', deviceTestDir])); |
2537 steps.add(() => device.runAdbShellCommand( | 2540 steps.add(() => device.runAdbShellCommand( |
2538 ['mkdir', '-p', deviceTestDir])); | 2541 ['mkdir', '-p', deviceTestDir])); |
2539 // TODO: We should find a way for us to cache the runner binary and avoid | 2542 // TODO: We should find a way for us to cache the runner binary and avoid |
2540 // pushhing it for every single test (this is bad for SSD cycle time, test | 2543 // pushhing it for every single test (this is bad for SSD cycle time, test |
2541 // timing). | 2544 // timing). |
2542 steps.add(() => device.runAdbCommand( | 2545 steps.add(() => device.runAdbCommand( |
2543 ['push', runner, '$devicedir/runner'])); | 2546 ['push', runner, '$devicedir/runner'])); |
2544 steps.add(() => device.runAdbShellCommand( | 2547 steps.add(() => device.runAdbShellCommand( |
2545 ['chmod', '777', '$devicedir/runner'])); | 2548 ['chmod', '777', '$devicedir/runner'])); |
2546 | 2549 |
2547 for (var file in files) { | 2550 for (var file in files) { |
2548 steps.add(() => device.runAdbCommand( | 2551 steps.add(() => device.runAdbCommand( |
2549 ['push', '$testdir/$file', '$deviceTestDir/$file'])); | 2552 ['push', '$testdir/$file', '$deviceTestDir/$file'])); |
2550 } | 2553 } |
2551 | 2554 |
2552 if (command.useBlobs) { | 2555 if (command.useBlobs) { |
2553 steps.add(() => device.runAdbShellCommand( | 2556 steps.add(() => device.runAdbShellCommand( |
2554 ['$devicedir/runner', '--run-precompiled-snapshot=$deviceTestDir', | 2557 ['$devicedir/runner', '--run-precompiled-snapshot=$deviceTestDir', |
2555 '--use_blobs', 'ignored.dart'])); | 2558 '--use_blobs', 'ignored.dart'], timeout: timeoutDuration)); |
2556 } else { | 2559 } else { |
2557 steps.add(() => device.runAdbShellCommand( | 2560 steps.add(() => device.runAdbShellCommand( |
2558 ['$devicedir/runner', '--run-precompiled-snapshot=$deviceTestDir', | 2561 ['$devicedir/runner', '--run-precompiled-snapshot=$deviceTestDir', |
2559 'ignored.dart'])); | 2562 'ignored.dart'], timeout: timeoutDuration)); |
2560 } | 2563 } |
2561 | 2564 |
2562 var stopwatch = new Stopwatch()..start(); | 2565 var stopwatch = new Stopwatch()..start(); |
2563 var writer = new StringBuffer(); | 2566 var writer = new StringBuffer(); |
2564 | 2567 |
2565 await device.waitForBootCompleted(); | 2568 await device.waitForBootCompleted(); |
2566 await device.waitForDevice(); | 2569 await device.waitForDevice(); |
2567 | 2570 |
2568 AdbCommandResult result; | 2571 AdbCommandResult result; |
2569 for (var i = 0; i < steps.length; i++) { | 2572 for (var i = 0; i < steps.length; i++) { |
(...skipping 10 matching lines...) Expand all Loading... |
2580 } | 2583 } |
2581 writer.writeln("ExitCode: ${result.exitCode}"); | 2584 writer.writeln("ExitCode: ${result.exitCode}"); |
2582 writer.writeln("Time: ${commandStopwatch.elapsed}"); | 2585 writer.writeln("Time: ${commandStopwatch.elapsed}"); |
2583 writer.writeln(""); | 2586 writer.writeln(""); |
2584 | 2587 |
2585 // If one command fails, we stop processing the others and return | 2588 // If one command fails, we stop processing the others and return |
2586 // immediately. | 2589 // immediately. |
2587 if (result.exitCode != 0) break; | 2590 if (result.exitCode != 0) break; |
2588 } | 2591 } |
2589 return createCommandOutput( | 2592 return createCommandOutput( |
2590 command, result.exitCode, false, UTF8.encode('$writer'), | 2593 command, result.exitCode, result.timedOut, UTF8.encode('$writer'), |
2591 [], stopwatch.elapsed, false); | 2594 [], stopwatch.elapsed, false); |
2592 } | 2595 } |
2593 | 2596 |
2594 BatchRunnerProcess _getBatchRunner(String identifier) { | 2597 BatchRunnerProcess _getBatchRunner(String identifier) { |
2595 // Start batch processes if needed | 2598 // Start batch processes if needed |
2596 var runners = _batchProcesses[identifier]; | 2599 var runners = _batchProcesses[identifier]; |
2597 if (runners == null) { | 2600 if (runners == null) { |
2598 runners = new List<BatchRunnerProcess>(maxProcesses); | 2601 runners = new List<BatchRunnerProcess>(maxProcesses); |
2599 for (int i = 0; i < maxProcesses; i++) { | 2602 for (int i = 0; i < maxProcesses; i++) { |
2600 runners[i] = new BatchRunnerProcess(); | 2603 runners[i] = new BatchRunnerProcess(); |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3014 } | 3017 } |
3015 } | 3018 } |
3016 | 3019 |
3017 void eventAllTestsDone() { | 3020 void eventAllTestsDone() { |
3018 for (var listener in _eventListener) { | 3021 for (var listener in _eventListener) { |
3019 listener.allDone(); | 3022 listener.allDone(); |
3020 } | 3023 } |
3021 _allDone(); | 3024 _allDone(); |
3022 } | 3025 } |
3023 } | 3026 } |
OLD | NEW |