Chromium Code Reviews| Index: tests/standalone/precompilation_test.dart |
| diff --git a/tests/standalone/precompilation_test.dart b/tests/standalone/precompilation_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ac994a9d583eef928b18e8162960bf3f70a14c04 |
| --- /dev/null |
| +++ b/tests/standalone/precompilation_test.dart |
| @@ -0,0 +1,57 @@ |
| +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +// Test generating and running a simple precompiled snapshot of this script. |
| + |
| +import 'dart:io'; |
| + |
| +main(List args) { |
| + if (!Platform.isLinux) { |
| + print("Linux only test"); |
| + return; |
| + } |
| + if (args.length > 0 && args[0] == "--hello") { |
| + print("Hello"); |
| + return; |
| + } |
| + String dart_executable = |
| + Directory.current.path + Platform.pathSeparator + Platform.executable; |
| + Directory tmp; |
| + try { |
| + tmp = Directory.current.createTempSync("temp_precompilation_test"); |
| + var result = Process.runSync( |
| + "${dart_executable}_no_snapshot", |
| + ["--gen-precompiled-snapshot", Platform.script.path], |
| + workingDirectory: tmp.path); |
| + if (result.exitCode != 0) { |
| + print(result.stdout); |
| + print(result.stderr); |
| + throw "Snapshot generation failed."; |
| + } |
|
Bill Hesse
2015/09/23 17:17:37
Maybe try and run gcc --version, and if it fails,
Florian Schneider
2015/09/24 09:36:36
Done.
|
| + result = Process.runSync( |
| + "gcc", |
|
rmacnak
2015/09/23 17:34:59
The ARM bots download a cross-compiled build inste
Florian Schneider
2015/09/24 09:36:36
Bill said they have gcc. But I'll add the check li
|
| + ["-shared", "-o", "libprecompiled.so", "precompiled.S"], |
|
rmacnak
2015/09/23 17:34:59
If enabled for the simulators, should explicitly p
Florian Schneider
2015/09/24 09:36:36
Done. I didn't find a generic way to check for 32-
|
| + workingDirectory: tmp.path); |
| + if (result.exitCode != 0) { |
| + print(result.stdout); |
| + print(result.stderr); |
| + throw "Shared library creation failed!"; |
| + } |
| + result = Process.runSync( |
| + "${dart_executable}", |
| + ["--run-precompiled-snapshot", "ignored_script", "--hello"], |
| + workingDirectory: tmp.path); |
| + if (result.exitCode != 0) { |
| + print(result.stdout); |
| + print(result.stderr); |
| + throw "Precompiled binary failed."; |
| + } |
| + print(result.stdout); |
| + if (result.stdout != "Hello\n") { |
| + throw "Precompiled binary output mismatch."; |
| + } |
| + } finally { |
| + tmp?.deleteSync(recursive: true); |
| + } |
| +} |