[tests] Fixes for standalone{,_2}/check_for_aot_snapshot_jit_test.

* Skip on IA32, since it has no AOT mode.

* Use .bat/.exe suffixes on Windows.

* Look for gen_snapshot in <buildDir>/clang_x64 on MacOS ARM64.

* Avoid using Platform.script to find .dart source file locations, since
  some architectures generate a .dill for running JIT programs, which
  will be in the generated files directory, not the SDK directory.

* Try both 'dart <aotsnapshot>' and 'dart run <aotsnapshot>', which
  should both give the correct error message.

Cq-Include-Trybots: luci.dart.try:vm-kernel-nnbd-linux-release-x64-try,vm-kernel-nnbd-linux-release-ia32-try,vm-kernel-nnbd-linux-release-simarm-try,vm-kernel-nnbd-linux-release-simarm64-try,vm-kernel-linux-release-x64-try,vm-kernel-linux-release-ia32-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-win-release-ia32-try,vm-kernel-win-release-x64-try,vm-kernel-nnbd-win-release-x64-try,vm-kernel-nnbd-win-release-ia32-try,vm-kernel-mac-release-arm64-try,vm-kernel-mac-release-x64-try,vm-kernel-nnbd-mac-release-x64-try
Change-Id: Ic50b86fb51b5f2b30c6a4cb4fd8f0594bb1cf93d
Bug: https://github.com/dart-lang/sdk/issues/46306
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202923
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
This commit is contained in:
Tess Strickland 2021-06-09 12:22:41 +00:00 committed by commit-bot@chromium.org
parent 30321de787
commit 7d44c20f2c
4 changed files with 84 additions and 28 deletions

View file

