From 3d292ad13cad45f4f18c1e5594191329404b3148 Mon Sep 17 00:00:00 2001 From: Erik Date: Mon, 26 Sep 2022 20:47:37 +0000 Subject: [PATCH 1/6] Add Dart JIT runner integration test --- DEPS | 2 +- shell/platform/fuchsia/dart_runner/BUILD.gn | 5 +- .../fuchsia/dart_runner/tests/README.md | 40 +++++++++++++ .../tests/fidl/flutter.example.echo/BUILD.gn | 12 ++++ .../tests/fidl/flutter.example.echo/README.md | 3 + .../tests/fidl/flutter.example.echo/echo.fidl | 17 ++++++ .../tests/fidl/flutter.example.echo/meta.json | 9 +++ .../tests/startup_integration_test/BUILD.gn | 6 +- .../dart_jit_runner/BUILD.gn | 50 +++++++++++++++++ .../dart_jit_runner/README.md | 3 + .../dart-jit-runner-integration-test.cc | 56 +++++++++++++++++++ .../dart_jit_echo_server/BUILD.gn | 45 +++++++++++++++ .../dart_jit_echo_server/main.dart | 48 ++++++++++++++++ .../meta/dart-jit-echo-server.cml | 20 +++++++ .../meta/dart-jit-runner-integration-test.cml | 31 ++++++++++ .../meta/gtest_runner.shard.cml | 18 ++++++ .../hello_world/BUILD.gn | 30 ---------- .../hello_world/main.dart | 7 --- .../hello_world/meta/hello-world.cml | 6 -- testing/fuchsia/test_suites.yaml | 4 ++ tools/fuchsia/dart/fidl_dart.gni | 6 +- tools/fuchsia/fidl/fidl.gni | 32 +++++++---- 22 files changed, 391 insertions(+), 59 deletions(-) create mode 100644 shell/platform/fuchsia/dart_runner/tests/README.md create mode 100644 shell/platform/fuchsia/dart_runner/tests/fidl/flutter.example.echo/BUILD.gn create mode 100644 shell/platform/fuchsia/dart_runner/tests/fidl/flutter.example.echo/README.md create mode 100644 shell/platform/fuchsia/dart_runner/tests/fidl/flutter.example.echo/echo.fidl create mode 100644 shell/platform/fuchsia/dart_runner/tests/fidl/flutter.example.echo/meta.json create mode 100644 shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/BUILD.gn create mode 100644 shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/README.md create mode 100644 shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart-jit-runner-integration-test.cc create mode 100644 shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/BUILD.gn create mode 100644 shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/main.dart create mode 100644 shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/meta/dart-jit-echo-server.cml create mode 100644 shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/dart-jit-runner-integration-test.cml create mode 100644 shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/gtest_runner.shard.cml delete mode 100644 shell/platform/fuchsia/dart_runner/tests/startup_integration_test/hello_world/BUILD.gn delete mode 100644 shell/platform/fuchsia/dart_runner/tests/startup_integration_test/hello_world/main.dart delete mode 100644 shell/platform/fuchsia/dart_runner/tests/startup_integration_test/hello_world/meta/hello-world.cml diff --git a/DEPS b/DEPS index 0503380fd33e3..e6faf59eae39d 100644 --- a/DEPS +++ b/DEPS @@ -102,7 +102,7 @@ allowed_hosts = [ ] deps = { - 'src': 'https://github.com/flutter/buildroot.git' + '@' + '25e5fd0200ff0bbf4761f3e73cab67a16e928955', + 'src': 'https://github.com/flutter/buildroot.git' + '@' + 'c9c2b77c9520903741ccda2fe12f773408a76c94', # Fuchsia compatibility # diff --git a/shell/platform/fuchsia/dart_runner/BUILD.gn b/shell/platform/fuchsia/dart_runner/BUILD.gn index 7aa07ac28ec3c..a1bfe34686170 100644 --- a/shell/platform/fuchsia/dart_runner/BUILD.gn +++ b/shell/platform/fuchsia/dart_runner/BUILD.gn @@ -337,6 +337,9 @@ if (enable_unittests) { group("tests") { testonly = true - deps = [ ":dart_runner_tests" ] + deps = [ + ":dart_runner_tests", + "tests/startup_integration_test", + ] } } diff --git a/shell/platform/fuchsia/dart_runner/tests/README.md b/shell/platform/fuchsia/dart_runner/tests/README.md new file mode 100644 index 0000000000000..0bfb005e5fc6c --- /dev/null +++ b/shell/platform/fuchsia/dart_runner/tests/README.md @@ -0,0 +1,40 @@ +# Dart Runner Tests + +Contains tests for the Dart Runner and their corresponding utility code + +### Running the 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 diff --git a/shell/platform/fuchsia/dart_runner/tests/fidl/flutter.example.echo/BUILD.gn b/shell/platform/fuchsia/dart_runner/tests/fidl/flutter.example.echo/BUILD.gn new file mode 100644 index 0000000000000..48efcd4d4c5a9 --- /dev/null +++ b/shell/platform/fuchsia/dart_runner/tests/fidl/flutter.example.echo/BUILD.gn @@ -0,0 +1,12 @@ +# Copyright 2019 The Fuchsia 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/fidl/fidl.gni") + +fidl("echo") { + name = "flutter.example.echo" + meta = "//flutter/shell/platform/fuchsia/dart_runner/tests/fidl/flutter.example.echo/meta.json" + sources = [ "echo.fidl" ] +} diff --git a/shell/platform/fuchsia/dart_runner/tests/fidl/flutter.example.echo/README.md b/shell/platform/fuchsia/dart_runner/tests/fidl/flutter.example.echo/README.md new file mode 100644 index 0000000000000..149853e98f9dd --- /dev/null +++ b/shell/platform/fuchsia/dart_runner/tests/fidl/flutter.example.echo/README.md @@ -0,0 +1,3 @@ +# Echo FIDL + +This FIDL protocol allows the Dart integration tests to communicate with a Dart Echo server (a test Dart component that echoes back a request). diff --git a/shell/platform/fuchsia/dart_runner/tests/fidl/flutter.example.echo/echo.fidl b/shell/platform/fuchsia/dart_runner/tests/fidl/flutter.example.echo/echo.fidl new file mode 100644 index 0000000000000..14624e6be78f4 --- /dev/null +++ b/shell/platform/fuchsia/dart_runner/tests/fidl/flutter.example.echo/echo.fidl @@ -0,0 +1,17 @@ +// Copyright 2019 The Fuchsia Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library flutter.example.echo; + +const MAX_STRING_LENGTH uint64 = 32; + +@discoverable +protocol Echo { + /// Returns the input. + EchoString(struct { + value string:; + }) -> (struct { + response string:; + }); +}; diff --git a/shell/platform/fuchsia/dart_runner/tests/fidl/flutter.example.echo/meta.json b/shell/platform/fuchsia/dart_runner/tests/fidl/flutter.example.echo/meta.json new file mode 100644 index 0000000000000..379328987faf7 --- /dev/null +++ b/shell/platform/fuchsia/dart_runner/tests/fidl/flutter.example.echo/meta.json @@ -0,0 +1,9 @@ +{ + "deps": [], + "name": "flutter.example.echo", + "root": "fidl/flutter.example.echo", + "sources": [ + "../../../flutter/shell/platform/fuchsia/dart_runner/tests/fidl/flutter.example.echo/echo.fidl" + ], + "type": "fidl_library" +} \ No newline at end of file diff --git a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/BUILD.gn b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/BUILD.gn index fffb456decca3..3ce01796bbc88 100644 --- a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/BUILD.gn +++ b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/BUILD.gn @@ -2,7 +2,9 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -group("tests") { +import("//build/fuchsia/sdk.gni") + +group("startup_integration_test") { testonly = true - deps = [ "hello_world:hello_world_dart" ] + deps = [ "dart_jit_runner:tests" ] } diff --git a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/BUILD.gn b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/BUILD.gn new file mode 100644 index 0000000000000..d918de9415f4c --- /dev/null +++ b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/BUILD.gn @@ -0,0 +1,50 @@ +# 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-jit-runner-integration-test" ] +} + +executable("dart-jit-runner-integration-test-bin") { + testonly = true + + output_name = "dart-jit-runner-integration-test" + + sources = [ "dart-jit-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", + "dart_jit_echo_server:package", + "//flutter/fml", + "//flutter/shell/platform/fuchsia/dart_runner/tests/fidl/flutter.example.echo:echo", + "//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", + ] + + binary = "$target_name" + cml_file = rebase_path("meta/$target_name.cml") +} diff --git a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/README.md b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/README.md new file mode 100644 index 0000000000000..be30e687b3fd6 --- /dev/null +++ b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/README.md @@ -0,0 +1,3 @@ +# dart_jit_runner + +Contains the integration test for the Dart JIT runner. The Dart Echo server is launched with a JIT runner. diff --git a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart-jit-runner-integration-test.cc b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart-jit-runner-integration-test.cc new file mode 100644 index 0000000000000..b897f2546f2d5 --- /dev/null +++ b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart-jit-runner-integration-test.cc @@ -0,0 +1,56 @@ +// Copyright 2022 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 + +#include +#include +#include + +#include "flutter/fml/logging.h" +#include "gtest/gtest.h" + +using namespace component_testing; + +namespace dart_jit_runner::testing { +namespace { + +using component_testing::RealmRoot; + +class RealmBuilderTest : public ::loop_fixture::RealLoop, + public ::testing::Test { + public: + RealmBuilderTest() = default; +}; + +TEST_F(RealmBuilderTest, DartRunnerStartsUp) { + auto realm_builder = RealmBuilder::Create(); + // 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.AddRoute( + Route{.capabilities = {Protocol{"fuchsia.logger.LogSink"}}, + .source = ParentRef(), + .targets = {ChildRef{"hello_world"}}}); + // 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"}, + .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(); + fidl::StringPtr response; + // Attempt to ping the Dart echo server for a response + echo->EchoString("hello", &response); + ASSERT_EQ(response, "hello"); +} + +} // namespace +} // namespace dart_jit_runner::testing diff --git a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/BUILD.gn b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/BUILD.gn new file mode 100644 index 0000000000000..a203bb671661f --- /dev/null +++ b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/BUILD.gn @@ -0,0 +1,45 @@ +# 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 launches a simple "Hello World" application using JIT +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" ] +} diff --git a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/main.dart b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/main.dart new file mode 100644 index 0000000000000..b1bb3b062c5ba --- /dev/null +++ b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/main.dart @@ -0,0 +1,48 @@ +// Copyright 2016 The Fuchsia 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 server uses async code to be able to listen for incoming Echo requests and connections +// asynchronously. +import 'dart:async'; + +// The fidl package contains general utility code for using FIDL in Dart. +import 'package:fidl/fidl.dart' as fidl; +// The generated Dart bindings for the Echo FIDL protocol +import 'package:fidl_flutter_example_echo/fidl_async.dart' as fidl_echo; +// The fuchsia_services package interfaces with the Fuchsia system. In particular, it is used +// to expose a service to other components +import 'package:fuchsia_services/services.dart' as sys; + +// Create an implementation for the Echo protocol by overriding the +// fidl_echo.Echo class from the bindings +class _EchoImpl extends fidl_echo.Echo { + // The stream controller for the stream of OnString events + final _onStringStreamController = StreamController(); + + // Implementation of EchoString that just echoes the request value back + @override + Future echoString(String? value) async { + return value; + } +} + +void main(List args) { + // Create the component context. We should not serve outgoing before we add + // the services. + final context = sys.ComponentContext.create(); + // Each FIDL protocol class has an accompanying Binding class, which takes + // an implementation of the protocol and a channel, and dispatches incoming + // requests on the channel to the protocol implementation. + final binding = fidl_echo.EchoBinding(); + // Serves the implementation by passing it a handler for incoming requests, + // and the name of the protocol it is providing. + final echo = _EchoImpl(); + // Add the outgoing service, and then serve the outgoing directory. + context.outgoing + ..addPublicService( + (fidl.InterfaceRequest serverEnd) => + binding.bind(echo, serverEnd), + fidl_echo.Echo.$serviceName) + ..serveFromStartupInfo(); +} diff --git a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/meta/dart-jit-echo-server.cml b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/meta/dart-jit-echo-server.cml new file mode 100644 index 0000000000000..bdfc9f21f15c4 --- /dev/null +++ b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/meta/dart-jit-echo-server.cml @@ -0,0 +1,20 @@ +// Copyright 2022 The Fuchsia 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: { + runner: "dart_jit_runner", + }, + // Capabilities provided by this component. + capabilities: [ + { protocol: "flutter.example.echo.Echo" }, + ], + expose: [ + { + protocol: "flutter.example.echo.Echo", + from: "self", + }, + ], +} diff --git a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/dart-jit-runner-integration-test.cml b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/dart-jit-runner-integration-test.cml new file mode 100644 index 0000000000000..cb61f60fc82ba --- /dev/null +++ b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/dart-jit-runner-integration-test.cml @@ -0,0 +1,31 @@ +// Copyright 2022 The Fuchsia 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", + ], + from: "parent", + to: "#realm_builder", + }, + ], +} \ No newline at end of file diff --git a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/gtest_runner.shard.cml b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/gtest_runner.shard.cml new file mode 100644 index 0000000000000..f47451554f09f --- /dev/null +++ b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/gtest_runner.shard.cml @@ -0,0 +1,18 @@ +// Copyright 2022 The Fuchsia 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", + }, + ], +} \ No newline at end of file diff --git a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/hello_world/BUILD.gn b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/hello_world/BUILD.gn deleted file mode 100644 index 42fcd964a7053..0000000000000 --- a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/hello_world/BUILD.gn +++ /dev/null @@ -1,30 +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("//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 = "hello_world" - language_version = "2.12" - source_dir = "." - sources = [ "main.dart" ] - deps = [] -} - -dart_component("hello-world-dart-component") { - testonly = true - manifest = "meta/hello-world.cml" - main_package = "hello_world" - component_name = "hello_world" - deps = [ ":lib" ] -} - -fuchsia_component("hello_world_dart") { - testonly = true - deps = [ ":hello-world-dart-component" ] - manifest = "meta/hello-world.cml" -} diff --git a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/hello_world/main.dart b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/hello_world/main.dart deleted file mode 100644 index a4f6425cf13b1..0000000000000 --- a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/hello_world/main.dart +++ /dev/null @@ -1,7 +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. - -void main() { - print("Hello, World!"); -} diff --git a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/hello_world/meta/hello-world.cml b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/hello_world/meta/hello-world.cml deleted file mode 100644 index eb20c2dc53cd5..0000000000000 --- a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/hello_world/meta/hello-world.cml +++ /dev/null @@ -1,6 +0,0 @@ -{ - program: { - data: "data/hello_world", - runner: "dart_jit_runner" - }, -} diff --git a/testing/fuchsia/test_suites.yaml b/testing/fuchsia/test_suites.yaml index 86630bdb73450..9206bd35cdd77 100644 --- a/testing/fuchsia/test_suites.yaml +++ b/testing/fuchsia/test_suites.yaml @@ -39,3 +39,7 @@ package: embedder_tests-0.far - test_command: run-test-suite fuchsia-pkg://fuchsia.com/dart_utils_tests#meta/dart_utils_tests.cm 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: + - dart-jit-runner-integration-test-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 diff --git a/tools/fuchsia/dart/fidl_dart.gni b/tools/fuchsia/dart/fidl_dart.gni index 3a7948f0d5ab6..06f0d0bb551fe 100644 --- a/tools/fuchsia/dart/fidl_dart.gni +++ b/tools/fuchsia/dart/fidl_dart.gni @@ -19,7 +19,11 @@ template("fidl_dart") { assert(current_toolchain == dart_toolchain, "This template can only be used in the $dart_toolchain toolchain.") - not_needed(invoker, [ "sources" ]) + not_needed(invoker, + [ + "meta", + "sources", + ]) main_target_name = target_name generation_target_name = "${target_name}_dart_generate" diff --git a/tools/fuchsia/fidl/fidl.gni b/tools/fuchsia/fidl/fidl.gni index 4a313b1223e6f..fb1e396abfa05 100644 --- a/tools/fuchsia/fidl/fidl.gni +++ b/tools/fuchsia/fidl/fidl.gni @@ -24,23 +24,33 @@ template("fidl") { "All FIDL dependencies are inherently " + "public, use 'public_deps' instead of 'deps'.") - deps = [] - if (current_toolchain == dart_toolchain) { import("//flutter/tools/fuchsia/dart/fidl_dart.gni") + not_needed(invoker, [ "meta" ]) + fidl_dart(target_name) { forward_variables_from(invoker, "*") } - } else { - if (current_toolchain == fidl_toolchain) { - import("//flutter/tools/fuchsia/fidl/fidl_library.gni") - - fidl_library(target_name) { - forward_variables_from(invoker, "*") - } - } else { - not_needed("*") + } else if (current_toolchain == fidl_toolchain) { + import("//flutter/tools/fuchsia/fidl/fidl_library.gni") + + not_needed(invoker, [ "meta" ]) + + fidl_library(target_name) { + forward_variables_from(invoker, "*") } + } else if (current_toolchain == default_toolchain) { + not_needed(invoker, + [ + "name", + "sources", + ]) + + fuchsia_fidl_library(target_name) { + forward_variables_from(invoker, "*") + } + } else { + not_needed("*") } } From ff2ef67736f5e82c6fe35dcf112bd079e03b9ef7 Mon Sep 17 00:00:00 2001 From: Erik Date: Mon, 26 Sep 2022 21:11:04 +0000 Subject: [PATCH 2/6] Update DEPS file to include new public fuchsia_fidl_library template --- DEPS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEPS b/DEPS index d08ac8d11bbb5..fa3d392ee51c9 100644 --- a/DEPS +++ b/DEPS @@ -109,7 +109,7 @@ allowed_hosts = [ ] deps = { - 'src': 'https://github.com/flutter/buildroot.git' + '@' + 'c9c2b77c9520903741ccda2fe12f773408a76c94', + 'src': 'https://github.com/flutter/buildroot.git' + '@' + 'b7ef254d8cec53bdad39cdb4a284af1d0a79dbdb', # Fuchsia compatibility # From 5d4c7a248c964071ec4a1c3aec263a689413e2ed Mon Sep 17 00:00:00 2001 From: Erik Date: Mon, 26 Sep 2022 23:51:53 +0000 Subject: [PATCH 3/6] Address PR comments --- .../tests/fidl/flutter.example.echo/BUILD.gn | 2 +- .../dart-jit-runner-integration-test.cc | 13 ++++++++----- .../dart_jit_runner/dart_jit_echo_server/BUILD.gn | 2 +- .../dart_jit_runner/dart_jit_echo_server/main.dart | 2 +- .../meta/dart-jit-echo-server.cml | 6 +++--- .../meta/dart-jit-runner-integration-test.cml | 8 ++++---- .../dart_jit_runner/meta/gtest_runner.shard.cml | 8 ++++---- testing/fuchsia/test_suites.yaml | 1 + 8 files changed, 23 insertions(+), 19 deletions(-) diff --git a/shell/platform/fuchsia/dart_runner/tests/fidl/flutter.example.echo/BUILD.gn b/shell/platform/fuchsia/dart_runner/tests/fidl/flutter.example.echo/BUILD.gn index 48efcd4d4c5a9..e129e9be136de 100644 --- a/shell/platform/fuchsia/dart_runner/tests/fidl/flutter.example.echo/BUILD.gn +++ b/shell/platform/fuchsia/dart_runner/tests/fidl/flutter.example.echo/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright 2019 The Fuchsia Authors. All rights reserved. +# 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. diff --git a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart-jit-runner-integration-test.cc b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart-jit-runner-integration-test.cc index b897f2546f2d5..b7d61132e36fd 100644 --- a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart-jit-runner-integration-test.cc +++ b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart-jit-runner-integration-test.cc @@ -1,4 +1,4 @@ -// Copyright 2022 The Flutter Authors. All rights reserved. +// 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. @@ -12,12 +12,15 @@ #include "flutter/fml/logging.h" #include "gtest/gtest.h" -using namespace component_testing; - -namespace dart_jit_runner::testing { +namespace dart_jit_runner_testing::testing { namespace { +using component_testing::ChildRef; +using component_testing::ParentRef; +using component_testing::Protocol; +using component_testing::RealmBuilder; using component_testing::RealmRoot; +using component_testing::Route; class RealmBuilderTest : public ::loop_fixture::RealLoop, public ::testing::Test { @@ -53,4 +56,4 @@ TEST_F(RealmBuilderTest, DartRunnerStartsUp) { } } // namespace -} // namespace dart_jit_runner::testing +} // namespace dart_jit_runner_testing::testing diff --git a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/BUILD.gn b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/BUILD.gn index a203bb671661f..bf5bc016ab6b6 100644 --- a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/BUILD.gn +++ b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/BUILD.gn @@ -25,7 +25,7 @@ dart_library("lib") { ] } -# Dart component that launches a simple "Hello World" application using JIT +# Dart component that serves the test Echo FIDL protocol, built using the Dart JIT runner dart_component("component") { testonly = true null_safe = true diff --git a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/main.dart b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/main.dart index b1bb3b062c5ba..5874f324d14e8 100644 --- a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/main.dart +++ b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/main.dart @@ -1,4 +1,4 @@ -// Copyright 2016 The Fuchsia Authors. All rights reserved. +// 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. diff --git a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/meta/dart-jit-echo-server.cml b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/meta/dart-jit-echo-server.cml index bdfc9f21f15c4..11c82b17548e7 100644 --- a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/meta/dart-jit-echo-server.cml +++ b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/meta/dart-jit-echo-server.cml @@ -1,6 +1,6 @@ -// Copyright 2022 The Fuchsia Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. +# 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" ], diff --git a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/dart-jit-runner-integration-test.cml b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/dart-jit-runner-integration-test.cml index cb61f60fc82ba..60ea214aac23d 100644 --- a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/dart-jit-runner-integration-test.cml +++ b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/dart-jit-runner-integration-test.cml @@ -1,6 +1,6 @@ -// Copyright 2022 The Fuchsia Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. +# 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: [ @@ -28,4 +28,4 @@ to: "#realm_builder", }, ], -} \ No newline at end of file +} diff --git a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/gtest_runner.shard.cml b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/gtest_runner.shard.cml index f47451554f09f..e74f37ae800d3 100644 --- a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/gtest_runner.shard.cml +++ b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/gtest_runner.shard.cml @@ -1,6 +1,6 @@ -// Copyright 2022 The Fuchsia Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. +# 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: { @@ -15,4 +15,4 @@ from: "self", }, ], -} \ No newline at end of file +} diff --git a/testing/fuchsia/test_suites.yaml b/testing/fuchsia/test_suites.yaml index 6a04e1fb3304e..498e2b28add56 100644 --- a/testing/fuchsia/test_suites.yaml +++ b/testing/fuchsia/test_suites.yaml @@ -40,4 +40,5 @@ - test_command: run-test-suite fuchsia-pkg://fuchsia.com/dart-jit-runner-integration-test#meta/dart-jit-runner-integration-test.cm packages: - 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 From 4ba4e97c8c1a94496716131aebb218d30441cf3b Mon Sep 17 00:00:00 2001 From: Erik Date: Tue, 27 Sep 2022 16:55:26 +0000 Subject: [PATCH 4/6] Proper comment blocks for CML files --- .../dart_jit_echo_server/meta/dart-jit-echo-server.cml | 6 +++--- .../meta/dart-jit-runner-integration-test.cml | 6 +++--- .../dart_jit_runner/meta/gtest_runner.shard.cml | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/meta/dart-jit-echo-server.cml b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/meta/dart-jit-echo-server.cml index 11c82b17548e7..7d5d684507154 100644 --- a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/meta/dart-jit-echo-server.cml +++ b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/meta/dart-jit-echo-server.cml @@ -1,6 +1,6 @@ -# 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. +// 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" ], diff --git a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/dart-jit-runner-integration-test.cml b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/dart-jit-runner-integration-test.cml index 60ea214aac23d..af47353d2835e 100644 --- a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/dart-jit-runner-integration-test.cml +++ b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/dart-jit-runner-integration-test.cml @@ -1,6 +1,6 @@ -# 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. +// 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: [ diff --git a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/gtest_runner.shard.cml b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/gtest_runner.shard.cml index e74f37ae800d3..f6cfe507747ad 100644 --- a/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/gtest_runner.shard.cml +++ b/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/meta/gtest_runner.shard.cml @@ -1,6 +1,6 @@ -# 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. +// 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: { From c7edd133ce23dff61d1ff0c1554ca77bd706b430 Mon Sep 17 00:00:00 2001 From: Erik Date: Tue, 27 Sep 2022 18:30:31 +0000 Subject: [PATCH 5/6] Correct naming for dart_jit_runner FAR file --- testing/fuchsia/test_suites.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/fuchsia/test_suites.yaml b/testing/fuchsia/test_suites.yaml index 498e2b28add56..cb486da1b0b3c 100644 --- a/testing/fuchsia/test_suites.yaml +++ b/testing/fuchsia/test_suites.yaml @@ -40,5 +40,5 @@ - test_command: run-test-suite fuchsia-pkg://fuchsia.com/dart-jit-runner-integration-test#meta/dart-jit-runner-integration-test.cm packages: - dart-jit-runner-integration-test-0.far - - dart-jit-runner-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 From 065f76501a21bce4b8614c01befe8463dbdd862e Mon Sep 17 00:00:00 2001 From: Erik Date: Tue, 27 Sep 2022 18:43:49 +0000 Subject: [PATCH 6/6] Replace underscore with dash --- testing/fuchsia/test_suites.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/fuchsia/test_suites.yaml b/testing/fuchsia/test_suites.yaml index cb486da1b0b3c..711b7eff700a4 100644 --- a/testing/fuchsia/test_suites.yaml +++ b/testing/fuchsia/test_suites.yaml @@ -40,5 +40,5 @@ - test_command: run-test-suite fuchsia-pkg://fuchsia.com/dart-jit-runner-integration-test#meta/dart-jit-runner-integration-test.cm packages: - dart-jit-runner-integration-test-0.far - - dart_jit_runner_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