From 45b51f9ab62642ba2c385c57a0085fb380118cd5 Mon Sep 17 00:00:00 2001 From: Tess Strickland Date: Wed, 26 May 2021 13:25:32 +0000 Subject: [PATCH] [vm/tests] Fix vm/dart/disassemble_aot_test. Bug: https://github.com/dart-lang/sdk/issues/46143 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-win-release-x64-try Change-Id: I2fa01046030471266c04b233adbd0016ec67ea82 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/201270 Commit-Queue: Tess Strickland Reviewed-by: Daco Harkes --- .../tests/vm/dart/disassemble_aot_test.dart | 37 ++++++++++++++----- .../tests/vm/dart_2/disassemble_aot_test.dart | 37 ++++++++++++++----- 2 files changed, 56 insertions(+), 18 deletions(-) diff --git a/runtime/tests/vm/dart/disassemble_aot_test.dart b/runtime/tests/vm/dart/disassemble_aot_test.dart index 1ad231258ca..80a32c33e0a 100644 --- a/runtime/tests/vm/dart/disassemble_aot_test.dart +++ b/runtime/tests/vm/dart/disassemble_aot_test.dart @@ -1,8 +1,11 @@ // Copyright (c) 2021, 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. - +// +// OtherResources=use_dwarf_stack_traces_flag_program.dart +// // Tests proper object recognition in disassembler. + import 'dart:async'; import 'dart:io'; @@ -12,25 +15,41 @@ import 'package:path/path.dart' as path; import 'use_flag_test_helper.dart'; Future main(List args) async { - if (Platform.isAndroid) { - return; // SDK tree and gen_snapshot not available on the test device. + if (!isAOTRuntime) { + return; // Running in JIT: AOT binaries not available. } - 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'); + if (const bool.fromEnvironment('dart.vm.product')) { + return; // No disassembling in PRODUCT mode. + } + + if (Platform.isAndroid) { + return; // SDK tree and dart_bootstrap not available on the test device. + } + + // These are the tools we need to be available to run on a given platform: + if (!await testExecutable(genSnapshot)) { + throw "Cannot run test as $genSnapshot not available"; + } + if (!await testExecutable(aotRuntime)) { + throw "Cannot run test as $aotRuntime not available"; + } + if (!File(platformDill).existsSync()) { + throw "Cannot run test as $platformDill does not exist"; + } await withTempDir('disassemble_aot', (String tempDir) async { + final cwDir = path.dirname(Platform.script.toFilePath()); + final script = path.join(cwDir, 'use_dwarf_stack_traces_flag_program.dart'); final scriptDill = path.join(tempDir, 'out.dill'); // Compile script to Kernel IR. - await run('pkg/vm/tool/gen_kernel', [ + await run(genKernel, [ '--aot', '--platform=$platformDill', '-o', scriptDill, - Platform.script.toString(), + script, ]); // Run the AOT compiler with the disassemble flags set. diff --git a/runtime/tests/vm/dart_2/disassemble_aot_test.dart b/runtime/tests/vm/dart_2/disassemble_aot_test.dart index 1ad231258ca..80a32c33e0a 100644 --- a/runtime/tests/vm/dart_2/disassemble_aot_test.dart +++ b/runtime/tests/vm/dart_2/disassemble_aot_test.dart @@ -1,8 +1,11 @@ // Copyright (c) 2021, 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. - +// +// OtherResources=use_dwarf_stack_traces_flag_program.dart +// // Tests proper object recognition in disassembler. + import 'dart:async'; import 'dart:io'; @@ -12,25 +15,41 @@ import 'package:path/path.dart' as path; import 'use_flag_test_helper.dart'; Future main(List args) async { - if (Platform.isAndroid) { - return; // SDK tree and gen_snapshot not available on the test device. + if (!isAOTRuntime) { + return; // Running in JIT: AOT binaries not available. } - 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'); + if (const bool.fromEnvironment('dart.vm.product')) { + return; // No disassembling in PRODUCT mode. + } + + if (Platform.isAndroid) { + return; // SDK tree and dart_bootstrap not available on the test device. + } + + // These are the tools we need to be available to run on a given platform: + if (!await testExecutable(genSnapshot)) { + throw "Cannot run test as $genSnapshot not available"; + } + if (!await testExecutable(aotRuntime)) { + throw "Cannot run test as $aotRuntime not available"; + } + if (!File(platformDill).existsSync()) { + throw "Cannot run test as $platformDill does not exist"; + } await withTempDir('disassemble_aot', (String tempDir) async { + final cwDir = path.dirname(Platform.script.toFilePath()); + final script = path.join(cwDir, 'use_dwarf_stack_traces_flag_program.dart'); final scriptDill = path.join(tempDir, 'out.dill'); // Compile script to Kernel IR. - await run('pkg/vm/tool/gen_kernel', [ + await run(genKernel, [ '--aot', '--platform=$platformDill', '-o', scriptDill, - Platform.script.toString(), + script, ]); // Run the AOT compiler with the disassemble flags set.