blob: c25f9b72ba1d59e28285b1be73df66f4b5863bb5 [file]
# Copyright 2020 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("//tools/devshell/test_runner/host_script_test.gni")
if (!is_host) {
group("fx") {
deps = []
}
} else {
# Host tools required by fx commands.
#
# Generally, an fx command that depends on a host tool should compile that
# tool on-the-fly. However, this incurs a significant slowdown due to the
# latency of starting up ninja. Therefore, host tools called by commonly-used
# and latency-sensitive fx commands may be included here so they're latently
# available and get automatically rebuilt by every `fx build`.
group("fx") {
deps = [
"//src/developer/ffx:ffx_tool",
"//tools/net/device-finder:host",
"//tools/symbolizer",
# For `fx format-code`.
"//build/tools/formatjson5",
"//tools/cmc",
"//tools/fidl/fidlc:fidl-format",
"//tools/fidl/gidl-format",
# For `fx klog`.
"//tools/loglistener:host",
# For `fx lint`.
"//tools/fidl/fidlc:fidl-lint",
"//tools/staticanalysis/clippy-reporter",
# For `fx pretty_serial`.
"//tools/pretty_serial",
# For 'fx create'.
"//tools/create",
# For `fx bindc`.
"//tools/bindc:host",
# For `fx test`.
"//scripts/fxtest/python:install($host_toolchain)",
# For Python devshell tools
"//tools/devshell/python:install($host_toolchain)",
# For `fx disable_ctf_tests`
"//scripts/disable_ctf_tests:install",
# For `fx debug`.
"//scripts/debug:install",
]
}
}
# Tests need to be in the default toolchain, because build_api_module only
# collects metadata (into tests.json) from the default toolchain.
group("tests") {
testonly = true
deps = [
":fx_script_tests($host_toolchain)",
"//tools/devshell/fx_cli:tests($host_toolchain)",
"//tools/devshell/lib:tests($host_toolchain)",
"//tools/devshell/python:tests($host_toolchain)",
]
}
# This is the list of test scripts that should be run to
# test the bash fx scripts.
test_scripts = [
"tests/fx-internal/bash_test_framework_test",
"tests/fx-internal/disktools_test",
"tests/fx-internal/ffx_target_list_usage_test",
"tests/fx-internal/fvm_test",
"tests/fx-internal/fx_helpers_test",
"tests/fx-internal/fx_registered_host_tool_test",
"tests/fx-internal/fx_test",
"tests/fx-internal/fx_update_path_test",
"tests/fx-internal/metrics_test",
"tests/fx-internal/mock_test",
"tests/fx-internal/optional-features_test",
"tests/fx-internal/reentry_test",
"tests/fx-internal/regenerator_test",
"tests/fx-internal/vars_test",
"tests/fx-internal/verify_default_keys_test",
"tests/subcommands/fx_add_test_test",
"tests/subcommands/fx_build_test",
"tests/subcommands/fx_clean_test",
"tests/subcommands/fx_config_load_test",
"tests/subcommands/fx_cp_test",
"tests/subcommands/fx_flash_fuchsia_test",
"tests/subcommands/fx_format_code_test",
"tests/subcommands/fx_lint_test",
"tests/subcommands/fx_get_device_test",
"tests/subcommands/fx_get_flash_source_test",
"tests/subcommands/fx_helpdoc_test",
"tests/subcommands/fx_host_tool_test",
"tests/subcommands/fx_klog_test",
"tests/subcommands/fx_list_build_artifacts_test",
"tests/subcommands/fx_log_test",
"tests/subcommands/fx_mkzedboot_test",
"tests/subcommands/fx_ota_test",
"tests/subcommands/fx_remote_test",
"tests/subcommands/fx_serve_test",
"tests/subcommands/fx_set_test",
"tests/subcommands/fx_set_device_test",
"tests/subcommands/fx_setup_go_test",
"tests/subcommands/fx_ssh_test",
"tests/subcommands/fx_sync_test",
"tests/subcommands/fx_test_test",
"tests/subcommands/fx_unset_device_test",
"tests/subcommands/fx_use_test",
]
# Copies the files needed for the tests to the out dir
# This stages the data and builds the metadata needed to
# have these files included in the test runtime deps.
#
# The datasets are copied to the data_path directory.
# The source_base_dir must be a prefix of the files
# being copied. The target_base dir is the destination
# directory within the data_path.
#
# There are multiple datasets, one for each unique source_base_dir.
host_script_test_data("fx_bash_tests") {
data_path = "fx_bash_tests"
datasets = [
{
source_base_dir = "//scripts"
target_base_dir = "scripts"
files = [
"//scripts/fx",
"//scripts/fx-env.sh",
"//scripts/fx-help.awk",
"//scripts/fx-reentry",
"//scripts/fuchsia-vendored-python3.14",
"//scripts/hermetic-env",
]
},
{
source_base_dir = "//tools/devshell/tests"
target_base_dir = "tools/devshell/tests"
files = []
foreach(f, test_scripts) {
files += [ "//tools/devshell/$f" ]
}
},
{
source_base_dir = "//tools/devshell/tests/lib"
target_base_dir = "tools/devshell"
files = [ "//tools/devshell/tests/lib/script_runner.sh" ]
},
{
source_base_dir = "//tools/devshell/tests/lib"
target_base_dir = "tools/devshell/tests/lib"
files = [
"//tools/devshell/tests/lib/bash_test_framework.sh",
"//tools/devshell/tests/lib/fuchsia-mock.sh",
"//tools/devshell/tests/lib/mock.sh",
]
},
{
source_base_dir = "//build"
target_base_dir = "build"
files = [
"//build/api/client",
"//build/auth/apt.py",
"//build/auth/gcloud_creds.py",
"//build/auth/select_auth_method.py",
"//build/bazel/config/bazel_top_dir",
"//build/force_clean/force_clean_if_needed.py",
"//build/profile/hardware_profiler.py",
"//build/profile/profile_wrap.sh",
"//build/profile/profile_wrap.py",
"//build/python/modules/serialization/serialization.py",
"//build/rbe/fuchsia-reproxy-wrap.sh",
"//build/rbe/reproxy_wrap.py",
"//build/rbe/profiles/default.json",
"//build/regenerator",
"//build/resultstore/fuchsia-rsproxy-wrap.sh",
"//build/resultstore/rsproxy_wrap.py",
"//build/resultstore/profiles/default.json",
"//build/scripts/graceful_timeout.py",
"//build/scripts/main_build.py",
"//build/scripts/managed_process.py",
# TODO(b/567721959): Migrate devshell build tests to Python to avoid
# manual file dependency tracking.
"//build/scripts/service_profile.py",
"//build/tui/build-tui-wrap.sh",
"//build/tui/build_tui_wrap.py",
# Python modules directly imported by main_build.py
# LINT.IfChange(main_build_python_imports)
"//build/auth/auth_env.py",
"//build/auth/gcloud.py",
"//build/bazel/scripts/bazel_invocation.py",
"//build/profile/procfs.py",
"//build/rbe/casfs.py",
"//build/rbe/rbe_profile.py",
"//build/rbe/rbe_settings.py",
"//build/resultstore/rs_profile.py",
"//build/scripts/build_timeout.py",
"//build/scripts/properties.py",
"//build/scripts/pstree.py",
"//build/scripts/python_subprocess.py",
"//build/scripts/signal_utils.py",
"//build/scripts/top_build_wrap.py",
# LINT.ThenChange(//build/scripts/main_build.py:main_build_python_imports,
# //tools/devshell/tests/subcommands/fx_build_test:main_build_python_imports)
]
},
{
source_base_dir = "//tools/devshell"
target_base_dir = "tools/devshell"
# Consolidated dependencies of all scripts. Extracted with:
# find tools/devshell/tests -name "*_test" -type f | xargs cat | awk '/^[
# ]*BT_FILE_DEPS=/{flag=1;next}/[ ]*\)/{flag=0}flag' | grep
# "tools/devshell" | sort -u | sed 's/[ ]*"\(.*\)".*/ "\/\/\1",/'
files = [
# Essential tools and libraries for fx build and its tests
"//tools/devshell/build",
"//tools/devshell/build-metrics",
"//tools/devshell/contrib/add-host-test",
"//tools/devshell/contrib/add-test",
"//tools/devshell/contrib/ffx",
"//tools/devshell/contrib/lib/count-ninja-actions.py",
"//tools/devshell/contrib/setup-go",
"//tools/devshell/clean",
"//tools/devshell/cp",
"//tools/devshell/flash",
"//tools/devshell/flash-remote",
"//tools/devshell/format-code",
"//tools/devshell/format_code.py",
"//tools/devshell/fx_cli/__init__.py",
"//tools/devshell/fx_cli/builder.py",
"//tools/devshell/fx_cli/locator.py",
"//tools/devshell/fx_cli/registry.py",
"//tools/devshell/fx_host_tools.json",
"//tools/devshell/get-build-dir",
"//tools/devshell/get-device",
"//tools/devshell/get-device-addr",
"//tools/devshell/get-flash-source",
"//tools/devshell/go",
"//tools/devshell/helpdoc",
"//tools/devshell/host-tool",
"//tools/devshell/jq.fx",
"//tools/devshell/klog",
"//tools/devshell/lib/bazel_utils.sh",
"//tools/devshell/lib/get_fuchsia_subdir_git_revision.sh",
"//tools/devshell/lib/build_api_client.sh",
"//tools/devshell/lib/disktools.sh",
"//tools/devshell/lib/credentials.sh",
"//tools/devshell/lib/fvm.sh",
"//tools/devshell/lib/fx-cmd-locator.sh",
"//tools/devshell/lib/fx-flash.sh",
"//tools/devshell/lib/fx-mkzedboot.sh",
"//tools/devshell/lib/fx-optional-features.sh",
"//tools/devshell/lib/fx-remote.sh",
"//tools/devshell/lib/generate-ssh-config.sh",
"//tools/devshell/lib/host_symbolizer.sh",
"//tools/devshell/lib/metrics.sh",
"//tools/devshell/lib/platform.sh",
"//tools/devshell/lib/style.sh",
"//tools/devshell/lib/updates.sh",
"//tools/devshell/lib/vars.sh",
"//tools/devshell/lib/is_invoked_by_agent.sh",
"//tools/devshell/lib/agent_session_ids.txt",
"//tools/devshell/lib/agents.txt",
"//tools/devshell/lib/scm.py",
"//tools/devshell/lib/shac_runner.py",
"//tools/devshell/lib/verify-default-keys.sh",
"//tools/devshell/lint",
"//tools/devshell/lint.py",
"//tools/devshell/list-build-artifacts",
"//tools/devshell/log",
"//tools/devshell/metrics",
"//tools/devshell/mkzedboot",
"//tools/devshell/ota",
"//tools/devshell/rbe",
"//tools/devshell/reboot",
"//tools/devshell/serve",
"//tools/devshell/serve-remote",
"//tools/devshell/set",
"//tools/devshell/set-device",
"//tools/devshell/shell",
"//tools/devshell/sync",
"//tools/devshell/test",
"//tools/devshell/tests/subcommands/data/fx_format_code_test/fidl.test.fidl",
"//tools/devshell/tests/subcommands/data/fx_format_code_test/cml.cml",
"//tools/devshell/tests/subcommands/data/fx_format_code_test/cplusplus.cc",
"//tools/devshell/tests/subcommands/data/fx_format_code_test/gidl.gidl",
"//tools/devshell/tests/subcommands/data/fx_format_code_test/gn.gn",
"//tools/devshell/tests/subcommands/data/fx_format_code_test/gn.gni",
"//tools/devshell/tests/subcommands/data/fx_format_code_test/json5.json5",
"//tools/devshell/tests/subcommands/data/fx_format_code_test/python3.py",
"//tools/devshell/tests/subcommands/data/fx_format_code_test/rust.rs",
"//tools/devshell/tests/subcommands/data/fx_serve_update_test/testpackage.json",
"//tools/devshell/tests/subcommands/data/fx_serve_update_test/testpackage.manifest",
"//tools/devshell/tests/subcommands/data/fx_set_test/myboard.gni",
"//tools/devshell/tests/subcommands/data/fx_set_test/myproduct.gni",
"//tools/devshell/unset-device",
"//tools/devshell/use",
"//tools/devshell/vendor",
]
},
{
source_base_dir = target_out_dir
target_base_dir = "tools/devshell"
files = [ "${target_out_dir}/run_fx_bash_tests_driver.sh" ]
},
{
source_base_dir = "//prebuilt"
target_base_dir = "prebuilt"
files = [ "//prebuilt/third_party/jq/${host_platform}/bin/jq" ]
},
]
data_deps = [ ":run_fx_bash_tests_driver" ]
}
generated_file("run_fx_bash_tests_driver") {
outputs = [ "${target_out_dir}/run_fx_bash_tests_driver.sh" ]
contents =
read_file("//tools/devshell/tests/lib/script_header.sh", "list lines")
foreach(s, test_scripts) {
contents += [ "tools/devshell/script_runner.sh $s" ]
}
}
# This is the entrypoint for the fx script tests.
host_script_test("fx_script_tests") {
# Script path is relative to $testroot
test_root = "fx_bash_tests"
test_script = "fx_bash_tests/tools/devshell/run_fx_bash_tests_driver.sh"
data_deps = [ ":fx_bash_tests" ]
}