Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Unified Diff: tests/standalone/precompilation_test.dart

Issue 1362743003: Add simple VM test for precompiled code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: ia32 marked as fail instead of skip Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/pages.cc ('k') | tests/standalone/standalone.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..4e8d491d6767516f0347d1be149debae271eed02
--- /dev/null
+++ b/tests/standalone/precompilation_test.dart
@@ -0,0 +1,81 @@
+// 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;
+ }
+ var 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.";
+ }
+
+ // Check if gcc is present, and skip test if it is not.
+ try {
+ result = Process.runSync(
+ "gcc",
+ ["--version"],
+ workingDirectory: tmp.path);
+ if (result.exitCode != 0) {
+ throw "gcc --version failed.";
+ }
+ } catch(e) {
+ print("Skipping test because gcc is not present: $e");
+ return;
+ }
+
+ // Detect if we're running a 32- or 64-bit VM.
+ result = Process.runSync( "file", [dart_executable]);
+ if (result.exitCode != 0) {
+ print(result.stdout);
+ print(result.stderr);
+ throw "'file $dart_executable' failed.";
+ }
+ var m_option = result.stdout.contains("32-bit") ? "-m32" : "-m64";
+
+ result = Process.runSync(
+ "gcc",
+ ["-shared", m_option, "-o", "libprecompiled.so", "precompiled.S"],
+ 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);
+ }
+}
« no previous file with comments | « runtime/vm/pages.cc ('k') | tests/standalone/standalone.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698