1
0
mirror of https://github.com/dart-lang/sdk synced 2024-07-03 00:08:46 +00:00

[test] Switch Fuchsia testing to CFv2.

Bug: https://github.com/dart-lang/sdk/issues/38752
Change-Id: Id6519937cfa8430249d576c99aeb6bdb9f97dbb7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332481
Reviewed-by: Zijie He <zijiehe@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
This commit is contained in:
Ryan Macnak 2023-10-30 20:03:40 +00:00 committed by Commit Queue
parent 25002f0f01
commit 4fa5cadb36
9 changed files with 66 additions and 194 deletions

View File

@ -225,7 +225,7 @@ if (is_fuchsia) {
}
dart_fuchsia_test_component("fuchsia_test_component") {
manifest = "build/fuchsia/fuchsia_test_component.cmx"
manifest = "build/fuchsia/fuchsia_test_component.cml"
resource_dirs = [
"pkg/async_helper",
"pkg/expect",
@ -253,7 +253,7 @@ if (is_fuchsia) {
}
dart_fuchsia_test_component("fuchsia_ffi_test_component") {
manifest = "build/fuchsia/fuchsia_ffi_test_component.cmx"
manifest = "build/fuchsia/fuchsia_ffi_test_component.cml"
data_deps = [
"runtime/bin:ffi_test_dynamic_library",
"runtime/bin:ffi_test_functions",
@ -274,28 +274,4 @@ if (is_fuchsia) {
package_name = "dart_ffi_test"
deps = [ ":fuchsia_ffi_test_component" ]
}
# TODO(38752): Remove "cfv2" once everything is migrated to CFv2.
dart_fuchsia_test_component("fuchsia_ffi_test_component_cfv2") {
manifest = "build/fuchsia/fuchsia_ffi_test_component.cml"
data_deps = [
"runtime/bin:ffi_test_dynamic_library",
"runtime/bin:ffi_test_functions",
]
library_files = [
"libffi_test_dynamic_library.so",
"libffi_test_functions.so",
]
resource_dirs = [
"pkg/expect",
"pkg/meta",
"tests/ffi",
"third_party/pkg/ffi",
]
}
dart_fuchsia_test_package("fuchsia_ffi_test_package_cfv2") {
package_name = "dart_ffi_test_cfv2"
deps = [ ":fuchsia_ffi_test_component_cfv2" ]
}
}

4
DEPS
View File

@ -87,7 +87,7 @@ vars = {
"reclient_version": "git_revision:81e819b39d4743462857cc55430d898b9fcca1af",
# Update from https://chrome-infra-packages.appspot.com/p/fuchsia/sdk/gn
"fuchsia_sdk_version": "version:12.20230407.0.1",
"fuchsia_sdk_version": "version:15.20231018.3.4",
"download_fuchsia_deps": False,
# Ninja, runs the build based on files generated by GN.
@ -670,7 +670,7 @@ Var("dart_root") + "/third_party/pkg/tar":
"packages": [
{
"package": "chromium/fuchsia/test-scripts/fuchsia",
"version": "version:2@30ecdcc6666ac09845a2e2d4fe7d8d5714230fba",
"version": "version:2@56179f1724e9bf82ce7abf5577884e5d217b52e9",
}
],
"condition":

View File

@ -1,27 +0,0 @@
{
"program": {
"binary": "exe.stripped/dart"
},
"sandbox": {
"features": [
"config-data",
"isolated-cache-storage",
"isolated-persistent-storage",
"isolated-temp",
"root-ssl-certificates"
],
"services": [
"fuchsia.deprecatedtimezone.Timezone",
"fuchsia.device.NameProvider",
"fuchsia.feedback.CrashReporter",
"fuchsia.intl.PropertyProvider",
"fuchsia.kernel.VmexResource",
"fuchsia.logger.LogSink",
"fuchsia.net.name.Lookup",
"fuchsia.posix.socket.Provider",
"fuchsia.sysmem.Allocator",
"fuchsia.timezone.Timezone",
"fuchsia.tracing.provider.Registry"
]
}
}

View File

@ -0,0 +1,54 @@
{
program: {
binary: "exe.stripped/dart",
runner: "elf_test_runner",
},
capabilities: [
{ protocol: "fuchsia.test.Suite" },
],
expose: [
{
protocol: "fuchsia.test.Suite",
from: "self",
},
],
use: [
{
directory: "config-data",
rights: [ "r*" ],
path: "/config/data",
},
{
storage: "cache",
path: "/cache",
},
{
storage: "data",
path: "/data",
},
{
storage: "tmp",
path: "/tmp",
},
{
directory: "root-ssl-certificates",
rights: [ "r*" ],
path: "/config/ssl",
},
{
protocol: [
"fuchsia.deprecatedtimezone.Timezone",
"fuchsia.device.NameProvider",
"fuchsia.feedback.CrashReporter",
"fuchsia.intl.PropertyProvider",
"fuchsia.kernel.VmexResource",
"fuchsia.logger.LogSink",
"fuchsia.net.name.Lookup",
"fuchsia.posix.socket.Provider",
"fuchsia.sysmem.Allocator",
"fuchsia.timezone.Timezone",
"fuchsia.tracing.provider.Registry",
],
},
]
}

View File

@ -1,27 +0,0 @@
{
"program": {
"binary": "exe.stripped/dart"
},
"sandbox": {
"features": [
"config-data",
"isolated-cache-storage",
"isolated-persistent-storage",
"isolated-temp",
"root-ssl-certificates"
],
"services": [
"fuchsia.deprecatedtimezone.Timezone",
"fuchsia.device.NameProvider",
"fuchsia.feedback.CrashReporter",
"fuchsia.intl.PropertyProvider",
"fuchsia.kernel.VmexResource",
"fuchsia.logger.LogSink",
"fuchsia.net.name.Lookup",
"fuchsia.posix.socket.Provider",
"fuchsia.sysmem.Allocator",
"fuchsia.timezone.Timezone",
"fuchsia.tracing.provider.Registry"
]
}
}

View File

@ -3,10 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
import 'dart:async';
import 'dart:io';
import 'command.dart';
import 'fuchsia_cfv1.dart';
import 'fuchsia_cfv2.dart';
// Sets up and executes commands against a Fuchsia environment.
@ -23,10 +21,7 @@ abstract class FuchsiaEmulator {
static final FuchsiaEmulator _instance = _create();
static FuchsiaEmulator _create() {
if (Platform.environment.containsKey('FUCHSIA_CFV2')) {
return FuchsiaEmulatorCFv2();
}
return FuchsiaEmulatorCFv1();
return FuchsiaEmulatorCFv2();
}
static FuchsiaEmulator instance() {

View File

@ -1,102 +0,0 @@
// Copyright (c) 2023, 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.
import 'dart:async';
import 'dart:io';
import 'command.dart';
import 'fuchsia.dart';
import 'repository.dart';
// Runs tests on a fuchsia emulator with legacy tools and CFv1 targets.
class FuchsiaEmulatorCFv1 extends FuchsiaEmulator {
static const String fsshTool =
"./third_party/fuchsia/sdk/linux/tools/x64/fssh";
static const String ffx = "./third_party/fuchsia/sdk/linux/tools/x64/ffx";
static const String pm = "./third_party/fuchsia/sdk/linux/tools/x64/pm";
@override
Future<void> publishPackage(String buildDir, String mode, String arch) async {
stop();
// Setup package server.
var packageRepositoryPath = "dart-test-package-repository-$mode-$arch";
var packageRepositoryName = "dart-test-package-repository-$mode-$arch-name";
var f = Directory(packageRepositoryPath);
if (f.existsSync()) f.deleteSync(recursive: true);
_run(pm, ["newrepo", "-repo", packageRepositoryPath]);
_run(pm, [
"publish",
"-a",
"-repo",
packageRepositoryPath,
"-f",
"$buildDir/gen/dart_ffi_test_$mode/dart_ffi_test_$mode.far"
]);
_run(ffx, [
"repository",
"add-from-pm",
packageRepositoryPath,
"-r",
packageRepositoryName
]);
_run(ffx, ["repository", "server", "start"]);
// Setup emulator.
var emulatorName = "dart-fuchsia-$mode-$arch";
_run(ffx, ["product-bundle", "get", "terminal.qemu-$arch"]);
_run(ffx, [
"emu",
"start",
"terminal.qemu-$arch",
"--name",
emulatorName,
"--headless"
]);
_run(ffx, [
"-t",
emulatorName,
"target",
"repository",
"register",
"-r",
packageRepositoryName,
"--alias",
"fuchsia.com"
]);
}
@override
void stop() {
_run(ffx, ["emu", "stop", "--all"]);
_run(ffx, ["repository", "server", "stop"]);
}
@override
VMCommand getTestCommand(
String buildDir, String mode, String arch, List<String> arguments) {
arguments = arguments
.map((arg) => arg.replaceAll(Repository.uri.toFilePath(), '/pkg/data/'))
.toList();
return VMCommand(fsshTool, [
"-device-name",
"dart-fuchsia-$mode-$arch",
"run",
"fuchsia-pkg://fuchsia.com/dart_ffi_test_$mode#meta/fuchsia_ffi_test_component.cmx",
...arguments
], <String, String>{});
}
static String _run(String exec, List<String> args) {
var line = "$exec ${args.join(' ')}";
print("+ $line");
var result = Process.runSync(exec, args);
print(result.stdout);
print(result.stderr);
if (result.exitCode != 0) {
throw "$line failed";
}
return (result.stdout as String).trim();
}
}

View File

@ -11,7 +11,7 @@ import 'fuchsia.dart';
// Runs tests on a fuchsia emulator with chromium maintained test-scripts and
// CFv2 targets.
// TODO(#38752): Need implementation.
// TODO(#38752): Merge back to fuchsia.dart.
class FuchsiaEmulatorCFv2 extends FuchsiaEmulator {
static const String ffx = "./third_party/fuchsia/sdk/linux/tools/x64/ffx";
static const String testScriptRoot =
@ -94,6 +94,10 @@ class FuchsiaEmulatorCFv2 extends FuchsiaEmulator {
_tempDirectoryOf("out"),
"--test-name",
"fuchsia-pkg://fuchsia.com/${_testPackageName(mode)}#meta/$cmName",
"--test-realm",
// VmexResource not available in default hermetic realm
// TODO(38752): Setup a Dart test realm.
"/core/testing:system-tests",
"--logs-dir",
_tempDirectoryOf("logs"),
"--package-deps",
@ -104,7 +108,7 @@ class FuchsiaEmulatorCFv2 extends FuchsiaEmulator {
}
static String _testPackageName(String mode) {
return "dart_ffi_test_cfv2_$mode";
return "dart_ffi_test_$mode";
}
static String _testPackagePath(String buildDir, String mode) {

View File

@ -1690,8 +1690,7 @@
"runtime",
"create_sdk",
"fuchsia_test_package",
"fuchsia_ffi_test_package",
"fuchsia_ffi_test_package_cfv2"
"fuchsia_ffi_test_package"
]
},
{