Skip to content

Commit 6eba1cc

Browse files
rmacnak-googleCommit Queue
authored and
Commit Queue
committed
[test] Unify discovery of gen_snapshot etc paths and fix for simarm_x64.
Bug: #51949 Change-Id: I4a0dfe82fc33f86b1795b62e022e66dba86cb260 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293462 Reviewed-by: Brian Quinlan <[email protected]> Commit-Queue: Ryan Macnak <[email protected]>
1 parent 5573ce7 commit 6eba1cc

32 files changed

+126
-155
lines changed

runtime/tests/vm/dart/disassemble_aot_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ Future<void> main(List<String> args) async {
3131
if (!await testExecutable(genSnapshot)) {
3232
throw "Cannot run test as $genSnapshot not available";
3333
}
34-
if (!await testExecutable(aotRuntime)) {
35-
throw "Cannot run test as $aotRuntime not available";
34+
if (!await testExecutable(dartPrecompiledRuntime)) {
35+
throw "Cannot run test as $dartPrecompiledRuntime not available";
3636
}
3737
if (!File(platformDill).existsSync()) {
3838
throw "Cannot run test as $platformDill does not exist";
@@ -64,7 +64,7 @@ Future<void> main(List<String> args) async {
6464
]);
6565

6666
// Run the AOT runtime with the disassemble flags set.
67-
await run(
68-
aotRuntime, <String>['--disassemble', '--disassemble_stubs', elfFile]);
67+
await run(dartPrecompiledRuntime,
68+
<String>['--disassemble', '--disassemble_stubs', elfFile]);
6969
});
7070
}

runtime/tests/vm/dart/emit_aot_size_info_flag_test.dart

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ main(List<String> args) async {
2020
return; // SDK tree and gen_snapshot not available on the test device.
2121
}
2222

