diff --git a/DEPS b/DEPS index eb097ccdcf..6b834814c1 100644 --- a/DEPS +++ b/DEPS @@ -244,6 +244,11 @@ vars = { "upstream_yaml": "https://github.com/dart-lang/yaml.git", "upstream_yapf": "https://github.com/google/yapf.git", "upstream_zlib": "https://github.com/madler/zlib.git", + + # The version / instance id of the cipd:chromium/fuchsia/test-scripts which + # will be used altogether with fuchsia-sdk to setup the build / test + # environment. + 'fuchsia_test_scripts_version': 'xMcCltDynP2JMZNUekFtV24vCnjgz_J3SZIN-4FbUKQC', } gclient_gn_args_file = 'src/third_party/dart/build/config/gclient_args.gni' @@ -929,7 +934,7 @@ deps = { # Get the SDK from https://chrome-infra-packages.appspot.com/p/fuchsia/sdk/core at the 'latest' tag # Get the toolchain from https://chrome-infra-packages.appspot.com/p/fuchsia/clang at the 'goma' tag - 'src/fuchsia/sdk/linux': { + 'src/fuchsia/sdk/linux': { 'packages': [ { 'package': 'fuchsia/sdk/core/linux-amd64', @@ -940,6 +945,17 @@ deps = { 'dep_type': 'cipd', }, + 'src/fuchsia/test_scripts': { + 'packages': [ + { + 'package': 'chromium/fuchsia/test-scripts', + 'version': Var('fuchsia_test_scripts_version'), + } + ], + 'condition': 'host_os == "linux"', + 'dep_type': 'cipd', + }, + 'src/third_party/impeller-cmake-example': { 'url': Var('flutter_git') + '/impeller-cmake-example.git' + '@' + 'd1a26a51dc6890e5f851749e3d8e048703f24f51', 'condition': 'download_impeller_cmake_example', @@ -1101,5 +1117,16 @@ hooks = [ 'third_party/impeller-cmake-example', '--setup', ] + }, + { + 'name': 'Download Fuchsia system images', + 'pattern': '.', + 'condition': 'host_os == "linux"', + 'action': [ + 'python3', + 'src/flutter/tools/fuchsia/with_envs.py', + 'src/fuchsia/test_scripts/update_product_bundles.py', + 'terminal.x64', + ] } ] diff --git a/engine/src/flutter/.ci.yaml b/engine/src/flutter/.ci.yaml index 7b68a7e2b0..98db64035a 100644 --- a/engine/src/flutter/.ci.yaml +++ b/engine/src/flutter/.ci.yaml @@ -195,6 +195,8 @@ targets: config_name: linux_fuchsia drone_dimensions: - os=Linux + dimensions: + kvm: "1" # TODO(https://github.com/flutter/flutter/issues/138559): Re-enable/delete. # runIfNot: # - lib/web_ui/** diff --git a/engine/src/flutter/ci/builders/linux_fuchsia.json b/engine/src/flutter/ci/builders/linux_fuchsia.json index 6388b1e9b1..3fe05050e4 100644 --- a/engine/src/flutter/ci/builders/linux_fuchsia.json +++ b/engine/src/flutter/ci/builders/linux_fuchsia.json @@ -77,7 +77,7 @@ { "name": "Upload to Symbol Server for arch: arm64", "language": "python3", - "contexts": ["depot_tools_on_path"], + "contexts": ["depot_tools_on_path"], "script": "flutter/tools/fuchsia/upload_to_symbol_server.py", "parameters": [ "--symbol-dir", @@ -163,7 +163,7 @@ { "name": "Upload to Symbol Server for arch: x64", "language": "python3", - "contexts": ["depot_tools_on_path"], + "contexts": ["depot_tools_on_path"], "script": "flutter/tools/fuchsia/upload_to_symbol_server.py", "parameters": [ "--symbol-dir", @@ -172,6 +172,14 @@ "${REVISION}", "--upload" ] + }, + { + "name": "x64 emulator based tests", + "language": "python3", + "script": "flutter/tools/fuchsia/with_envs.py", + "parameters": [ + "testing/fuchsia/run_tests.py" + ] } ] } diff --git a/engine/src/flutter/ci/licenses_golden/excluded_files b/engine/src/flutter/ci/licenses_golden/excluded_files index 9847624da5..c3ee22b8b1 100644 --- a/engine/src/flutter/ci/licenses_golden/excluded_files +++ b/engine/src/flutter/ci/licenses_golden/excluded_files @@ -1122,6 +1122,7 @@ ../../../flutter/tools/licenses/pubspec.yaml ../../../flutter/tools/licenses/test ../../../flutter/web_sdk +../../../fuchsia/images ../../../fuchsia/sdk/linux/.build-id ../../../fuchsia/sdk/linux/.versions ../../../fuchsia/sdk/linux/AUTHORS @@ -1434,6 +1435,7 @@ ../../../fuchsia/sdk/linux/pkg/zx/meta.json ../../../fuchsia/sdk/linux/tools ../../../fuchsia/sdk/linux/version_history.json +../../../fuchsia/test_scripts ../../../out ../../../third_party/abseil-cpp/.git ../../../third_party/abseil-cpp/.github diff --git a/engine/src/flutter/ci/licenses_golden/tool_signature b/engine/src/flutter/ci/licenses_golden/tool_signature index 89e6ae1518..02a5b5dddb 100644 --- a/engine/src/flutter/ci/licenses_golden/tool_signature +++ b/engine/src/flutter/ci/licenses_golden/tool_signature @@ -1,2 +1,2 @@ -Signature: b0fbe71c20bdf5b2a1c163281b1f90de +Signature: 2f236965c1094091d6a2bb9532023b96 diff --git a/engine/src/flutter/testing/fuchsia/run_tests.py b/engine/src/flutter/testing/fuchsia/run_tests.py new file mode 100755 index 0000000000..929b022fd8 --- /dev/null +++ b/engine/src/flutter/testing/fuchsia/run_tests.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python3 +# Copyright (c) 2024, the Flutter project 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 argparse +import os +import sys + +# The imports are coming from fuchsia/test_scripts and pylint cannot find them +# without setting a global init-hook which is less favorable. +# But this file will be executed as part of the CI, its correctness of importing +# is guaranteed. + +sys.path.insert( + 0, + os.path.join( + os.path.dirname(__file__), '../../../fuchsia/test_scripts/test/' + ) +) + +# pylint: disable=import-error, wrong-import-position +import run_test +from run_executable_test import ExecutableTestRunner +from test_runner import TestRunner + +# This file is expected to be executed from src/flutter/. + + +# TODO(https://github.com/flutter/flutter/issues/140179): Execute all the tests +# in +# https://github.com/flutter/engine/blob/main/testing/fuchsia/test_suites.yaml +# and avoid hardcoded paths. +def _get_test_runner(runner_args: argparse.Namespace, *_) -> TestRunner: + return ExecutableTestRunner( + runner_args.out_dir, [], + 'fuchsia-pkg://fuchsia.com/dart_runner_tests#meta/dart_runner_tests.cm', + runner_args.target_id, 'codecoverage', '/tmp/log', + ['../out/fuchsia_debug_x64/dart_runner_tests.far'], None + ) + + +# TODO(https://github.com/flutter/flutter/issues/140179): Respect build +# configurations. +if __name__ == '__main__': + try: + os.remove('../out/fuchsia_debug_x64/dart_runner_tests.far') + except FileNotFoundError: + pass + os.symlink( + 'dart_runner_tests-0.far', + '../out/fuchsia_debug_x64/dart_runner_tests.far' + ) + sys.argv.append('--out-dir=out/fuchsia_debug_x64') + # The 'flutter-test-type' is a place holder and has no specific meaning; the + # _get_test_runner is overrided. + sys.argv.append('flutter-test-type') + run_test._get_test_runner = _get_test_runner # pylint: disable=protected-access + sys.exit(run_test.main()) diff --git a/engine/src/flutter/tools/fuchsia/with_envs.py b/engine/src/flutter/tools/fuchsia/with_envs.py new file mode 100644 index 0000000000..38702743ac --- /dev/null +++ b/engine/src/flutter/tools/fuchsia/with_envs.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python3 +# Copyright (c) 2024, the Flutter project 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 os +import platform +import subprocess +import sys + +sys.path.insert( + 0, + os.path.abspath( + os.path.join( + os.path.dirname(__file__), '../../../fuchsia/test_scripts/test/' + ) + ) +) + +from common import catch_sigterm, wait_for_sigterm + + +def Main(): + """ + Executes the test-scripts with required environment variables. It acts like + /usr/bin/env, but provides some extra functionality to dynamically set up + the environment variables. + """ + # Ensures the signals can be correctly forwarded to the subprocesses. + catch_sigterm() + + # Flutter uses a different repo structure and fuchsia sdk is not in the + # third_party/, so setting the DIR_SRC_ROOT does not make sense. + os.environ['FUCHSIA_IMAGES_ROOT'] = os.path.abspath( + os.path.join(os.path.dirname(__file__), '../../../fuchsia/images/') + ) + + assert platform.system() == 'Linux', 'Unsupported OS ' + platform.system() + os.environ['FUCHSIA_SDK_ROOT'] = os.path.abspath( + os.path.join(os.path.dirname(__file__), '../../../fuchsia/sdk/linux') + ) + + with subprocess.Popen(sys.argv[1:]) as proc: + try: + proc.wait() + except: + # Use terminate / SIGTERM to allow the subprocess exiting cleanly. + proc.terminate() + return proc.returncode + + +if __name__ == '__main__': + sys.exit(Main()) diff --git a/engine/src/flutter/tools/licenses/lib/paths.dart b/engine/src/flutter/tools/licenses/lib/paths.dart index 3136c27239..776416db33 100644 --- a/engine/src/flutter/tools/licenses/lib/paths.dart +++ b/engine/src/flutter/tools/licenses/lib/paths.dart @@ -101,6 +101,7 @@ final Set skippedPaths = { r'flutter/third_party/yapf', // only used for code formatting r'flutter/tools', r'flutter/web_sdk', // this code is not linked into Flutter apps; it's only used by engine tests and tools + r'fuchsia/images', r'fuchsia/sdk/linux/docs', r'fuchsia/sdk/linux/meta', r'fuchsia/sdk/linux/NOTICE.fuchsia', // covers things that contribute to the Fuchsia SDK; see fxb/94240 @@ -110,6 +111,7 @@ final Set skippedPaths = { r'fuchsia/sdk/mac/meta', r'fuchsia/sdk/mac/NOTICE.fuchsia', r'fuchsia/sdk/mac/tools', + r'fuchsia/test_scripts', r'out', // output of build r'third_party/android_embedding_dependencies', // Not shipped. Used only for the build-time classpath, and for the in-tree testing framework for Android r'third_party/android_tools', // excluded on advice