[VM/tests] issue/45618 - Avoid large outputs from tests

Change-Id: I382541458eb618fa9e02b19fee0781ddcc8a2e55
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/201169
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
This commit is contained in:
asiva 2021-05-26 06:04:01 +00:00 committed by commit-bot@chromium.org
parent aa426380b9
commit 4dea737439
13 changed files with 210 additions and 50 deletions

View file

@ -2696,7 +2696,6 @@
"../../../tests/language/unsorted/cyclic_default_values_test.dart",
"../../../tests/language/unsorted/default_implementation_test.dart",
"../../../tests/language/unsorted/default_init_test.dart",
"../../../tests/language/unsorted/disassemble_test.dart",
"../../../tests/language/unsorted/efficient_length_warning_test.dart",
"../../../tests/language/unsorted/emit_const_fields_test.dart",
"../../../tests/language/unsorted/expect_test.dart",
@ -6059,7 +6058,6 @@
"../../../tests/language_2/unsorted/cyclic_default_values_test.dart",
"../../../tests/language_2/unsorted/default_implementation_test.dart",
"../../../tests/language_2/unsorted/default_init_test.dart",
"../../../tests/language_2/unsorted/disassemble_test.dart",
"../../../tests/language_2/unsorted/efficient_length_warning_test.dart",
"../../../tests/language_2/unsorted/emit_const_fields_test.dart",
"../../../tests/language_2/unsorted/expect_test.dart",

View file

@ -0,0 +1,48 @@
// 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.
// Tests proper object recognition in disassembler.
import 'dart:async';
import 'dart:io';
import 'package:expect/expect.dart';
import 'package:path/path.dart' as path;
import 'use_flag_test_helper.dart';
Future<void> main(List<String> args) async {
if (Platform.isAndroid) {
return; // SDK tree and gen_snapshot not available on the test device.
}
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');
await withTempDir('disassemble_aot', (String tempDir) async {
final scriptDill = path.join(tempDir, 'out.dill');
// Compile script to Kernel IR.
await run('pkg/vm/tool/gen_kernel', <String>[
'--aot',
'--platform=$platformDill',
'-o',
scriptDill,
Platform.script.toString(),
]);
// Run the AOT compiler with the disassemble flags set.
final elfFile = path.join(tempDir, 'aot.snapshot');
await Future.wait(<Future>[
run(genSnapshot, <String>[
'--snapshot-kind=app-aot-elf',
'--disassemble',
'--always_generate_trampolines_for_testing',
'--elf=$elfFile',
scriptDill,
]),
]);
});
}

View file

