From ca9eb4af0f70fc7024f753e87b444ea22fe7f18e Mon Sep 17 00:00:00 2001 From: Daco Harkes Date: Fri, 16 Feb 2024 16:39:09 +0000 Subject: [PATCH] [gardening/test] Cleanup AOT checks in tests Change-Id: I5235c5ba9824f72806214528ed86ecca2f3a7630 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352863 Auto-Submit: Daco Harkes Reviewed-by: Martin Kustermann Commit-Queue: Daco Harkes --- runtime/tests/vm/dart/emit_aot_size_info_flag_test.dart | 3 ++- .../vm/dart/gen_snapshot_include_resolved_urls_test.dart | 3 ++- runtime/tests/vm/dart/isolates/regress_46539_test.dart | 5 ++--- runtime/tests/vm/dart/isolates/reload_utils.dart | 5 +++-- runtime/tests/vm/dart/regress_45898_test.dart | 7 +++---- runtime/tests/vm/dart/regress_54871_test.dart | 6 +++--- runtime/tests/vm/dart/use_flag_test_helper.dart | 4 ++-- .../dwarf_stack_trace_invisible_functions_test.dart | 4 ++-- tests/standalone/dwarf_stack_trace_obfuscate_test.dart | 4 ++-- tests/standalone/dwarf_stack_trace_test.dart | 6 +++--- 10 files changed, 24 insertions(+), 23 deletions(-) diff --git a/runtime/tests/vm/dart/emit_aot_size_info_flag_test.dart b/runtime/tests/vm/dart/emit_aot_size_info_flag_test.dart index 13d9e12bc34..25d0c30010e 100644 --- a/runtime/tests/vm/dart/emit_aot_size_info_flag_test.dart +++ b/runtime/tests/vm/dart/emit_aot_size_info_flag_test.dart @@ -6,13 +6,14 @@ import "dart:async"; import "dart:io"; import "dart:convert"; +import 'package:expect/config.dart'; import 'package:expect/expect.dart'; import 'package:path/path.dart' as path; import 'use_flag_test_helper.dart'; main(List args) async { - if (!Platform.executable.endsWith("dart_precompiled_runtime")) { + if (!isVmAotConfiguration) { return; // Running in JIT: AOT binaries not available. } diff --git a/runtime/tests/vm/dart/gen_snapshot_include_resolved_urls_test.dart b/runtime/tests/vm/dart/gen_snapshot_include_resolved_urls_test.dart index 66f4829f17d..7d56ee22614 100644 --- a/runtime/tests/vm/dart/gen_snapshot_include_resolved_urls_test.dart +++ b/runtime/tests/vm/dart/gen_snapshot_include_resolved_urls_test.dart @@ -6,6 +6,7 @@ import "dart:async"; import "dart:io"; import "dart:convert"; +import 'package:expect/config.dart'; import 'package:expect/expect.dart'; import 'package:path/path.dart' as path; import 'package:test/test.dart'; @@ -13,7 +14,7 @@ import 'package:test/test.dart'; import 'use_flag_test_helper.dart'; main(List args) async { - if (!Platform.executable.endsWith("dart_precompiled_runtime")) { + if (!isVmAotConfiguration) { return; // Running in JIT: AOT binaries not available. } diff --git a/runtime/tests/vm/dart/isolates/regress_46539_test.dart b/runtime/tests/vm/dart/isolates/regress_46539_test.dart index 148280d0aa9..0f191021f20 100644 --- a/runtime/tests/vm/dart/isolates/regress_46539_test.dart +++ b/runtime/tests/vm/dart/isolates/regress_46539_test.dart @@ -12,18 +12,17 @@ import 'dart:io'; import 'dart:isolate'; import 'dart:_internal' show VMInternalsForTesting; +import 'package:expect/config.dart'; import 'package:expect/expect.dart'; const int isolateCount = 3; const int deoptIsolateId = 0; const int polyIsolateId = 1; -final bool isAOT = Platform.executable.contains('dart_precompiled_runtime'); - main() async { // This test will cause deoptimizations (via helper in `dart:_internal`) and // does therefore not run in AOT. - if (isAOT) return; + if (isVmAotConfiguration) return; final onExit = ReceivePort(); final onError = ReceivePort() diff --git a/runtime/tests/vm/dart/isolates/reload_utils.dart b/runtime/tests/vm/dart/isolates/reload_utils.dart index 1030b9ebd58..a624a33055c 100644 --- a/runtime/tests/vm/dart/isolates/reload_utils.dart +++ b/runtime/tests/vm/dart/isolates/reload_utils.dart @@ -7,15 +7,16 @@ import 'dart:io'; import 'dart:convert'; import 'dart:typed_data'; +import 'package:expect/config.dart'; import 'package:path/path.dart' as path; + import '../../../../../pkg/front_end/test/tool/reload.dart'; export '../snapshot_test_helper.dart' show withTempDir; bool get currentVmSupportsReload { final executable = Platform.executable; - return !executable.contains('Product') && - !executable.contains('dart_precompiled_runtime'); + return !executable.contains('Product') && !isVmAotConfiguration; } bool get runningInSimulator { diff --git a/runtime/tests/vm/dart/regress_45898_test.dart b/runtime/tests/vm/dart/regress_45898_test.dart index 7a602005f2c..9564aba31b3 100644 --- a/runtime/tests/vm/dart/regress_45898_test.dart +++ b/runtime/tests/vm/dart/regress_45898_test.dart @@ -5,6 +5,7 @@ import 'dart:async'; import 'dart:io'; +import 'package:expect/config.dart'; import 'package:path/path.dart' as path; import 'use_flag_test_helper.dart'; @@ -58,8 +59,6 @@ void main(List args) async { return; } - final bool isAot = Platform.executable.contains('dart_precompiled_runtime'); - await withTempDir('tts', (String temp) async { final script = path.join(temp, 'script.dart'); await File(script).writeAsString(generateExample()); @@ -69,7 +68,7 @@ void main(List args) async { // binaries). final scriptDill = path.join(temp, 'script.dart.dill'); await run('pkg/vm/tool/gen_kernel', [ - isAot ? '--aot' : '--no-aot', + isVmAotConfiguration ? '--aot' : '--no-aot', '--platform=$platformDill', '-o', scriptDill, @@ -77,7 +76,7 @@ void main(List args) async { ]); String mainFile = scriptDill; - if (isAot) { + if (isVmAotConfiguration) { final elfFile = path.join(temp, 'script.dart.dill.elf'); await run(genSnapshot, [ '--snapshot-kind=app-aot-elf', diff --git a/runtime/tests/vm/dart/regress_54871_test.dart b/runtime/tests/vm/dart/regress_54871_test.dart index 114ab435f2d..7e6bd221229 100644 --- a/runtime/tests/vm/dart/regress_54871_test.dart +++ b/runtime/tests/vm/dart/regress_54871_test.dart @@ -8,15 +8,15 @@ import 'dart:_internal'; import 'dart:ffi'; import 'dart:io'; +import 'package:expect/config.dart'; + const address = 0xaabbccdd; bool deoptimize = false; -final bool isAOT = Platform.executable.contains('dart_precompiled_runtime'); - main() { // This test will cause deoptimizations (via helper in `dart:_internal`) and // does therefore not run in AOT. - if (isAOT) return; + if (isVmAotConfiguration) return; for (int i = 0; i < 100000; ++i) { foo(); diff --git a/runtime/tests/vm/dart/use_flag_test_helper.dart b/runtime/tests/vm/dart/use_flag_test_helper.dart index f63319ae89e..9ab72f46099 100644 --- a/runtime/tests/vm/dart/use_flag_test_helper.dart +++ b/runtime/tests/vm/dart/use_flag_test_helper.dart @@ -5,11 +5,11 @@ import 'dart:convert'; import 'dart:io'; +import 'package:expect/config.dart'; import 'package:expect/expect.dart'; import 'package:path/path.dart' as path; -final isAOTRuntime = path.basenameWithoutExtension(Platform.executable) == - 'dart_precompiled_runtime'; +final isAOTRuntime = isVmAotConfiguration; final buildDir = path.dirname(Platform.executable); final sdkDir = path.dirname(path.dirname(buildDir)); late final platformDill = () { diff --git a/tests/standalone/dwarf_stack_trace_invisible_functions_test.dart b/tests/standalone/dwarf_stack_trace_invisible_functions_test.dart index 4c0f58902b4..41cabd4fb3f 100644 --- a/tests/standalone/dwarf_stack_trace_invisible_functions_test.dart +++ b/tests/standalone/dwarf_stack_trace_invisible_functions_test.dart @@ -6,6 +6,7 @@ import 'dart:io'; +import 'package:expect/config.dart'; import 'package:native_stack_traces/native_stack_traces.dart'; import 'package:path/path.dart' as path; @@ -58,8 +59,7 @@ Future main() async { rawStack = st.toString(); } - if (path.basenameWithoutExtension(Platform.executable) != - "dart_precompiled_runtime") { + if (!isVmAotConfiguration) { return; // Not running from an AOT compiled snapshot. } diff --git a/tests/standalone/dwarf_stack_trace_obfuscate_test.dart b/tests/standalone/dwarf_stack_trace_obfuscate_test.dart index d109984ad94..4a5419ce1f2 100644 --- a/tests/standalone/dwarf_stack_trace_obfuscate_test.dart +++ b/tests/standalone/dwarf_stack_trace_obfuscate_test.dart @@ -6,6 +6,7 @@ import 'dart:io'; +import 'package:expect/config.dart'; import 'package:native_stack_traces/native_stack_traces.dart'; import 'package:path/path.dart' as path; @@ -31,8 +32,7 @@ Future main() async { rawStack = st.toString(); } - if (path.basenameWithoutExtension(Platform.executable) != - "dart_precompiled_runtime") { + if (!isVmAotConfiguration) { return; // Not running from an AOT compiled snapshot. } diff --git a/tests/standalone/dwarf_stack_trace_test.dart b/tests/standalone/dwarf_stack_trace_test.dart index 34964fde434..ce8b10ecd71 100644 --- a/tests/standalone/dwarf_stack_trace_test.dart +++ b/tests/standalone/dwarf_stack_trace_test.dart @@ -7,9 +7,10 @@ import 'dart:convert'; import 'dart:io'; +import 'package:expect/config.dart'; +import 'package:expect/expect.dart'; import 'package:native_stack_traces/native_stack_traces.dart'; import 'package:path/path.dart' as path; -import 'package:expect/expect.dart'; @pragma("vm:prefer-inline") bar() { @@ -31,8 +32,7 @@ Future main() async { rawStack = st.toString(); } - if (path.basenameWithoutExtension(Platform.executable) != - "dart_precompiled_runtime") { + if (!isVmAotConfiguration) { return; // Not running from an AOT compiled snapshot. }