|
| 1 | +// Copyright (c) 2020, 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 | +import 'dart:io'; |
| 5 | + |
| 6 | +import 'package:expect/expect.dart'; |
| 7 | +import 'package:path/path.dart' as path; |
| 8 | + |
| 9 | +main() { |
| 10 | + final buildDir = path.dirname(Platform.executable); |
| 11 | + final sdkDir = path.dirname(path.dirname(buildDir)); |
| 12 | + final platformDill = path.join(buildDir, 'vm_platform_strong.dill'); |
| 13 | + final genSnapshot = path.join(buildDir, 'gen_snapshot'); |
| 14 | + |
| 15 | + final exePath = Platform.resolvedExecutable; |
| 16 | + final genSnapshotPath = |
| 17 | + Uri.parse(Platform.executable).resolve('gen_snapshot').path; |
| 18 | + final powTest = Platform.script.resolve('pow_test.dart').path; |
| 19 | + final d = Directory.systemTemp.createTempSync('aot_tmp'); |
| 20 | + final kernelOutput = d.uri.resolve('pow_test.dill').path; |
| 21 | + final aotOutput = d.uri.resolve('pow_test.aot').path; |
| 22 | + |
| 23 | + final genKernelResult = Process.runSync( |
| 24 | + 'pkg/vm/tool/gen_kernel', |
| 25 | + [ |
| 26 | + '--aot', |
| 27 | + '--platform=$platformDill', |
| 28 | + '-o', |
| 29 | + kernelOutput, |
| 30 | + powTest, |
| 31 | + ], |
| 32 | + ); |
| 33 | + Expect.equals(genKernelResult.exitCode, 0); |
| 34 | + |
| 35 | + final genAotResult = Process.runSync( |
| 36 | + genSnapshot, |
| 37 | + [ |
| 38 | + '--snapshot_kind=app-aot-elf', |
| 39 | + '--elf=$aotOutput', |
| 40 | + kernelOutput, |
| 41 | + ], |
| 42 | + ); |
| 43 | + Expect.equals(genAotResult.exitCode, 0); |
| 44 | + |
| 45 | + final runAotResult = Process.runSync( |
| 46 | + exePath, |
| 47 | + [ |
| 48 | + 'run', |
| 49 | + aotOutput, |
| 50 | + ], |
| 51 | + ); |
| 52 | + Expect.equals(runAotResult.exitCode, 255); |
| 53 | + Expect.stringContainsInOrder( |
| 54 | + runAotResult.stderr, |
| 55 | + [ |
| 56 | + "pow_test.aot is an AOT snapshot and should be run with 'dartaotruntime'", |
| 57 | + ], |
| 58 | + ); |
| 59 | +} |
0 commit comments