@ -33,22 +33,28 @@ Future<void> main(List<String> args) async {
return; // Our IA32 code is not position independent.
}
final result1 = await runDart('GENERATE DISASSEMBLY 1', [
'--deterministic',
'--disassemble',
'--disassemble-relative',
Platform.script.toFilePath(),
'--child'
]);
final result1 = await runDart(
'GENERATE DISASSEMBLY 1',
[
'--deterministic',
'--disassemble',
'--disassemble-relative',
Platform.script.toFilePath(),
'--child'
],
printOut: false);
final asm1 = result1.processResult.stderr;
final result2 = await runDart('GENERATE DISASSEMBLY 2', [
'--deterministic',
'--disassemble',
'--disassemble-relative',
Platform.script.toFilePath(),
'--child'
]);
final result2 = await runDart(
'GENERATE DISASSEMBLY 2',
[
'--deterministic',
'--disassemble',
'--disassemble-relative',
Platform.script.toFilePath(),
'--child'
],
printOut: false);
final asm2 = result2.processResult.stderr;
Expect.isTrue(

View file

@ -58,12 +58,14 @@ final String genKernel = p.join("pkg", "vm", "bin", "gen_kernel.dart");
final String checkedInDartVM =
p.join("tools", "sdks", "dart-sdk", "bin", "dart${executableSuffix}");
Future<Result> runDart(String prefix, List<String> arguments) {
Future<Result> runDart(String prefix, List<String> arguments,
{bool printOut: true}) {
final augmentedArguments = <String>[]
..addAll(Platform.executableArguments)
..add('--verbosity=warning')
..addAll(arguments);
return runBinary(prefix, Platform.executable, augmentedArguments);
return runBinary(prefix, Platform.executable, augmentedArguments,
printOut: printOut);
}
Future<Result> runGenKernel(String prefix, List<String> arguments) {
@ -89,21 +91,23 @@ Future<Result> runGenSnapshot(String prefix, List<String> arguments) {
}
Future<Result> runBinary(String prefix, String binary, List<String> arguments,
{Map<String, String>? environment, bool runInShell: false}) async {
{Map<String, String>? environment,
bool runInShell: false,
bool printOut: true}) async {
print("+ $binary " + arguments.join(" "));
final processResult = await Process.run(binary, arguments,
environment: environment, runInShell: runInShell);
final result =
new Result('[$prefix] ${binary} ${arguments.join(' ')}', processResult);
if (processResult.stdout.isNotEmpty) {
if (printOut && processResult.stdout.isNotEmpty) {
print('''
Command stdout:
${processResult.stdout}''');
}
if (processResult.stderr.isNotEmpty) {
if (printOut && processResult.stderr.isNotEmpty) {
print('''
Command stderr:

View file

@ -0,0 +1,48 @@
// 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.
// Tests proper object recognition in disassembler.
import 'dart:async';
import 'dart:io';
import 'package:expect/expect.dart';
import 'package:path/path.dart' as path;
import 'use_flag_test_helper.dart';
Future<void> main(List<String> args) async {
if (Platform.isAndroid) {
return; // SDK tree and gen_snapshot not available on the test device.
}
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');
await withTempDir('disassemble_aot', (String tempDir) async {
final scriptDill = path.join(tempDir, 'out.dill');
// Compile script to Kernel IR.
await run('pkg/vm/tool/gen_kernel', <String>[
'--aot',
'--platform=$platformDill',
'-o',
scriptDill,
Platform.script.toString(),
]);
// Run the AOT compiler with the disassemble flags set.
final elfFile = path.join(tempDir, 'aot.snapshot');
await Future.wait(<Future>[
run(genSnapshot, <String>[
'--snapshot-kind=app-aot-elf',
'--disassemble',
'--always_generate_trampolines_for_testing',
'--elf=$elfFile',
scriptDill,
]),
]);
});
}

View file

@ -33,22 +33,28 @@ Future<void> main(List<String> args) async {
return; // Our IA32 code is not position independent.
}
final result1 = await runDart('GENERATE DISASSEMBLY 1', [
'--deterministic',
'--disassemble',
'--disassemble-relative',
Platform.script.toFilePath(),
'--child'
]);
final result1 = await runDart(
'GENERATE DISASSEMBLY 1',
[
'--deterministic',
'--disassemble',
'--disassemble-relative',
Platform.script.toFilePath(),
'--child'
],
printOut: false);
final asm1 = result1.processResult.stderr;
final result2 = await runDart('GENERATE DISASSEMBLY 2', [
'--deterministic',
'--disassemble',
'--disassemble-relative',
Platform.script.toFilePath(),
'--child'
]);
final result2 = await runDart(
'GENERATE DISASSEMBLY 2',
[
'--deterministic',
'--disassemble',
'--disassemble-relative',
Platform.script.toFilePath(),
'--child'
],
printOut: false);
final asm2 = result2.processResult.stderr;
Expect.isTrue(

View file

@ -58,12 +58,14 @@ final String genKernel = p.join("pkg", "vm", "bin", "gen_kernel.dart");
final String checkedInDartVM =
p.join("tools", "sdks", "dart-sdk", "bin", "dart${executableSuffix}");
Future<Result> runDart(String prefix, List<String> arguments) {
Future<Result> runDart(String prefix, List<String> arguments,
{bool printOut: true}) {
final augmentedArguments = <String>[]
..addAll(Platform.executableArguments)
..add('--verbosity=warning')
..addAll(arguments);
return runBinary(prefix, Platform.executable, augmentedArguments);
return runBinary(prefix, Platform.executable, augmentedArguments,
printOut: printOut);
}
Future<Result> runGenKernel(String prefix, List<String> arguments) {
@ -89,21 +91,23 @@ Future<Result> runGenSnapshot(String prefix, List<String> arguments) {
}
Future<Result> runBinary(String prefix, String binary, List<String> arguments,
{Map<String, String> environment, bool runInShell: false}) async {
{Map<String, String> environment,
bool runInShell: false,
bool printOut: true}) async {
print("+ $binary " + arguments.join(" "));
final processResult = await Process.run(binary, arguments,
environment: environment, runInShell: runInShell);
final result =
new Result('[$prefix] ${binary} ${arguments.join(' ')}', processResult);
if (processResult.stdout.isNotEmpty) {
if (printOut && processResult.stdout.isNotEmpty) {
print('''
Command stdout:
${processResult.stdout}''');
}
if (processResult.stderr.isNotEmpty) {
if (printOut && processResult.stderr.isNotEmpty) {
print('''
Command stderr:

View file

@ -30,6 +30,10 @@ dart_2/snapshot_version_test: Skip # This test is a Dart1 test (script snapshot)
dart_2/stack_overflow_shared_test: Pass, Slow # Uses --shared-slow-path-triggers-gc flag.
dart_2/use_bare_instructions_flag_test: Pass, Slow # Spawns several subprocesses
[ $arch == ia32 ]
dart/disassemble_aot_test: SkipByDesign # IA32 does not support AOT.
dart_2/disassemble_aot_test: SkipByDesign # IA32 does not support AOT.
[ $builder_tag == asan ]
dart/transferable_throws_oom_test: SkipByDesign # This test tries to allocate too much memory on purpose. Still dartbug.com/37188
dart_2/transferable_throws_oom_test: SkipByDesign # This test tries to allocate too much memory on purpose. Still dartbug.com/37188
@ -99,8 +103,10 @@ dart_2/v8_snapshot_profile_writer_test: Pass, Slow # Can be slow due to re-invok
[ $compiler != dartkp ]
dart/base_il_serialization: SkipByDesign # Serialization currently supported only when compiling with --aot.
dart/disassemble_aot_test: SkipByDesign # runs gen snapshot.
dart/entrypoints/aot/*: SkipByDesign # These tests should only run on AOT.
dart_2/base_il_serialization: SkipByDesign # Serialization currently supported only when compiling with --aot.
dart_2/disassemble_aot_test: SkipByDesign # runs gen snapshot.
dart_2/entrypoints/aot/*: SkipByDesign # These tests should only run on AOT.
[ $compiler == fasta ]

View file

@ -37,6 +37,9 @@ regress/regress29784_test/02: SkipByDesign # Requires checked mode.
stack_trace/demangle_ctors_test: SkipByDesign # Names are not scrubbed.
type/checks_in_factory_method_test: SkipByDesign # Requires checked mode.
[ $runtime != vm ]
unsorted/disassemble_test: Skip # VM only test
[ $compiler != dart2analyzer && $compiler != fasta ]
identifier/built_in_type_annotation_test/*: SkipByDesign # Analyzer/CFE only tests.

View file

@ -6,10 +6,12 @@
[ $compiler == app_jitk ]
main/no_main_test/01: Crash
number/web_int_literals_test/*: SkipByDesign # Test applies only to JavaScript targets
unsorted/disassemble_test: SkipByDesign # Tested in JIT mode.
vm/regress_27671_test: SkipByDesign # Relies on string comparison of exception message which may return '<optimized out>'
[ $compiler == dartkp ]
number/web_int_literals_test/*: SkipByDesign # Test applies only to JavaScript targets
unsorted/disassemble_test: SkipByDesign # JIT only test
[ $compiler == fasta ]
number/web_int_literals_test/*: SkipByDesign # Test applies only to JavaScript targets

View file

@ -2,15 +2,31 @@
// 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.
// VMOptions=--disassemble
// VMOptions=--disassemble --always_generate_trampolines_for_testing
// Tests proper object recognition in disassembler.
import 'dart:async';
import 'dart:io';
import "package:expect/expect.dart";
Future runBinary(String binary, List<String> arguments) async {
print("+ $binary " + arguments.join(" "));
final result = await Process.run(binary, arguments);
return result;
}
f(x) {
return "foo";
}
main() {
print(f(0));
Future<void> main(List<String> args) async {
if (args.contains('--child')) {
print(f(0));
return;
}
if (Platform.executable.contains("Product")) {
return; // No disassembler in product mode.
}
final result = await runBinary(Platform.executable,
['--disassemble', Platform.script.toFilePath(), '--child']);
Expect.equals(0, result.exitCode);
}

View file

@ -31,6 +31,9 @@ regress/regress29784_test/02: SkipByDesign # Requires checked mode.
stack_trace/demangle_ctors_test: SkipByDesign # Names are not scrubbed.
type/checks_in_factory_method_test: SkipByDesign # Requires checked mode.
[ $runtime != vm ]
unsorted/disassemble_test: Skip # VM only test
[ $compiler != dart2analyzer && $compiler != fasta ]
identifier/built_in_type_annotation_test/*: SkipByDesign # Analyzer/CFE only tests.

View file

@ -4,15 +4,31 @@
// @dart = 2.9
// VMOptions=--disassemble
// VMOptions=--disassemble --always_generate_trampolines_for_testing
// Tests proper object recognition in disassembler.
import 'dart:async';
import 'dart:io';
import "package:expect/expect.dart";
Future runBinary(String binary, List<String> arguments) async {
print("+ $binary " + arguments.join(" "));
final result = await Process.run(binary, arguments);
return result;
}
f(x) {
return "foo";
}
main() {
print(f(0));
Future<void> main(List<String> args) async {
if (args.contains('--child')) {
print(f(0));
return;
}
if (Platform.executable.contains("Product")) {
return; // No disassembler in product mode.
}
final result = await runBinary(Platform.executable,
['--disassemble', Platform.script.toFilePath(), '--child']);
Expect.equals(0, result.exitCode);
}