23-
final buildDir = path.dirname(Platform.executable);
24-
final sdkDir = path.dirname(path.dirname(buildDir));
25-
final platformDill = path.join(buildDir, 'vm_platform_strong.dill');
26-
final genSnapshot = path.join(buildDir, 'gen_snapshot');
27-
final aotRuntime = path.join(buildDir, 'dart_precompiled_runtime');
28-
2923
await withTempDir('emit_aot_size_info_flag', (String tempDir) async {
3024
final script = path.join(sdkDir, 'pkg/kernel/bin/dump.dart');
3125
final scriptDill = path.join(tempDir, 'kernel_dump.dill');
@@ -55,7 +49,7 @@ main(List<String> args) async {
5549

5650
// Ensure we can actually run the code.
5751
await Future.wait(<Future>[
58-
run(aotRuntime, <String>[
52+
run(dartPrecompiledRuntime, <String>[
5953
elfFile,
6054
scriptDill,
6155
path.join(tempDir, 'ignored.txt'),

runtime/tests/vm/dart/gen_snapshot_include_resolved_urls_test.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import 'package:expect/expect.dart';
1010
import 'package:path/path.dart' as path;
1111
import 'package:test/test.dart';
1212

13+
import 'use_flag_test_helper.dart';
14+
1315
main(List<String> args) async {
1416
if (!Platform.executable.endsWith("dart_precompiled_runtime")) {
1517
return; // Running in JIT: AOT binaries not available.
@@ -19,8 +21,6 @@ main(List<String> args) async {
1921
return; // SDK tree and gen_snapshot not available on the test device.
2022
}
2123

22-
final buildDir = path.dirname(Platform.executable);
23-
final sdkDir = path.dirname(path.dirname(buildDir));
2424
final scriptUrl = path.join(
2525
sdkDir,
2626
'runtime',
@@ -30,10 +30,6 @@ main(List<String> args) async {
3030
'gen_snapshot_include_resolved_urls_script.dart',
3131
);
3232

33-
final platformDill = path.join(buildDir, 'vm_platform_strong.dill');
34-
final genSnapshot = path.join(buildDir, 'gen_snapshot');
35-
final aotRuntime = path.join(buildDir, 'dart_precompiled_runtime');
36-
3733
late Directory tempDir;
3834
setUpAll(() async {
3935
tempDir = Directory.systemTemp.createTempSync('aot-script-urls-test');
@@ -79,7 +75,7 @@ main(List<String> args) async {
7975

8076
// Ensure we can actually run the code.
8177
expect(
82-
await run(aotRuntime, <String>[
78+
await run(dartPrecompiledRuntime, <String>[
8379
'--enable-vm-service=0',
8480
'--profiler',
8581
elfFile,

runtime/tests/vm/dart/incompatible_loading_unit_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,15 @@ main(List<String> args) async {
107107
Expect.isTrue(await new File(deferredSnapshot2).exists());
108108

109109
// Works when used normally.
110-
var lines = await runOutput(aotRuntime, <String>[snapshot1]);
110+
var lines = await runOutput(dartPrecompiledRuntime, <String>[snapshot1]);
111111
Expect.listEquals(["One!"], lines);
112112

113-
lines = await runOutput(aotRuntime, <String>[snapshot2]);
113+
lines = await runOutput(dartPrecompiledRuntime, <String>[snapshot2]);
114114
Expect.listEquals(["Two!"], lines);
115115

116116
// Fails gracefully when mixing snapshot parts.
117117
await new File(deferredSnapshot2).rename(deferredSnapshot1);
118-
lines = await runError(aotRuntime, <String>[snapshot1]);
118+
lines = await runError(dartPrecompiledRuntime, <String>[snapshot1]);
119119
Expect.equals(
120120
"DeferredLoadException: 'Deferred loading unit is from a different program than the main loading unit'",
121121
lines[1]);

runtime/tests/vm/dart/product_aot_kernel_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ import 'package:path/path.dart' as path;
1919
import 'use_flag_test_helper.dart';
2020

2121
Future main(List<String> args) async {
22-
final buildDir = path.dirname(Platform.resolvedExecutable);
23-
2422
if (!buildDir.contains('Product')) {
2523
print('Skipping test due to running in non-PRODUCT configuration.');
2624
return;

runtime/tests/vm/dart/regress_45898_test.dart

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,7 @@ import 'dart:io';
77

88
import 'package:path/path.dart' as path;
99

10-
import 'use_flag_test_helper.dart' show withTempDir, run;
11-
12-
final buildDir = path.dirname(Platform.executable);
13-
final platformDill = path.join(buildDir, 'vm_platform_strong.dill');
14-
final genSnapshot1 = path.join(buildDir, 'gen_snapshot');
15-
final genSnapshot2 = path.join('${buildDir}_X64', 'gen_snapshot');
16-
final genSnapshot =
17-
File(genSnapshot1).existsSync() ? genSnapshot1 : genSnapshot2;
10+
import 'use_flag_test_helper.dart';
1811

1912
const classCount = 10000;
2013
const subclassCount = 5000;

runtime/tests/vm/dart/run_appended_aot_snapshot_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Future<void> main(List<String> args) async {
3333
.toList();
3434

3535
{
36-
final result = await generateAotKernel(checkedInDartVM, genKernel,
36+
final result = await generateAotKernel(checkedInDartVM, genKernelDart,
3737
platformDill, sourcePath, dillPath, null, [],
3838
extraGenKernelOptions: extraGenKernelOptions);
3939
Expect.equals(result.stderr, '');

runtime/tests/vm/dart/snapshot_test_helper.dart

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import 'dart:math';
99
import 'package:expect/expect.dart';
1010
import 'package:path/path.dart' as p;
1111

12+
import 'use_flag_test_helper.dart';
13+
export 'use_flag_test_helper.dart';
14+
1215
class Result {
1316
final String cmdline;
1417
final ProcessResult processResult;
@@ -46,18 +49,6 @@ void expectOutput(String what, Result result) {
4649
}
4750
}
4851

49-
final String scriptSuffix = Platform.isWindows ? ".bat" : "";
50-
final String executableSuffix = Platform.isWindows ? ".exe" : "";
51-
final String buildDir = p.dirname(Platform.executable);
52-
final String platformDill = p.join(buildDir, "vm_platform_strong.dill");
53-
final String genSnapshot = p.join(buildDir, "gen_snapshot${executableSuffix}");
54-
final String dart = p.join(buildDir, "dart${executableSuffix}");
55-
final String dartPrecompiledRuntime =
56-
p.join(buildDir, "dart_precompiled_runtime${executableSuffix}");
57-
final String genKernel = p.join("pkg", "vm", "bin", "gen_kernel.dart");
58-
final String checkedInDartVM =
59-
p.join("tools", "sdks", "dart-sdk", "bin", "dart${executableSuffix}");
60-
6152
Future<Result> runDart(String prefix, List<String> arguments,
6253
{bool printOut = true}) {
6354
final augmentedArguments = <String>[]
@@ -83,7 +74,7 @@ Future<Result> runGenKernel(String prefix, List<String> arguments) {
8374

8475
Future<Result> runGenKernelWithoutStandardOptions(
8576
String prefix, List<String> arguments) {
86-
return runBinary(prefix, checkedInDartVM, [genKernel, ...arguments]);
77+
return runBinary(prefix, checkedInDartVM, [genKernelDart, ...arguments]);
8778
}
8879

8980
Future<Result> runGenSnapshot(String prefix, List<String> arguments) {

runtime/tests/vm/dart/spawn_uri_aot_test.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ main(List<String> args) async {
2222
if (!await testExecutable(genSnapshot)) {
2323
throw "Cannot run test as $genSnapshot not available";
2424
}
25-
if (!await testExecutable(aotRuntime)) {
26-
throw "Cannot run test as $aotRuntime not available";
25+
if (!await testExecutable(dartPrecompiledRuntime)) {
26+
throw "Cannot run test as $dartPrecompiledRuntime not available";
2727
}
2828
if (!File(platformDill).existsSync()) {
2929
throw "Cannot run test as $platformDill does not exist";
@@ -85,7 +85,7 @@ main(List<String> args) async {
8585
}
8686

8787
// Successful run
88-
final result1 = await runOutput(aotRuntime, <String>[
88+
final result1 = await runOutput(dartPrecompiledRuntime, <String>[
8989
path.join(dir, 'main.dart.dill.so'),
9090
path.join(dir, 'spawnee.dart.dill.so'),
9191
]);
@@ -98,7 +98,7 @@ main(List<String> args) async {
9898
if (!isProductMode) {
9999
// File exists and is AOT snapshot but was compiled with different flags
100100
// (namely --enable-asserts)
101-
final result2 = await runHelper(aotRuntime, [
101+
final result2 = await runHelper(dartPrecompiledRuntime, [
102102
path.join(dir, 'main.dart.dill.so'),
103103
path.join(dir, 'spawnee_checked.dart.dill.so'),
104104
]);
@@ -109,7 +109,7 @@ main(List<String> args) async {
109109
}
110110

111111
// File does not exist.
112-
final result3 = await runHelper(aotRuntime, [
112+
final result3 = await runHelper(dartPrecompiledRuntime, [
113113
path.join(dir, 'main.dart.dill.so'),
114114
path.join(dir, 'does_not_exist.dart.dill.so'),
115115
]);

runtime/tests/vm/dart/use_add_readonly_data_symbols_flag_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ main(List<String> args) async {
2929
if (!await testExecutable(genSnapshot)) {
3030
throw "Cannot run test as $genSnapshot not available";
3131
}
32-
if (!await testExecutable(aotRuntime)) {
33-
throw "Cannot run test as $aotRuntime not available";
32+
if (!await testExecutable(dartPrecompiledRuntime)) {
33+
throw "Cannot run test as $dartPrecompiledRuntime not available";
3434
}
3535
if (!File(platformDill).existsSync()) {
3636
throw "Cannot run test as $platformDill does not exist";

runtime/tests/vm/dart/use_code_comments_flag_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ main(List<String> args) async {
5959
final commentsOut1 = path.join(tempDir, 'comments-out1.txt');
6060
final commentsOut2 = path.join(tempDir, 'comments-out2.txt');
6161
await Future.wait(<Future>[
62-
run(aotRuntime, <String>[
62+
run(dartPrecompiledRuntime, <String>[
6363
'--code-comments',
6464
scriptCommentedSnapshot,
6565
scriptDill,
6666
commentsOut1,
6767
]),
68-
run(aotRuntime, <String>[
68+
run(dartPrecompiledRuntime, <String>[
6969
'--no-code-comments',
7070
scriptCommentedSnapshot,
7171
scriptDill,
@@ -77,13 +77,13 @@ main(List<String> args) async {
7777
final uncommentedOut1 = path.join(tempDir, 'uncommented-out1.txt');
7878
final uncommentedOut2 = path.join(tempDir, 'uncommented-out2.txt');
7979
await Future.wait(<Future>[
80-
run(aotRuntime, <String>[
80+
run(dartPrecompiledRuntime, <String>[
8181
'--code-comments',
8282
scriptUncommentedSnapshot,
8383
scriptDill,
8484
uncommentedOut1,
8585
]),
86-
run(aotRuntime, <String>[
86+
run(dartPrecompiledRuntime, <String>[
8787
'--no-code-comments',
8888
scriptUncommentedSnapshot,
8989
scriptDill,

runtime/tests/vm/dart/use_dwarf_stack_traces_flag_test.dart

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ main(List<String> args) async {
3030
if (!await testExecutable(genSnapshot)) {
3131
throw "Cannot run test as $genSnapshot not available";
3232
}
33-
if (!await testExecutable(aotRuntime)) {
34-
throw "Cannot run test as $aotRuntime not available";
33+
if (!await testExecutable(dartPrecompiledRuntime)) {
34+
throw "Cannot run test as $dartPrecompiledRuntime not available";
3535
}
3636
if (!File(platformDill).existsSync()) {
3737
throw "Cannot run test as $platformDill does not exist";
@@ -80,27 +80,29 @@ main(List<String> args) async {
8080

8181
// Run the resulting Dwarf-AOT compiled script.
8282

83-
final output1 = await runTestProgram(aotRuntime,
83+
final output1 = await runTestProgram(dartPrecompiledRuntime,
8484
<String>['--dwarf-stack-traces-mode', scriptDwarfSnapshot, scriptDill]);
85-
final output2 = await runTestProgram(aotRuntime, <String>[
85+
final output2 = await runTestProgram(dartPrecompiledRuntime, <String>[
8686
'--no-dwarf-stack-traces-mode',
8787
scriptDwarfSnapshot,
8888
scriptDill
8989
]);
9090

9191
// Run the resulting non-Dwarf-AOT compiled script.
92-
final nonDwarfTrace1 = (await runTestProgram(aotRuntime, <String>[
92+
final nonDwarfTrace1 =
93+
(await runTestProgram(dartPrecompiledRuntime, <String>[
9394
'--dwarf-stack-traces-mode',
9495
scriptNonDwarfSnapshot,
9596
scriptDill,
9697
]))
97-
.trace;
98-
final nonDwarfTrace2 = (await runTestProgram(aotRuntime, <String>[
98+
.trace;
99+
final nonDwarfTrace2 =
100+
(await runTestProgram(dartPrecompiledRuntime, <String>[
99101
'--no-dwarf-stack-traces-mode',
100102
scriptNonDwarfSnapshot,
101103
scriptDill,
102104
]))
103-
.trace;
105+
.trace;
104106

105107
// Ensure the result is based off the flag passed to gen_snapshot, not
106108
// the one passed to the runtime.
@@ -148,12 +150,12 @@ Future<void> testAssembly(
148150
debug: true);
149151

150152
// Run the resulting Dwarf-AOT compiled script.
151-
final assemblyOutput1 = await runTestProgram(aotRuntime, <String>[
153+
final assemblyOutput1 = await runTestProgram(dartPrecompiledRuntime, <String>[
152154
'--dwarf-stack-traces-mode',
153155
scriptDwarfAssemblySnapshot,
154156
scriptDill,
155157
]);
156-
final assemblyOutput2 = await runTestProgram(aotRuntime, <String>[
158+
final assemblyOutput2 = await runTestProgram(dartPrecompiledRuntime, <String>[
157159
'--no-dwarf-stack-traces-mode',
158160
scriptDwarfAssemblySnapshot,
159161
scriptDill,

runtime/tests/vm/dart/use_flag_test_helper.dart

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,23 @@ final isAOTRuntime = path.basenameWithoutExtension(Platform.executable) ==
1212
'dart_precompiled_runtime';
1313
final buildDir = path.dirname(Platform.executable);
1414
final sdkDir = path.dirname(path.dirname(buildDir));
15-
final platformDill = path.join(buildDir, 'vm_platform_strong.dill');
15+
late final platformDill = () {
16+
final possiblePaths = [
17+
// No cross compilation.
18+
path.join(buildDir, 'vm_platform_strong.dill'),
19+
// ${MODE}SIMARM_X64 for X64->SIMARM cross compilation.
20+
path.join('${buildDir}_X64', 'vm_platform_strong.dill'),
21+
];
22+
for (final path in possiblePaths) {
23+
if (File(path).existsSync()) {
24+
return path;
25+
}
26+
}
27+
throw 'Could not find vm_platform_strong.dill for build directory $buildDir';
28+
}();
1629
final genKernel = path.join(sdkDir, 'pkg', 'vm', 'tool',
1730
'gen_kernel' + (Platform.isWindows ? '.bat' : ''));
31+
final genKernelDart = path.join('pkg', 'vm', 'bin', 'gen_kernel.dart');
1832
final _genSnapshotBase = 'gen_snapshot' + (Platform.isWindows ? '.exe' : '');
1933
// Lazily initialize `genSnapshot` so that tests that don't use it on platforms
2034
// that don't have a `gen_snapshot` don't fail.
@@ -34,8 +48,12 @@ late final genSnapshot = () {
3448
}
3549
throw 'Could not find gen_snapshot for build directory $buildDir';
3650
}();
37-
final aotRuntime = path.join(
51+
final dart = path.join(buildDir, 'dart' + (Platform.isWindows ? '.exe' : ''));
52+
final dartPrecompiledRuntime = path.join(
3853
buildDir, 'dart_precompiled_runtime' + (Platform.isWindows ? '.exe' : ''));
54+
final checkedInDartVM = path.join('tools', 'sdks', 'dart-sdk', 'bin',
55+
'dart' + (Platform.isWindows ? '.exe' : ''));
56+
3957
final isSimulator = path.basename(buildDir).contains('SIM');
4058

4159
String? get clangBuildToolsDir {

runtime/tests/vm/dart/use_resolve_dwarf_paths_flag_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ main(List<String> args) async {
2929
if (!await testExecutable(genSnapshot)) {
3030
throw "Cannot run test as $genSnapshot not available";
3131
}
32-
if (!await testExecutable(aotRuntime)) {
33-
throw "Cannot run test as $aotRuntime not available";
32+
if (!await testExecutable(dartPrecompiledRuntime)) {
33+
throw "Cannot run test as $dartPrecompiledRuntime not available";
3434
}
3535
if (!File(platformDill).existsSync()) {
3636
throw "Cannot run test as $platformDill does not exist";
@@ -71,7 +71,7 @@ void runTests({required bool obfuscate}) async {
7171
]);
7272

7373
// Run the resulting Dwarf-AOT compiled script.
74-
final dwarfTrace = await runError(aotRuntime, <String>[
74+
final dwarfTrace = await runError(dartPrecompiledRuntime, <String>[
7575
scriptDwarfSnapshot,
7676
scriptDill,
7777
]);

0 commit comments

Comments
 (0)