Add Dart AOT integration test (flutter/engine#36460)
This commit is contained in:
@@ -298,6 +298,20 @@ jit_runner_package("dart_jit_product_runner") {
|
||||
product = true
|
||||
}
|
||||
|
||||
# "OOT" copy of the runner used by tests, to avoid conflicting with the runner
|
||||
# in the base fuchsia image.
|
||||
# TODO(fxbug.dev/106575): Fix this with subpackages.
|
||||
aot_runner_package("oot_dart_aot_runner") {
|
||||
product = false
|
||||
}
|
||||
|
||||
# "OOT" copy of the runner used by tests, to avoid conflicting with the runner
|
||||
# in the base fuchsia image.
|
||||
# TODO(fxbug.dev/106575): Fix this with subpackages.
|
||||
jit_runner_package("oot_dart_jit_runner") {
|
||||
product = false
|
||||
}
|
||||
|
||||
if (enable_unittests) {
|
||||
runner_sources("jit_runner_sources_for_test") {
|
||||
product = false
|
||||
|
||||
@@ -1,40 +1,3 @@
|
||||
# Dart Runner Tests
|
||||
|
||||
Contains tests for the Dart Runner and their corresponding utility code
|
||||
|
||||
### Running the Tests
|
||||
<!-- TODO(erkln): Replace steps once test runner script is updated to run Dart runner tests -->
|
||||
- The tests can be run using the Fuchsia emulator
|
||||
```
|
||||
fx set workstation_eng.qemu-x64
|
||||
ffx emu start --headless
|
||||
```
|
||||
- Start up the package server
|
||||
```
|
||||
fx serve
|
||||
```
|
||||
- Prepare the BUILD files
|
||||
```
|
||||
$ENGINE_DIR/flutter/tools/gn --fuchsia --no-lto
|
||||
```
|
||||
- Build the Fuchsia binary with the test directory as the target (ie. `flutter/shell/platform/fuchsia/dart_runner/tests/startup_integration_test`)
|
||||
```
|
||||
ninja -C $ENGINE_DIR/out/fuchsia_debug_x64 flutter/shell/platform/fuchsia/dart_runner/tests/startup_integration_test
|
||||
```
|
||||
- Deploy/publish test FAR files to Fuchsia
|
||||
```
|
||||
$FUCHSIA_DIR/.jiri_root/bin/fx pm publish -a -repo $FUCHSIA_DIR/$(cat $FUCHSIA_DIR/.fx-build-dir)/amber-files -f $ENGINE_DIR/out/fuchsia_debug_x64/dart-jit-runner-integration-test-0.far
|
||||
```
|
||||
|
||||
Note that some tests may have components that also need to be deployed/published (ie. `dart_jit_echo_server` also needs to be published for the Dart JIT integration test to run successfully)
|
||||
|
||||
```
|
||||
$FUCHSIA_DIR/.jiri_root/bin/fx pm publish -a -repo $FUCHSIA_DIR/$(cat $FUCHSIA_DIR/.fx-build-dir)/amber-files -f $ENGINE_DIR/out/fuchsia_debug_x64/gen/flutter/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/dart_jit_echo_server/dart_jit_echo_server.far
|
||||
```
|
||||
- Run the test
|
||||
```
|
||||
ffx test run "fuchsia-pkg://fuchsia.com/dart-jit-runner-integration-test#meta/dart-jit-runner-integration-test.cm"
|
||||
```
|
||||
|
||||
Notes:
|
||||
- To find the FAR files, `ls` into the output directory provided to the `ninja` command
|
||||
|
||||
@@ -6,5 +6,8 @@ import("//build/fuchsia/sdk.gni")
|
||||
|
||||
group("startup_integration_test") {
|
||||
testonly = true
|
||||
deps = [ "dart_jit_runner:tests" ]
|
||||
deps = [
|
||||
"dart_aot_runner:tests",
|
||||
"dart_jit_runner:tests",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
# Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import("//build/fuchsia/sdk.gni")
|
||||
|
||||
import("//flutter/tools/fuchsia/dart/dart_component.gni")
|
||||
import("//flutter/tools/fuchsia/fidl/fidl.gni")
|
||||
import("//flutter/tools/fuchsia/fuchsia_archive.gni")
|
||||
|
||||
group("tests") {
|
||||
testonly = true
|
||||
deps = [ ":dart-aot-runner-integration-test" ]
|
||||
}
|
||||
|
||||
executable("dart-aot-runner-integration-test-bin") {
|
||||
testonly = true
|
||||
|
||||
output_name = "dart-aot-runner-integration-test"
|
||||
|
||||
sources = [ "dart-aot-runner-integration-test.cc" ]
|
||||
|
||||
# This is needed for //third_party/googletest for linking zircon symbols.
|
||||
libs = [ "$fuchsia_sdk_path/arch/$target_cpu/sysroot/lib/libzircon.so" ]
|
||||
|
||||
deps = [
|
||||
"$fuchsia_sdk_root/fidl:fuchsia.logger",
|
||||
"$fuchsia_sdk_root/fidl:fuchsia.tracing.provider",
|
||||
"$fuchsia_sdk_root/pkg:async",
|
||||
"$fuchsia_sdk_root/pkg:async-loop-testing",
|
||||
"$fuchsia_sdk_root/pkg:fidl_cpp",
|
||||
"$fuchsia_sdk_root/pkg:sys_component_cpp_testing",
|
||||
"$fuchsia_sdk_root/pkg:zx",
|
||||
"//flutter/fml",
|
||||
"//flutter/shell/platform/fuchsia/dart_runner/tests/fidl/flutter.example.echo:echo",
|
||||
"//flutter/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_echo_server:aot_echo_package",
|
||||
"//third_party/googletest:gtest",
|
||||
"//third_party/googletest:gtest_main",
|
||||
]
|
||||
}
|
||||
|
||||
fuchsia_test_archive("dart-aot-runner-integration-test") {
|
||||
deps = [ ":dart-aot-runner-integration-test-bin" ]
|
||||
|
||||
binary = "$target_name"
|
||||
cml_file = rebase_path("meta/$target_name.cml")
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
# dart_aot_runner
|
||||
|
||||
Contains the integration test for the Dart AOT runner.
|
||||
|
||||
### Running Tests
|
||||
<!-- TODO(erkln): Replace steps once test runner script is updated to run Dart runner tests -->
|
||||
#### Setup emulator and PM serve
|
||||
```
|
||||
fx set workstation_eng.qemu-x64
|
||||
ffx emu start --headless
|
||||
|
||||
fx serve
|
||||
```
|
||||
|
||||
#### Prepare build files and build binary
|
||||
```
|
||||
$ENGINE_DIR/flutter/tools/gn --fuchsia --no-lto --runtime-mode=profile
|
||||
ninja -C $ENGINE_DIR/out/fuchsia_profile_x64 flutter/shell/platform/fuchsia fuchsia_tests
|
||||
```
|
||||
|
||||
#### Publish files to PM
|
||||
```
|
||||
$FUCHSIA_DIR/.jiri_root/bin/fx pm publish -a -repo $FUCHSIA_DIR/$(cat $FUCHSIA_DIR/.fx-build-dir)/amber-files -f $ENGINE_DIR/out/fuchsia_profile_x64/dart-aot-runner-integration-test-0.far
|
||||
|
||||
$FUCHSIA_DIR/.jiri_root/bin/fx pm publish -a -repo $FUCHSIA_DIR/$(cat $FUCHSIA_DIR/.fx-build-dir)/amber-files -f $ENGINE_DIR/out/fuchsia_profile_x64/oot_dart_aot_runner-0.far
|
||||
|
||||
$FUCHSIA_DIR/.jiri_root/bin/fx pm publish -a -repo $FUCHSIA_DIR/$(cat $FUCHSIA_DIR/.fx-build-dir)/amber-files -f $ENGINE_DIR/out/fuchsia_profile_x64/gen/flutter/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_echo_server/dart_aot_echo_server/dart_aot_echo_server.far
|
||||
```
|
||||
|
||||
#### Run test
|
||||
```
|
||||
ffx test run "fuchsia-pkg://fuchsia.com/dart-aot-runner-integration-test#meta/dart-aot-runner-integration-test.cm"
|
||||
```
|
||||
|
||||
## Notes
|
||||
The `profile` runtime should be used when running the `dart_aot_runner` integration test. Snapshots will fail to generate or generate incorrectly if the wrong runtime is used.
|
||||
@@ -0,0 +1,112 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// The generated C++ bindings for the Echo FIDL protocol
|
||||
#include <flutter/shell/platform/fuchsia/dart_runner/tests/fidl/flutter.example.echo/flutter/example/echo/cpp/fidl.h>
|
||||
|
||||
#include <fuchsia/tracing/provider/cpp/fidl.h>
|
||||
|
||||
#include <lib/async-loop/testing/cpp/real_loop.h>
|
||||
#include <lib/sys/component/cpp/testing/realm_builder.h>
|
||||
#include <lib/sys/component/cpp/testing/realm_builder_types.h>
|
||||
|
||||
#include "flutter/fml/logging.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace dart_aot_runner_testing::testing {
|
||||
namespace {
|
||||
|
||||
// Types imported for the realm_builder library
|
||||
using component_testing::ChildOptions;
|
||||
using component_testing::ChildRef;
|
||||
using component_testing::Directory;
|
||||
using component_testing::ParentRef;
|
||||
using component_testing::Protocol;
|
||||
using component_testing::RealmBuilder;
|
||||
using component_testing::RealmRoot;
|
||||
using component_testing::Route;
|
||||
|
||||
constexpr auto kDartRunnerEnvironment = "dart_runner_env";
|
||||
|
||||
constexpr auto kDartAotRunner = "dart_aot_runner";
|
||||
constexpr auto kDartAotRunnerRef = ChildRef{kDartAotRunner};
|
||||
constexpr auto kDartAotRunnerUrl =
|
||||
"fuchsia-pkg://fuchsia.com/oot_dart_aot_runner#meta/"
|
||||
"dart_aot_runner.cm";
|
||||
|
||||
constexpr auto kDartAotEchoServer = "dart_aot_echo_server";
|
||||
constexpr auto kDartAotEchoServerRef = ChildRef{kDartAotEchoServer};
|
||||
constexpr auto kDartAotEchoServerUrl =
|
||||
"fuchsia-pkg://fuchsia.com/dart_aot_echo_server#meta/"
|
||||
"dart_aot_echo_server.cm";
|
||||
|
||||
class RealmBuilderTest : public ::loop_fixture::RealLoop,
|
||||
public ::testing::Test {
|
||||
public:
|
||||
RealmBuilderTest() = default;
|
||||
};
|
||||
|
||||
TEST_F(RealmBuilderTest, DartRunnerStartsUp) {
|
||||
auto realm_builder = RealmBuilder::Create();
|
||||
// Add Dart AOT runner as a child of RealmBuilder
|
||||
realm_builder.AddChild(kDartAotRunner, kDartAotRunnerUrl);
|
||||
|
||||
// Add environment providing the Dart AOT runner
|
||||
fuchsia::component::decl::Environment dart_runner_environment;
|
||||
dart_runner_environment.set_name(kDartRunnerEnvironment);
|
||||
dart_runner_environment.set_extends(
|
||||
fuchsia::component::decl::EnvironmentExtends::REALM);
|
||||
dart_runner_environment.set_runners({});
|
||||
auto environment_runners = dart_runner_environment.mutable_runners();
|
||||
|
||||
fuchsia::component::decl::RunnerRegistration dart_aot_runner_reg;
|
||||
dart_aot_runner_reg.set_source(fuchsia::component::decl::Ref::WithChild(
|
||||
fuchsia::component::decl::ChildRef{.name = kDartAotRunner}));
|
||||
dart_aot_runner_reg.set_source_name(kDartAotRunner);
|
||||
dart_aot_runner_reg.set_target_name(kDartAotRunner);
|
||||
environment_runners->push_back(std::move(dart_aot_runner_reg));
|
||||
|
||||
auto realm_decl = realm_builder.GetRealmDecl();
|
||||
if (!realm_decl.has_environments()) {
|
||||
realm_decl.set_environments({});
|
||||
}
|
||||
auto realm_environments = realm_decl.mutable_environments();
|
||||
realm_environments->push_back(std::move(dart_runner_environment));
|
||||
realm_builder.ReplaceRealmDecl(std::move(realm_decl));
|
||||
|
||||
// Add Dart server component as a child of Realm Builder
|
||||
realm_builder.AddChild(kDartAotEchoServer, kDartAotEchoServerUrl,
|
||||
ChildOptions{.environment = kDartRunnerEnvironment});
|
||||
|
||||
// Route base capabilities to the Dart AOT runner
|
||||
realm_builder.AddRoute(
|
||||
Route{.capabilities = {Protocol{"fuchsia.logger.LogSink"},
|
||||
Protocol{"fuchsia.tracing.provider.Registry"},
|
||||
Protocol{"fuchsia.posix.socket.Provider"},
|
||||
Protocol{"fuchsia.intl.PropertyProvider"},
|
||||
Protocol{"fuchsia.vulkan.loader.Loader"},
|
||||
Directory{"config-data"}},
|
||||
.source = ParentRef(),
|
||||
.targets = {kDartAotRunnerRef, kDartAotEchoServerRef}});
|
||||
|
||||
// Route the Echo FIDL protocol, this allows the Dart echo server to
|
||||
// communicate with the Realm Builder
|
||||
realm_builder.AddRoute(
|
||||
Route{.capabilities = {Protocol{"flutter.example.echo.Echo"}},
|
||||
.source = kDartAotEchoServerRef,
|
||||
.targets = {ParentRef()}});
|
||||
|
||||
// Build the Realm with the provided child and protocols
|
||||
auto realm = realm_builder.Build(dispatcher());
|
||||
FML_LOG(INFO) << "Realm built: " << realm.GetChildName();
|
||||
// Connect to the Dart echo server
|
||||
auto echo = realm.ConnectSync<flutter::example::echo::Echo>();
|
||||
fidl::StringPtr response;
|
||||
// Attempt to ping the Dart echo server for a response
|
||||
echo->EchoString("hello", &response);
|
||||
ASSERT_EQ(response, "hello");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace dart_aot_runner_testing::testing
|
||||
@@ -0,0 +1,40 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
{
|
||||
include: [
|
||||
"gtest_runner.shard.cml",
|
||||
"sys/component/realm_builder_absolute.shard.cml",
|
||||
|
||||
// This test needs both the vulkan facet and the hermetic-tier-2 facet,
|
||||
// so we are forced to make it a system test.
|
||||
"sys/testing/system-test.shard.cml",
|
||||
],
|
||||
program: {
|
||||
binary: "bin/app",
|
||||
},
|
||||
offer: [
|
||||
{
|
||||
// Offer capabilities needed by components in this test realm.
|
||||
// Keep it minimal, describe only what's actually needed.
|
||||
protocol: [
|
||||
"fuchsia.logger.LogSink",
|
||||
"fuchsia.sysmem.Allocator",
|
||||
"fuchsia.tracing.provider.Registry",
|
||||
"fuchsia.vulkan.loader.Loader",
|
||||
"fuchsia.posix.socket.Provider",
|
||||
"fuchsia.intl.PropertyProvider",
|
||||
],
|
||||
from: "parent",
|
||||
to: "#realm_builder",
|
||||
},
|
||||
{
|
||||
directory: "pkg",
|
||||
subdir: "config",
|
||||
as: "config-data",
|
||||
from: "framework",
|
||||
to: "#realm_builder",
|
||||
},
|
||||
],
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
{
|
||||
program: {
|
||||
runner: "gtest_runner",
|
||||
},
|
||||
capabilities: [
|
||||
{ protocol: "fuchsia.test.Suite" },
|
||||
],
|
||||
expose: [
|
||||
{
|
||||
protocol: "fuchsia.test.Suite",
|
||||
from: "self",
|
||||
},
|
||||
],
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
# Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import("//build/fuchsia/sdk.gni")
|
||||
|
||||
import("//flutter/tools/fuchsia/dart/dart_component.gni")
|
||||
import("//flutter/tools/fuchsia/dart/dart_library.gni")
|
||||
import("//flutter/tools/fuchsia/gn-sdk/package.gni")
|
||||
|
||||
dart_library("lib") {
|
||||
testonly = true
|
||||
package_name = "dart_echo_server"
|
||||
null_safe = true
|
||||
|
||||
source_dir = "."
|
||||
sources = [ "main.dart" ]
|
||||
|
||||
deps = [
|
||||
"//flutter/shell/platform/fuchsia/dart_runner/tests/fidl/flutter.example.echo:echo",
|
||||
"//flutter/tools/fuchsia/dart:fidl",
|
||||
"//flutter/tools/fuchsia/dart:fuchsia_services",
|
||||
"//flutter/tools/fuchsia/fidl:fuchsia.logger",
|
||||
"//flutter/tools/fuchsia/fidl:fuchsia.test",
|
||||
]
|
||||
}
|
||||
|
||||
# Dart component that serves the test Echo FIDL protocol, built using the Dart AOT runner
|
||||
dart_component("aot_component") {
|
||||
testonly = true
|
||||
null_safe = true
|
||||
|
||||
main_package = "dart_echo_server"
|
||||
manifest = "meta/dart-aot-echo-server.cml"
|
||||
component_name = "dart_aot_echo_server"
|
||||
|
||||
deps = [ ":lib" ]
|
||||
}
|
||||
|
||||
# Dart component that serves the test Echo FIDL protocol, built using the Dart AOT runner
|
||||
dart_component("jit_component") {
|
||||
testonly = true
|
||||
null_safe = true
|
||||
|
||||
main_package = "dart_echo_server"
|
||||
manifest = "meta/dart-jit-echo-server.cml"
|
||||
component_name = "dart_jit_echo_server"
|
||||
|
||||
deps = [ ":lib" ]
|
||||
}
|
||||
|
||||
fuchsia_package("aot_echo_package") {
|
||||
testonly = true
|
||||
|
||||
package_name = "dart_aot_echo_server"
|
||||
deps = [
|
||||
":aot_component",
|
||||
|
||||
# "OOT" copy of the runner used by tests, to avoid conflicting with the
|
||||
# runners in the base fuchsia image.
|
||||
# TODO(fxbug.dev/106575): Fix this with subpackages.
|
||||
"//flutter/shell/platform/fuchsia/dart_runner:oot_dart_aot_runner",
|
||||
]
|
||||
}
|
||||
|
||||
fuchsia_package("jit_echo_package") {
|
||||
testonly = true
|
||||
|
||||
package_name = "dart_jit_echo_server"
|
||||
deps = [
|
||||
":jit_component",
|
||||
|
||||
# "OOT" copy of the runner used by tests, to avoid conflicting with the
|
||||
# runners in the base fuchsia image.
|
||||
# TODO(fxbug.dev/106575): Fix this with subpackages.
|
||||
"//flutter/shell/platform/fuchsia/dart_runner:oot_dart_jit_runner",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
# dart_echo_server
|
||||
|
||||
Contains the Echo servers for the integration tests. There are currently two outputs:
|
||||
- `dart-aot-echo-server`
|
||||
- `dart-jit-echo-server`
|
||||
|
||||
The outputs run with their respective Dart runners and are consumed by their respective integration test.
|
||||
@@ -0,0 +1,21 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
{
|
||||
include: [ "syslog/client.shard.cml" ],
|
||||
program: {
|
||||
data: "data/dart-aot-echo-server",
|
||||
runner: "dart_aot_runner",
|
||||
},
|
||||
// Capabilities provided by this component.
|
||||
capabilities: [
|
||||
{ protocol: "flutter.example.echo.Echo" },
|
||||
],
|
||||
expose: [
|
||||
{
|
||||
protocol: "flutter.example.echo.Echo",
|
||||
from: "self",
|
||||
},
|
||||
],
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
{
|
||||
include: [ "syslog/client.shard.cml" ],
|
||||
program: {
|
||||
data: "data/dart-jit-echo-server",
|
||||
runner: "dart_jit_runner",
|
||||
},
|
||||
// Capabilities provided by this component.
|
||||
@@ -31,19 +31,16 @@ executable("dart-jit-runner-integration-test-bin") {
|
||||
"$fuchsia_sdk_root/pkg:fidl_cpp",
|
||||
"$fuchsia_sdk_root/pkg:sys_component_cpp_testing",
|
||||
"$fuchsia_sdk_root/pkg:zx",
|
||||
"dart_jit_echo_server:package",
|
||||
"//flutter/fml",
|
||||
"//flutter/shell/platform/fuchsia/dart_runner/tests/fidl/flutter.example.echo:echo",
|
||||
"//flutter/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_echo_server:jit_echo_package",
|
||||
"//third_party/googletest:gtest",
|
||||
"//third_party/googletest:gtest_main",
|
||||
]
|
||||
}
|
||||
|
||||
fuchsia_test_archive("dart-jit-runner-integration-test") {
|
||||
deps = [
|
||||
":dart-jit-runner-integration-test-bin",
|
||||
"dart_jit_echo_server:package",
|
||||
]
|
||||
deps = [ ":dart-jit-runner-integration-test-bin" ]
|
||||
|
||||
binary = "$target_name"
|
||||
cml_file = rebase_path("meta/$target_name.cml")
|
||||
|
||||
@@ -1,3 +1,36 @@
|
||||
# dart_jit_runner
|
||||
|
||||
Contains the integration test for the Dart JIT runner. The Dart Echo server is launched with a JIT runner.
|
||||
Contains the integration test for the Dart JIT runner.
|
||||
|
||||
### Running Tests
|
||||
<!-- TODO(erkln): Replace steps once test runner script is updated to run Dart runner tests -->
|
||||
#### Setup emulator and PM serve
|
||||
```
|
||||
fx set workstation_eng.qemu-x64
|
||||
ffx emu start --headless
|
||||
|
||||
fx serve
|
||||
```
|
||||
|
||||
#### Prepare build files and build binary
|
||||
```
|
||||
$ENGINE_DIR/flutter/tools/gn --fuchsia --no-lto
|
||||
ninja -C $ENGINE_DIR/out/fuchsia_debug_x64 flutter/shell/platform/fuchsia fuchsia_tests
|
||||
```
|
||||
|
||||
#### Publish files to PM
|
||||
```
|
||||
$FUCHSIA_DIR/.jiri_root/bin/fx pm publish -a -repo $FUCHSIA_DIR/$(cat $FUCHSIA_DIR/.fx-build-dir)/amber-files -f $ENGINE_DIR/out/fuchsia_debug_x64/dart-jit-runner-integration-test-0.far
|
||||
|
||||
$FUCHSIA_DIR/.jiri_root/bin/fx pm publish -a -repo $FUCHSIA_DIR/$(cat $FUCHSIA_DIR/.fx-build-dir)/amber-files -f $ENGINE_DIR/out/fuchsia_debug_x64/oot_dart_jit_runner-0.far
|
||||
|
||||
$FUCHSIA_DIR/.jiri_root/bin/fx pm publish -a -repo $FUCHSIA_DIR/$(cat $FUCHSIA_DIR/.fx-build-dir)/amber-files -f $ENGINE_DIR/out/fuchsia_debug_x64/gen/flutter/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_echo_server/dart_jit_echo_server/dart_jit_echo_server.far
|
||||
```
|
||||
|
||||
#### Run test
|
||||
```
|
||||
ffx test run "fuchsia-pkg://fuchsia.com/dart-jit-runner-integration-test#meta/dart-jit-runner-integration-test.cm"
|
||||
```
|
||||
|
||||
## Notes
|
||||
The `debug` runtime should be used when running the `dart_jit_runner` integration test. Snapshots will fail to generate or generate incorrectly if the wrong runtime is used.
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
// The generated C++ bindings for the Echo FIDL protocol
|
||||
#include <flutter/shell/platform/fuchsia/dart_runner/tests/fidl/flutter.example.echo/flutter/example/echo/cpp/fidl.h>
|
||||
|
||||
#include <fuchsia/tracing/provider/cpp/fidl.h>
|
||||
|
||||
#include <lib/async-loop/testing/cpp/real_loop.h>
|
||||
#include <lib/sys/component/cpp/testing/realm_builder.h>
|
||||
#include <lib/sys/component/cpp/testing/realm_builder_types.h>
|
||||
@@ -15,13 +17,30 @@
|
||||
namespace dart_jit_runner_testing::testing {
|
||||
namespace {
|
||||
|
||||
// Types imported for the realm_builder library
|
||||
using component_testing::ChildOptions;
|
||||
using component_testing::ChildRef;
|
||||
using component_testing::Directory;
|
||||
using component_testing::ParentRef;
|
||||
using component_testing::Protocol;
|
||||
using component_testing::RealmBuilder;
|
||||
using component_testing::RealmRoot;
|
||||
using component_testing::Route;
|
||||
|
||||
constexpr auto kDartRunnerEnvironment = "dart_runner_env";
|
||||
|
||||
constexpr auto kDartJitRunner = "dart_jit_runner";
|
||||
constexpr auto kDartJitRunnerRef = ChildRef{kDartJitRunner};
|
||||
constexpr auto kDartJitRunnerUrl =
|
||||
"fuchsia-pkg://fuchsia.com/oot_dart_jit_runner#meta/"
|
||||
"dart_jit_runner.cm";
|
||||
|
||||
constexpr auto kDartJitEchoServer = "dart_jit_echo_server";
|
||||
constexpr auto kDartJitEchoServerRef = ChildRef{kDartJitEchoServer};
|
||||
constexpr auto kDartJitEchoServerUrl =
|
||||
"fuchsia-pkg://fuchsia.com/dart_jit_echo_server#meta/"
|
||||
"dart_jit_echo_server.cm";
|
||||
|
||||
class RealmBuilderTest : public ::loop_fixture::RealLoop,
|
||||
public ::testing::Test {
|
||||
public:
|
||||
@@ -30,20 +49,52 @@ class RealmBuilderTest : public ::loop_fixture::RealLoop,
|
||||
|
||||
TEST_F(RealmBuilderTest, DartRunnerStartsUp) {
|
||||
auto realm_builder = RealmBuilder::Create();
|
||||
// Add Dart JIT runner as a child of RealmBuilder
|
||||
realm_builder.AddChild(kDartJitRunner, kDartJitRunnerUrl);
|
||||
|
||||
// Add environment providing the Dart JIT runner
|
||||
fuchsia::component::decl::Environment dart_runner_environment;
|
||||
dart_runner_environment.set_name(kDartRunnerEnvironment);
|
||||
dart_runner_environment.set_extends(
|
||||
fuchsia::component::decl::EnvironmentExtends::REALM);
|
||||
dart_runner_environment.set_runners({});
|
||||
auto environment_runners = dart_runner_environment.mutable_runners();
|
||||
|
||||
fuchsia::component::decl::RunnerRegistration dart_jit_runner_reg;
|
||||
dart_jit_runner_reg.set_source(fuchsia::component::decl::Ref::WithChild(
|
||||
fuchsia::component::decl::ChildRef{.name = kDartJitRunner}));
|
||||
dart_jit_runner_reg.set_source_name(kDartJitRunner);
|
||||
dart_jit_runner_reg.set_target_name(kDartJitRunner);
|
||||
environment_runners->push_back(std::move(dart_jit_runner_reg));
|
||||
auto realm_decl = realm_builder.GetRealmDecl();
|
||||
if (!realm_decl.has_environments()) {
|
||||
realm_decl.set_environments({});
|
||||
}
|
||||
auto realm_environments = realm_decl.mutable_environments();
|
||||
realm_environments->push_back(std::move(dart_runner_environment));
|
||||
realm_builder.ReplaceRealmDecl(std::move(realm_decl));
|
||||
|
||||
// Add Dart server component as a child of Realm Builder
|
||||
realm_builder.AddChild("hello_world",
|
||||
"fuchsia-pkg://fuchsia.com/dart_jit_echo_server#meta/"
|
||||
"dart_jit_echo_server.cm");
|
||||
realm_builder.AddChild(kDartJitEchoServer, kDartJitEchoServerUrl,
|
||||
ChildOptions{.environment = kDartRunnerEnvironment});
|
||||
|
||||
// Route base capabilities to the Dart JIT runner
|
||||
realm_builder.AddRoute(
|
||||
Route{.capabilities = {Protocol{"fuchsia.logger.LogSink"}},
|
||||
Route{.capabilities = {Protocol{"fuchsia.logger.LogSink"},
|
||||
Protocol{"fuchsia.tracing.provider.Registry"},
|
||||
Protocol{"fuchsia.posix.socket.Provider"},
|
||||
Protocol{"fuchsia.intl.PropertyProvider"},
|
||||
Directory{"config-data"}},
|
||||
.source = ParentRef(),
|
||||
.targets = {ChildRef{"hello_world"}}});
|
||||
.targets = {kDartJitRunnerRef, kDartJitEchoServerRef}});
|
||||
|
||||
// Route the Echo FIDL protocol, this allows the Dart echo server to
|
||||
// communicate with the Realm Builder
|
||||
realm_builder.AddRoute(
|
||||
Route{.capabilities = {Protocol{"flutter.example.echo.Echo"}},
|
||||
.source = ChildRef{"hello_world"},
|
||||
.source = kDartJitEchoServerRef,
|
||||
.targets = {ParentRef()}});
|
||||
|
||||
// Build the Realm with the provided child and protocols
|
||||
auto realm = realm_builder.Build(dispatcher());
|
||||
FML_LOG(INFO) << "Realm built: " << realm.GetChildName();
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
# Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import("//build/fuchsia/sdk.gni")
|
||||
|
||||
import("//flutter/tools/fuchsia/dart/dart_component.gni")
|
||||
import("//flutter/tools/fuchsia/dart/dart_library.gni")
|
||||
import("//flutter/tools/fuchsia/gn-sdk/package.gni")
|
||||
|
||||
dart_library("lib") {
|
||||
testonly = true
|
||||
package_name = "dart_jit_echo_server"
|
||||
null_safe = true
|
||||
|
||||
source_dir = "."
|
||||
sources = [ "main.dart" ]
|
||||
|
||||
deps = [
|
||||
"//flutter/shell/platform/fuchsia/dart_runner/tests/fidl/flutter.example.echo:echo",
|
||||
"//flutter/tools/fuchsia/dart:fidl",
|
||||
"//flutter/tools/fuchsia/dart:fuchsia_services",
|
||||
"//flutter/tools/fuchsia/fidl:fuchsia.logger",
|
||||
"//flutter/tools/fuchsia/fidl:fuchsia.test",
|
||||
]
|
||||
}
|
||||
|
||||
# Dart component that serves the test Echo FIDL protocol, built using the Dart JIT runner
|
||||
dart_component("component") {
|
||||
testonly = true
|
||||
null_safe = true
|
||||
|
||||
manifest = "meta/dart-jit-echo-server.cml"
|
||||
main_package = "dart_jit_echo_server"
|
||||
component_name = "dart_jit_echo_server"
|
||||
|
||||
deps = [ ":lib" ]
|
||||
}
|
||||
|
||||
fuchsia_package("package") {
|
||||
testonly = true
|
||||
|
||||
package_name = "dart_jit_echo_server"
|
||||
deps = [ ":component" ]
|
||||
}
|
||||
@@ -23,9 +23,18 @@
|
||||
"fuchsia.sysmem.Allocator",
|
||||
"fuchsia.tracing.provider.Registry",
|
||||
"fuchsia.vulkan.loader.Loader",
|
||||
"fuchsia.posix.socket.Provider",
|
||||
"fuchsia.intl.PropertyProvider",
|
||||
],
|
||||
from: "parent",
|
||||
to: "#realm_builder",
|
||||
},
|
||||
{
|
||||
directory: "pkg",
|
||||
subdir: "config",
|
||||
as: "config-data",
|
||||
from: "framework",
|
||||
to: "#realm_builder",
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
@@ -39,6 +39,12 @@
|
||||
package: dart_utils_tests-0.far
|
||||
- test_command: run-test-suite fuchsia-pkg://fuchsia.com/dart-jit-runner-integration-test#meta/dart-jit-runner-integration-test.cm
|
||||
packages:
|
||||
- oot_dart_jit_runner-0.far
|
||||
- dart-jit-runner-integration-test-0.far
|
||||
- dart_jit_runner-0.far
|
||||
- gen/flutter/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/dart_jit_echo_server/dart_jit_echo_server.far
|
||||
- gen/flutter/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_echo_server/dart_jit_echo_server/dart_jit_echo_server.far
|
||||
- test_command: run-test-suite fuchsia-pkg://fuchsia.com/dart-aot-runner-integration-test#meta/dart-aot-runner-integration-test.cm
|
||||
run_with_dart_aot: 'true'
|
||||
packages:
|
||||
- oot_dart_aot_runner-0.far
|
||||
- dart-aot-runner-integration-test-0.far
|
||||
- gen/flutter/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_echo_server/dart_aot_echo_server/dart_aot_echo_server.far
|
||||
|
||||
Reference in New Issue
Block a user