| # 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. |
| |
| import("//build/assembly/assembled_system.gni") |
| import("//build/assembly/board_configuration.gni") |
| import("//build/assembly/product_assembly_configuration.gni") |
| import("//build/board.gni") |
| import("//build/components/fuchsia_package.gni") |
| import("//build/config.gni") |
| import("//build/testing/host_test_data.gni") |
| |
| _assemble_system_target_name = "assembly" |
| _assemble_system_recovery_target_name = "assembly_recovery" |
| |
| if (is_fuchsia) { |
| # `assembled_system` needs at least one package in base_packages. |
| fuchsia_package("empty-pkg") { |
| testonly = true |
| package_name = "empty-pkg" |
| } |
| |
| config_data("empty_config") { |
| for_pkg = "empty-pkg" |
| sources = [ "empty_config" ] |
| outputs = [ "empty/{{source_file_part}}" ] |
| } |
| |
| board_configuration("board_config") { |
| name = "test" |
| filesystems = { |
| fvm = { |
| slice_size = 1048576 |
| sparse_output = { |
| } |
| } |
| } |
| } |
| |
| product_assembly_configuration("product_config") { |
| platform = { |
| build_type = "eng" |
| feature_set_level = "bootstrap" |
| storage = { |
| filesystems = { |
| image_name = _assemble_system_target_name |
| volume = { |
| fvm = { |
| data = { |
| } |
| blob = { |
| } |
| } |
| } |
| } |
| } |
| } |
| product = { |
| } |
| } |
| |
| product_assembly_configuration("product_config_recovery") { |
| platform = { |
| build_type = "eng" |
| feature_set_level = "bootstrap" |
| storage = { |
| filesystems = { |
| image_name = _assemble_system_recovery_target_name |
| volume = { |
| fvm = { |
| data = { |
| } |
| blob = { |
| } |
| } |
| } |
| } |
| } |
| } |
| product = { |
| } |
| } |
| |
| # `assembled_system` builds a zbi and blob.blk for consumption by the test. |
| assembled_system(_assemble_system_target_name) { |
| testonly = true |
| generate_fvm = true |
| product_assembly_config_label = ":product_config" |
| board_config_label = ":board_config" |
| use_bringup_platform_bundles_only = true |
| bootfs_labels = [] |
| base_packages = [ |
| ":empty-pkg", |
| ":empty_config", |
| ] |
| } |
| |
| # `assembled_system` builds a zbi, specifying `ramdisk_in_zbi = true` |
| # tests the path where the blobfs exists in the zbi and is automatically |
| # extracted as part of the zbi, such as in recovery images. |
| assembled_system(_assemble_system_recovery_target_name) { |
| testonly = true |
| generate_fvm = true |
| product_assembly_config_label = ":product_config_recovery" |
| board_config_label = ":board_config" |
| use_bringup_platform_bundles_only = true |
| bootfs_labels = [] |
| ramdisk_in_zbi = true |
| base_packages = [ |
| ":empty-pkg", |
| ":empty_config", |
| ] |
| } |
| } |
| |
| if (is_host) { |
| if (has_board) { |
| group("host_tests") { |
| testonly = true |
| deps = [ ":scrutiny_ffx_integration_test" ] |
| } |
| |
| host_test_data("testdata") { |
| deps = [ |
| ":${_assemble_system_recovery_target_name}.image_assembler($target_toolchain)", |
| ":${_assemble_system_target_name}.image_assembler($target_toolchain)", |
| ] |
| sources = [ |
| get_label_info( |
| ":${_assemble_system_target_name}.image_assembler($target_toolchain)", |
| "target_out_dir") + "/${_assemble_system_target_name}/blob.blk", |
| get_label_info( |
| ":${_assemble_system_target_name}.image_assembler($target_toolchain)", |
| "target_out_dir") + "/${_assemble_system_target_name}/${_assemble_system_target_name}.zbi", |
| get_label_info( |
| ":${_assemble_system_recovery_target_name}.image_assembler($target_toolchain)", |
| "target_out_dir") + "/${_assemble_system_recovery_target_name}/${_assemble_system_recovery_target_name}.zbi", |
| ] |
| outputs = [ "$target_out_dir/testdata/{{source_file_part}}" ] |
| |
| metadata = { |
| package_barrier = [] |
| } |
| } |
| |
| # Required for the test to be able to call ffx. |
| host_test_data("copy_host_tools") { |
| sources = [ "${host_tools_dir}/ffx-scrutiny" ] |
| deps = [ "//src/developer/ffx/plugins/scrutiny:ffx_scrutiny_tool_host_tool($host_toolchain)" ] |
| outputs = [ "$target_out_dir/host_tools/{{source_file_part}}" ] |
| } |
| |
| config("config") { |
| ffx_path = "$target_out_dir/host_tools/ffx-scrutiny" |
| blobfs_path = "$target_out_dir/testdata/blob.blk" |
| zbi_path = "$target_out_dir/testdata/${_assemble_system_target_name}.zbi" |
| recovery_zbi_path = "$target_out_dir/testdata/${_assemble_system_recovery_target_name}.zbi" |
| |
| rustenv = [ |
| "FFX_TOOL_PATH=" + rebase_path(ffx_path, root_build_dir), |
| "BLOBFS_PATH=" + rebase_path(blobfs_path, root_build_dir), |
| "ZBI_PATH=" + rebase_path(zbi_path, root_build_dir), |
| "RECOVERY_ZBI_PATH=" + rebase_path(recovery_zbi_path, root_build_dir), |
| ] |
| } |
| |
| rustc_test("scrutiny_ffx_integration_test") { |
| source_root = "src/lib.rs" |
| edition = "2021" |
| deps = [ |
| ":copy_host_tools", |
| ":testdata", |
| "//third_party/rust_crates:tempfile", |
| ] |
| sources = [ "src/lib.rs" ] |
| configs += [ ":config" ] |
| |
| # TODO(https://fxbug.dev/42179241): LSAN says that Scrutiny has a leak, disable this test in ASAN |
| if (is_asan) { |
| test_environments = [] |
| } |
| } |
| } else { |
| # If there's no board, just stub out the host_tests group. |
| group("host_tests") { |
| } |
| |
| # And then these vars aren't needed. |
| not_needed([ |
| "_assemble_system_target_name", |
| "_assemble_system_recovery_target_name", |
| ]) |
| } |
| } |