@ -6,22 +6,38 @@ import 'dart:io';
import 'package:expect/expect.dart';
import 'package:path/path.dart' as path;
final _execSuffix = Platform.isWindows ? '.exe' : '';
final _batchSuffix = Platform.isWindows ? '.bat' : '';
main() {
final buildDir = path.dirname(Platform.executable);
final sdkDir = path.dirname(path.dirname(buildDir));
final platformDill = path.join(buildDir, 'vm_platform_strong.dill');
final genSnapshot = path.join(buildDir, 'gen_snapshot');
final genKernel =
path.join(sdkDir, 'pkg', 'vm', 'tool', 'gen_kernel$_batchSuffix');
Expect.isTrue(File(genKernel).existsSync(),
"Can't locate gen_kernel$_batchSuffix on this platform");
Expect.isTrue(File(genKernel).existsSync(),
"Can't locate gen_kernel$_batchSuffix on this platform");
// Currently gen_snapshot is only in buildDir/clang_x64 on Mac ARM64.
final genSnapshot = Platform.isMacOS && buildDir.endsWith('XARM64')
? path.join(buildDir, 'clang_x64', 'gen_snapshot$_execSuffix')
: path.join(buildDir, 'gen_snapshot$_execSuffix');
Expect.isTrue(File(genSnapshot).existsSync(),
"Can't locate gen_snapshot$_execSuffix on this platform");
final exePath = Platform.resolvedExecutable;
final genSnapshotPath =
Uri.parse(Platform.executable).resolve('gen_snapshot').path;
final powTest = Platform.script.resolve('pow_test.dart').path;
final exePath = path.join(buildDir, 'dart$_execSuffix');
Expect.isTrue(File(exePath).existsSync(),
"Can't locate dart$_execSuffix on this platform");
final powTest = path.join(sdkDir, 'tests', 'standalone_2', 'pow_test.dart');
Expect.isTrue(File(powTest).existsSync(),
"Can't locate dart$_execSuffix on this platform");
final d = Directory.systemTemp.createTempSync('aot_tmp');
final kernelOutput = d.uri.resolve('pow_test.dill').path;
final aotOutput = d.uri.resolve('pow_test.aot').path;
final genKernelResult = runAndPrintOutput(
'pkg/vm/tool/gen_kernel',
genKernel,
[
'--aot',
'--platform=$platformDill',
@ -44,20 +60,32 @@ main() {
Expect.equals(genAotResult.exitCode, 0);
print("Ran successfully.\n");
final runAotResult = runAndPrintOutput(
final runAotDirectlyResult = runAndPrintOutput(
exePath,
[
aotOutput,
],
);
Expect.equals(runAotDirectlyResult.exitCode, 255);
Expect.contains(
"pow_test.aot is an AOT snapshot and should be run with 'dartaotruntime'",
runAotDirectlyResult.stderr);
print('Got expected error result.');
final runAotUsingCommandResult = runAndPrintOutput(
exePath,
[
'run',
aotOutput,
],
);
Expect.equals(runAotResult.exitCode, 255);
Expect.stringContainsInOrder(
runAotResult.stderr,
[
"pow_test.aot is an AOT snapshot and should be run with 'dartaotruntime'",
],
);
Expect.equals(runAotUsingCommandResult.exitCode, 255);
Expect.containsOneOf(<String>[
"pow_test.aot is an AOT snapshot and should be run with 'dartaotruntime'",
// If dartdev itself failed, can happen on SIMARM as not enough is built
// to run it.
"Failed to start the Dart CLI isolate",
], runAotUsingCommandResult.stderr);
print('Got expected error result.');
}

View file

@ -3,6 +3,7 @@
# BSD-style license that can be found in the LICENSE file.
[ $arch == ia32 ]
check_for_aot_snapshot_jit_test: SkipByDesign # No AOT mode on IA32.
link_natives_lazily_test: SkipByDesign # Not supported.
no_allow_absolute_addresses_test: SkipByDesign # Not supported.

View file

@ -8,22 +8,36 @@ import 'dart:io';
import 'package:expect/expect.dart';
import 'package:path/path.dart' as path;
final _execSuffix = Platform.isWindows ? '.exe' : '';
final _batchSuffix = Platform.isWindows ? '.bat' : '';
main() {
final buildDir = path.dirname(Platform.executable);
final sdkDir = path.dirname(path.dirname(buildDir));
final platformDill = path.join(buildDir, 'vm_platform_strong.dill');
final genSnapshot = path.join(buildDir, 'gen_snapshot');
final genKernel =
path.join(sdkDir, 'pkg', 'vm', 'tool', 'gen_kernel$_batchSuffix');
Expect.isTrue(File(genKernel).existsSync(),
"Can't locate gen_kernel$_batchSuffix on this platform");
// Currently gen_snapshot is only in buildDir/clang_x64 on Mac ARM64.
final genSnapshot = Platform.isMacOS && buildDir.endsWith('XARM64')
? path.join(buildDir, 'clang_x64', 'gen_snapshot$_execSuffix')
: path.join(buildDir, 'gen_snapshot$_execSuffix');
Expect.isTrue(File(genSnapshot).existsSync(),
"Can't locate gen_snapshot$_execSuffix on this platform");
final exePath = Platform.resolvedExecutable;
final genSnapshotPath =
Uri.parse(Platform.executable).resolve('gen_snapshot').path;
final powTest = Platform.script.resolve('pow_test.dart').path;
final exePath = path.join(buildDir, 'dart$_execSuffix');
Expect.isTrue(File(exePath).existsSync(),
"Can't locate dart$_execSuffix on this platform");
final powTest = path.join(sdkDir, 'tests', 'standalone_2', 'pow_test.dart');
Expect.isTrue(File(powTest).existsSync(),
"Can't locate dart$_execSuffix on this platform");
final d = Directory.systemTemp.createTempSync('aot_tmp');
final kernelOutput = d.uri.resolve('pow_test.dill').path;
final aotOutput = d.uri.resolve('pow_test.aot').path;
final genKernelResult = runAndPrintOutput(
'pkg/vm/tool/gen_kernel',
genKernel,
[
'--aot',
'--platform=$platformDill',
@ -46,20 +60,32 @@ main() {
Expect.equals(genAotResult.exitCode, 0);
print("Ran successfully.\n");
final runAotResult = runAndPrintOutput(
final runAotDirectlyResult = runAndPrintOutput(
exePath,
[
aotOutput,
],
);
Expect.equals(runAotDirectlyResult.exitCode, 255);
Expect.contains(
"pow_test.aot is an AOT snapshot and should be run with 'dartaotruntime'",
runAotDirectlyResult.stderr);
print('Got expected error result.');
final runAotUsingCommandResult = runAndPrintOutput(
exePath,
[
'run',
aotOutput,
],
);
Expect.equals(runAotResult.exitCode, 255);
Expect.stringContainsInOrder(
runAotResult.stderr,
[
"pow_test.aot is an AOT snapshot and should be run with 'dartaotruntime'",
],
);
Expect.equals(runAotUsingCommandResult.exitCode, 255);
Expect.containsOneOf(<String>[
"pow_test.aot is an AOT snapshot and should be run with 'dartaotruntime'",
// If dartdev itself failed, can happen on SIMARM as not enough is built
// to run it.
"Failed to start the Dart CLI isolate",
], runAotUsingCommandResult.stderr);
print('Got expected error result.');
}

View file

@ -3,6 +3,7 @@
# BSD-style license that can be found in the LICENSE file.
[ $arch == ia32 ]
check_for_aot_snapshot_jit_test: SkipByDesign # No AOT mode on IA32.
link_natives_lazily_test: SkipByDesign # Not supported.
no_allow_absolute_addresses_test: SkipByDesign # Not supported.